# Filepaths and Hard-coded Defaults
proj_root = "/home/users/kcochran/oak/kcochran/procap_models/"
sequence_path = proj_root + "genomes/GRCh38_no_alt_analysis_set_GCA_000001405.15.fasta"
chrom_sizes = proj_root + "genomes/hg38.chrom.sizes.withrRNA"
in_window = 2114
out_window = 1000
# stuff to get from config file
with open("2022-07-24_12-31-29_run1_modisco_config_K562_counts.txt") as config_f:
config_dict = {line.split()[0] : line.strip().split()[1] for line in config_f}
modisco_out_path = config_dict["modisco_out_path"]
scoring_type = config_dict["scoring_type"]
score_center_size = int(config_dict["score_center_size"])
profile_display_center_size = int(config_dict["profile_display_center_size"])
train_val_type = config_dict["train_val_type"]
# digest what's in config file
if not modisco_out_path.endswith("/"):
modisco_out_path = modisco_out_path + "/"
assay_type, model_type, cell, accession, modisco_dir_base = modisco_out_path.split("/")[-6:-1]
ts_part1, ts_part2, run_str, _ = modisco_dir_base.split("_")
timestamp = ts_part1 + "_" + ts_part2
run = int(run_str.replace("run", ""))
print(modisco_out_path)
print("cell_type:", cell, accession)
print("timestamp:", timestamp)
print("run:", run)
print("scoring_type:", scoring_type)
print("score_center_size:", score_center_size)
print("profile_display_center_size:", profile_display_center_size)
/home/users/kcochran/oak/kcochran/procap_models/modisco_out/procap/bpnetlite_basic_v2/K562/ENCSR261KBX/2022-07-24_12-31-29_run1_modisco/ cell_type: K562 ENCSR261KBX timestamp: 2022-07-24_12-31-29 run: 1 scoring_type: counts score_center_size: 1000 profile_display_center_size: 400
data_dir = proj_root + "/data/procap/processed/" + cell + "/" + accession + "/"
plus_bw_path = data_dir + "final.5prime.pos.bigWig"
minus_bw_path = data_dir + "final.5prime.neg.bigWig"
val_peak_path = data_dir + "peaks_uni_and_bi_" + train_val_type + ".bed.gz"
val_save_dir = proj_root + "model_out/" + assay_type + "/" + model_type + "/" + cell + "/" + accession + "/"
val_save_path = val_save_dir + timestamp + "_run" + str(run) + "_" + train_val_type
attr_save_path = val_save_dir.replace("model_out", "deepshap_out") + timestamp + "_run" + str(run) + "_deepshap"
# task-specific filepaths
import os
assert scoring_type in ["profile", "counts"], scoring_type
if scoring_type == "profile":
score_type_short = "prof"
else:
score_type_short = "count"
scores_path = attr_save_path + "_" + score_type_short + ".npy"
onehot_scores_path = attr_save_path + "_" + score_type_short + "_onehot.npy"
modisco_obj_path = modisco_out_path + "results_allChroms_" + score_type_short + "_slice" + str(score_center_size) + ".hdf5"
seqlet_path = modisco_out_path + "seqlets_" + score_type_short + ".txt"
tomtom_dir = modisco_out_path + "tomtom_" + score_type_short
assert(os.path.exists(scores_path)), scores_path
assert(os.path.exists(onehot_scores_path)), onehot_scores_path
# Imports, Plotting Defaults
import matplotlib.pyplot as plt
import matplotlib.font_manager as font_manager
plot_params = {
"figure.titlesize": 22,
"axes.titlesize": 22,
"axes.labelsize": 20,
"legend.fontsize": 18,
"xtick.labelsize": 16,
"ytick.labelsize": 16,
"font.weight": "bold"
}
plt.rcParams.update(plot_params)
from IPython.display import display
import tqdm
tqdm.tqdm_notebook()
import numpy as np
from view_modisco_results_utils import *
from tomtom_utils import *
/home/users/kcochran/miniconda3/envs/procap/lib/python3.7/site-packages/ipykernel_launcher.py:19: TqdmDeprecationWarning: This function will be removed in tqdm==5.0.0 Please use `tqdm.notebook.tqdm` instead of `tqdm.tqdm_notebook`
# Load in True Profiles and Sequences
import sys
sys.path.append('../1_train_models')
from data_loading import extract_peaks
one_hot_seqs, true_profs = extract_peaks(sequence_path,
plus_bw_path, minus_bw_path, val_peak_path, in_window, out_window,
max_jitter=0, verbose=True)
one_hot_seqs = one_hot_seqs.swapaxes(1,2)
one_hot_seqs = one_hot_seqs[:, (in_window // 2 - score_center_size // 2):(in_window // 2 + score_center_size // 2), :]
Reading FASTA: 100%|██████████| 24/24 [00:35<00:00, 1.47s/it] Loading Peaks: 27000it [00:37, 726.09it/s]
# Load in Coordinates of Examples
coords = load_coords(val_peak_path, in_window)
# Import SHAP scores, predicted profiles
hyp_scores = np.load(scores_path).swapaxes(1,2)
hyp_scores = hyp_scores[:, (in_window // 2 - score_center_size // 2):(in_window // 2 + score_center_size // 2), :]
pred_profs = np.exp(np.load(val_save_path + ".profs.npy"))
# Load modisco results object
tfm_obj = import_tfmodisco_results(modisco_obj_path, hyp_scores, one_hot_seqs)
motif_pfms, motif_hcwms, motif_cwms, \
motif_pfms_short, num_seqlets, \
motif_seqlets, num_metaclusters = plot_all_metaclusters(tfm_obj, one_hot_seqs, hyp_scores,
true_profs, pred_profs, coords,
in_window, out_window,
score_center_size,
profile_display_center_size)
9372 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
8027 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
5603 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
5579 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
3722 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
1480 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
1090 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
1075 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
1054 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
1006 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
826 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
822 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
680 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
338 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
289 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
107 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
76 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
40 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
30 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
24 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
137 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
98 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
70 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
64 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
63 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
47 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
36 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
22 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
run_and_plot_tomtom(modisco_out_path, motif_pfms, motif_hcwms, motif_pfms_short, num_metaclusters, tomtom_dir)
Motif ID | q-val | PWM |
---|---|---|
MA0516.3 | 0.000151491 | |
MA0742.2 | 0.000153393 | |
MA0079.5 | 0.000161258 | |
MA0685.2 | 0.000161258 | |
MA1511.2 | 0.000161258 |
Motif ID | q-val | PWM |
---|---|---|
MA0076.2 | 5.70795e-05 | |
MA0764.3 | 0.000125721 | |
MA0759.2 | 0.000125721 | |
MA0916.1 | 0.000141856 | |
MA0765.3 | 0.000271855 |
Motif ID | q-val | PWM |
---|---|---|
MA0060.3 | 4.28622e-05 | |
MA0316.1 | 4.28622e-05 | |
MA1644.1 | 4.28622e-05 | |
MA0314.2 | 7.41335e-05 | |
MA0502.2 | 0.0275738 |
Motif ID | q-val | PWM |
---|---|---|
MA0506.2 | 1.03877e-05 | |
MA1826.1 | 0.287145 | |
MA0048.2 | 0.395958 | |
MA1106.1 | 0.395958 | |
MA1061.1 | 0.395958 |
Motif ID | q-val | PWM |
---|---|---|
MA1475.1 | 0.000192117 | |
MA0609.2 | 0.000278576 | |
MA1346.1 | 0.0013707 | |
MA1438.1 | 0.0013707 | |
MA1133.1 | 0.00139121 |
Motif ID | q-val | PWM |
---|---|---|
MA1573.2 | 1.66769e-08 | |
MA0088.2 | 0.0189088 | |
MA1716.1 | 0.0210958 | |
MA1625.1 | 0.345819 | |
MA0519.1 | 0.438711 |
Motif ID | q-val | PWM |
---|---|---|
MA0748.2 | 0.000237995 | |
MA0998.1 | 0.00127309 | |
MA1004.1 | 0.00352335 | |
MA0975.1 | 0.00365308 | |
MA1651.1 | 0.00365308 |
Motif ID | q-val | PWM |
---|---|---|
MA0139.1 | 1.0599e-06 | |
MA1929.1 | 1.7404e-05 | |
MA1102.2 | 2.27925e-05 | |
MA1930.1 | 3.91608e-05 | |
MA0531.1 | 6.25181e-05 |
Motif ID | q-val | PWM |
---|---|---|
MA1053.1 | 0.00239086 | |
MA1051.1 | 0.00269004 | |
MA0997.1 | 0.00492725 | |
MA0975.1 | 0.00492725 | |
MA0998.1 | 0.015186 |
Motif ID | q-val | PWM |
---|---|---|
MA0062.3 | 1.05054e-06 | |
MA0473.3 | 2.34168e-06 | |
MA0598.3 | 2.34168e-06 | |
MA0474.3 | 5.35136e-06 | |
MA1992.1 | 5.35136e-06 |
Motif ID | q-val | PWM |
---|---|---|
MA0527.1 | 1.7272e-06 |
Motif ID | q-val | PWM |
---|---|---|
MA0501.1 | 0.000865897 | |
MA0591.1 | 0.000865897 | |
MA0150.2 | 0.000865897 | |
MA0489.2 | 0.000865897 | |
MA1448.1 | 0.000865897 |
Motif ID | q-val | PWM |
---|---|---|
MA1053.1 | 0.000146374 | |
MA1051.1 | 0.00190959 | |
MA1102.2 | 0.00269784 | |
MA0975.1 | 0.00632135 | |
MA0531.1 | 0.0104988 |
Motif ID | q-val | PWM |
---|---|---|
MA0361.1 | 0.155987 | |
MA1961.1 | 0.155987 | |
MA0979.1 | 0.155987 | |
MA1713.1 | 0.155987 | |
MA1006.1 | 0.155987 |
Motif ID | q-val | PWM |
---|---|---|
MA1102.2 | 0.00264256 | |
MA1053.1 | 0.00396152 | |
MA1051.1 | 0.00498648 | |
MA0139.1 | 0.00514376 | |
MA0531.1 | 0.00767921 |
Motif ID | q-val | PWM |
---|---|---|
MA1004.1 | 0.0777813 | |
MA1460.1 | 0.0777813 | |
MA0748.2 | 0.0777813 | |
MA0544.1 | 0.0777813 | |
MA0998.1 | 0.103456 |
Motif ID | q-val | PWM |
---|---|---|
MA1819.1 | 0.154935 | |
MA1820.1 | 0.257593 | |
MA1880.1 | 0.257593 | |
MA1832.1 | 0.268619 | |
MA1821.1 | 0.268619 |
Motif ID | q-val | PWM |
---|---|---|
MA0527.1 | 0.126239 |
Motif ID | q-val | PWM |
---|---|---|
MA1053.1 | 0.203181 | |
MA0597.2 | 0.203181 | |
MA1051.1 | 0.203181 | |
MA0456.1 | 0.203181 | |
MA1730.1 | 0.224849 |
Motif ID | q-val | PWM |
---|---|---|
MA1050.1 | 0.0873503 | |
MA1066.1 | 0.0873503 | |
MA1097.1 | 0.192887 | |
MA1095.1 | 0.20955 | |
MA1098.1 | 0.20955 |
Motif ID | q-val | PWM |
---|---|---|
MA1267.1 | 0.0266873 | |
MA1380.1 | 0.0280915 | |
MA1268.1 | 0.0373389 | |
MA1863.1 | 0.0380333 | |
MA1871.1 | 0.0380333 |
Motif ID | q-val | PWM |
---|---|---|
MA1267.1 | 2.1566e-07 | |
MA1268.1 | 6.98031e-07 | |
MA1281.1 | 6.98031e-07 | |
MA1274.1 | 1.31759e-06 | |
MA1871.1 | 3.12224e-06 |
Motif ID | q-val | PWM |
---|---|---|
MA1826.1 | 0.030388 | |
MA1412.1 | 0.0340818 | |
MA1822.1 | 0.0586347 | |
MA0375.1 | 0.0586347 | |
MA1560.1 | 0.0586347 |
Motif ID | q-val | PWM |
---|---|---|
MA1125.1 | 0.0151513 | |
MA1380.1 | 0.0151513 | |
MA1205.1 | 0.0230788 | |
MA1823.1 | 0.0230788 | |
MA1379.1 | 0.0230788 |
Motif ID | q-val | PWM |
---|---|---|
MA0538.1 | 0.000641539 | |
MA1865.1 | 0.292076 | |
MA1107.2 | 0.373096 |
Motif ID | q-val | PWM |
---|---|---|
MA0538.1 | 0.000319051 | |
MA1890.1 | 0.0141953 | |
MA1627.1 | 0.020239 | |
MA0073.1 | 0.0606604 | |
MA1893.1 | 0.0724721 |
Motif ID | q-val | PWM |
---|---|---|
MA1281.1 | 2.41325e-07 | |
MA1274.1 | 2.17542e-06 | |
MA1268.1 | 3.74801e-06 | |
MA1278.1 | 5.31535e-06 | |
MA1277.1 | 1.83689e-05 |
Motif ID | q-val | PWM |
---|---|---|
MA1864.1 | 0.231954 | |
MA1862.1 | 0.308981 | |
MA1366.1 | 0.308981 | |
MA1917.1 | 0.308981 | |
MA1870.1 | 0.308981 |