# 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_profile.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
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: profile 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"
if not modisco_out_path.endswith("/"):
modisco_out_path = modisco_out_path + "/"
# task-specific filepaths
import os
assert scoring_type in ["profile", "counts"], scoring_type
if scoring_type == "profile":
scores_path = attr_save_path + "_prof.npy"
onehot_scores_path = attr_save_path + "_prof_onehot.npy"
modisco_obj_path = modisco_out_path + "results_allChroms_prof_slice" + str(score_center_size) + ".hdf5"
seqlet_path = modisco_out_path + "seqlets_prof.txt"
else:
scores_path = attr_save_path + "_count.npy"
onehot_scores_path = attr_save_path + "_count_onehot.npy"
modisco_obj_path = modisco_out_path + "results_allChroms_count_slice" + str(score_center_size) + ".hdf5"
seqlet_path = modisco_out_path + "seqlets_count.txt"
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:10<00:00, 2.26it/s] Loading Peaks: 27000it [00:23, 1131.39it/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)
12329 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
10782 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
4928 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
4167 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
3325 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
3303 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
2705 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
1616 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
1606 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
1493 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
1345 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
1032 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
915 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
834 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
755 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
604 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
604 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
435 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
429 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
391 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
344 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
325 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
284 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
165 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
128 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
124 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
122 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
91 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
85 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
74 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
67 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
63 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
63 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
57 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
44 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
44 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
32 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
29 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
27 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
25 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
24 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
22 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
62 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) |
23 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)
No TOMTOM matches passing threshold
Motif ID | q-val | PWM |
---|---|---|
MA0516.3 | 0.000114923 | |
MA0742.2 | 0.000130081 | |
MA0685.2 | 0.000167693 | |
MA0079.5 | 0.000170741 | |
MA1961.1 | 0.000170741 |
Motif ID | q-val | PWM |
---|---|---|
MA0314.2 | 6.49542e-06 | |
MA0060.3 | 6.49542e-06 | |
MA1644.1 | 1.60722e-05 | |
MA0502.2 | 0.011712 | |
MA0316.1 | 0.0127761 |
Motif ID | q-val | PWM |
---|---|---|
MA0076.2 | 9.77514e-07 | |
MA0750.2 | 9.77514e-07 | |
MA0764.3 | 3.94958e-05 | |
MA0156.3 | 5.92437e-05 | |
MA0763.1 | 0.000116853 |
Motif ID | q-val | PWM |
---|---|---|
MA1820.1 | 0.000977921 | |
MA1817.1 | 0.000977921 | |
MA1049.1 | 0.00110805 | |
MA1818.1 | 0.00128521 | |
MA1832.1 | 0.00128521 |
Motif ID | q-val | PWM |
---|---|---|
MA0506.2 | 6.87591e-07 | |
MA1826.1 | 0.139178 | |
MA0103.3 | 0.169361 | |
MA1834.1 | 0.169361 | |
MA0522.3 | 0.169361 |
Motif ID | q-val | PWM |
---|---|---|
MA0609.2 | 0.000109852 | |
MA1145.1 | 0.000155738 | |
MA1475.1 | 0.00629298 | |
MA1899.1 | 0.00629298 | |
MA0967.1 | 0.0092637 |
No TOMTOM matches passing threshold
No TOMTOM matches passing threshold
Motif ID | q-val | PWM |
---|---|---|
MA1257.1 | 2.25591e-09 | |
MA1262.1 | 4.36941e-09 | |
MA1833.1 | 4.36941e-09 | |
MA1239.1 | 8.66923e-09 | |
MA2022.1 | 8.79324e-09 |
Motif ID | q-val | PWM |
---|---|---|
MA0489.2 | 0.000518996 | |
MA0591.1 | 0.000518996 | |
MA0501.1 | 0.000518996 | |
MA0150.2 | 0.000518996 | |
MA1141.1 | 0.000518996 |
Motif ID | q-val | PWM |
---|---|---|
MA1573.2 | 2.85065e-09 | |
MA0088.2 | 0.0243914 | |
MA1716.1 | 0.0302586 | |
MA1625.1 | 0.266622 | |
MA0519.1 | 0.47702 |
Motif ID | q-val | PWM |
---|---|---|
MA0748.2 | 4.02353e-05 | |
MA0975.1 | 4.9859e-05 | |
MA0998.1 | 0.000349785 | |
MA0997.1 | 0.00119263 | |
MA1244.1 | 0.00215836 |
Motif ID | q-val | PWM |
---|---|---|
MA0139.1 | 1.73652e-07 | |
MA1929.1 | 2.1535e-07 | |
MA1930.1 | 2.67266e-06 | |
MA1102.2 | 7.30355e-06 | |
MA0531.1 | 8.67421e-05 |
Motif ID | q-val | PWM |
---|---|---|
MA1820.1 | 0.00016575 | |
MA1819.1 | 0.000548911 | |
MA1817.1 | 0.00155117 | |
MA1833.1 | 0.00228667 | |
MA1821.1 | 0.00228667 |
Motif ID | q-val | PWM |
---|---|---|
MA0080.6 | 0.217397 | |
MA1268.1 | 0.217397 | |
MA0452.2 | 0.217397 | |
MA1279.1 | 0.217397 | |
MA1823.1 | 0.217397 |
No TOMTOM matches passing threshold
Motif ID | q-val | PWM |
---|---|---|
MA0527.1 | 6.92661e-06 |
Motif ID | q-val | PWM |
---|---|---|
MA1833.1 | 0.000103603 | |
MA1817.1 | 0.000103603 | |
MA0535.1 | 0.000134933 | |
MA2022.1 | 0.000138324 | |
MA1818.1 | 0.000138324 |
Motif ID | q-val | PWM |
---|---|---|
MA2022.1 | 0.00446026 | |
MA1817.1 | 0.00557395 | |
MA1820.1 | 0.00557395 | |
MA1228.1 | 0.00557395 | |
MA1264.1 | 0.0146121 |
Motif ID | q-val | PWM |
---|---|---|
MA0599.1 | 0.000424675 | |
MA0039.4 | 0.000424675 | |
MA1513.1 | 0.000457268 | |
MA1107.2 | 0.00125194 | |
MA0493.2 | 0.00125194 |
Motif ID | q-val | PWM |
---|---|---|
MA1833.1 | 5.44003e-07 | |
MA1257.1 | 2.36847e-06 | |
MA1820.1 | 2.36847e-06 | |
MA2022.1 | 2.83176e-06 | |
MA1817.1 | 8.1102e-06 |
Motif ID | q-val | PWM |
---|---|---|
MA1596.1 | 0.0270208 | |
MA0587.1 | 0.210511 | |
MA1513.1 | 0.232968 | |
MA1961.1 | 0.232968 | |
MA1712.1 | 0.410875 |
Motif ID | q-val | PWM |
---|---|---|
MA1817.1 | 0.00652875 | |
MA1833.1 | 0.00652875 | |
MA1713.1 | 0.00652875 | |
MA1832.1 | 0.00652875 | |
MA1821.1 | 0.00652875 |
Motif ID | q-val | PWM |
---|---|---|
MA1880.1 | 8.92839e-05 | |
MA0506.2 | 0.000457509 | |
MA1833.1 | 0.00135399 | |
MA1650.1 | 0.00586157 | |
MA0375.1 | 0.00756002 |
Motif ID | q-val | PWM |
---|---|---|
MA1596.1 | 0.00207162 | |
MA1817.1 | 0.00886397 | |
MA1820.1 | 0.00886397 | |
MA0131.2 | 0.0289714 | |
MA2013.1 | 0.0332991 |
No TOMTOM matches passing threshold
Motif ID | q-val | PWM |
---|---|---|
MA0527.1 | 0.010958 |
Motif ID | q-val | PWM |
---|---|---|
MA1833.1 | 5.40527e-07 | |
MA1820.1 | 5.40527e-07 | |
MA1817.1 | 5.40527e-07 | |
MA1819.1 | 6.19317e-07 | |
MA1228.1 | 8.20316e-06 |
No TOMTOM matches passing threshold
Motif ID | q-val | PWM |
---|---|---|
MA0609.2 | 0.229455 |
Motif ID | q-val | PWM |
---|---|---|
MA1730.1 | 0.2509 |
Motif ID | q-val | PWM |
---|---|---|
MA0506.2 | 0.00169329 | |
MA1880.1 | 0.00217315 | |
MA1892.1 | 0.0125828 | |
MA1826.1 | 0.0125828 | |
MA1893.1 | 0.0125828 |
Motif ID | q-val | PWM |
---|---|---|
MA0299.1 | 0.434865 |
No TOMTOM matches passing threshold
Motif ID | q-val | PWM |
---|---|---|
MA1820.1 | 0.00178998 | |
MA1819.1 | 0.00178998 | |
MA1833.1 | 0.00178998 | |
MA1880.1 | 0.00178998 | |
MA1713.1 | 0.00178998 |
No TOMTOM matches passing threshold
Motif ID | q-val | PWM |
---|---|---|
MA1066.1 | 0.204762 | |
MA1050.1 | 0.204762 | |
MA1097.1 | 0.300788 | |
MA1095.1 | 0.300788 | |
MA1098.1 | 0.300788 |
Motif ID | q-val | PWM |
---|---|---|
MA0609.2 | 0.384514 | |
MA0595.1 | 0.392174 | |
MA0354.1 | 0.392174 | |
MA0450.1 | 0.392174 | |
MA1145.1 | 0.435865 |
No TOMTOM matches passing threshold
Motif ID | q-val | PWM |
---|---|---|
MA1464.1 | 0.125312 | |
MA0526.4 | 0.125312 | |
MA0831.3 | 0.129495 | |
MA1816.1 | 0.129495 | |
MA0399.1 | 0.129495 |
No TOMTOM matches passing threshold
Motif ID | q-val | PWM |
---|---|---|
MA1513.1 | 1.44586e-05 | |
MA1893.1 | 2.81395e-05 | |
MA1890.1 | 7.91672e-05 | |
MA0685.2 | 8.88832e-05 | |
MA0742.2 | 8.88832e-05 |
Motif ID | q-val | PWM |
---|---|---|
MA0506.2 | 0.00154604 | |
MA1880.1 | 0.015799 | |
MA1650.1 | 0.0214383 | |
MA0522.3 | 0.0502543 | |
MA1412.1 | 0.0524631 |
Motif ID | q-val | PWM |
---|---|---|
MA0060.3 | 8.62694e-05 | |
MA1644.1 | 8.62694e-05 | |
MA0314.2 | 0.00297962 | |
MA0316.1 | 0.00488603 | |
MA0502.2 | 0.0472531 |
Motif ID | q-val | PWM |
---|---|---|
MA0156.3 | 0.00013354 | |
MA0763.1 | 0.000283267 | |
MA0759.2 | 0.000283267 | |
MA0598.3 | 0.000283267 | |
MA0028.2 | 0.000300729 |