# 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-26_15-18-44_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
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_umap/K562/ENCSR261KBX/2022-07-26_15-18-44_run1_modisco/ cell_type: K562 ENCSR261KBX timestamp: 2022-07-26_15-18-44 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"
# 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:14<00:00, 1.65it/s] Loading Peaks: 27000it [00:30, 896.94it/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)
13142 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
11079 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
6013 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
4916 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
3543 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
2625 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
2197 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
1321 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
1277 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
1177 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
1114 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
912 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
798 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
775 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
731 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
712 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
469 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
456 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
383 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
369 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
346 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
292 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
213 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
185 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
125 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
123 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
98 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
81 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
80 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
71 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
62 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
34 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
31 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
22 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
22 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
57 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
45 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
26 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
24 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)
No TOMTOM matches passing threshold
Motif ID | q-val | PWM |
---|---|---|
MA0742.2 | 0.00021035 | |
MA0516.3 | 0.00021035 | |
MA0685.2 | 0.00021035 | |
MA1961.1 | 0.00021035 | |
MA0741.1 | 0.00021035 |
Motif ID | q-val | PWM |
---|---|---|
MA0314.2 | 2.48986e-05 | |
MA0060.3 | 2.89337e-05 | |
MA1644.1 | 2.89337e-05 | |
MA0502.2 | 0.00938454 | |
MA0316.1 | 0.0143206 |
Motif ID | q-val | PWM |
---|---|---|
MA0076.2 | 1.8465e-06 | |
MA0750.2 | 1.77665e-05 | |
MA0759.2 | 9.46198e-05 | |
MA0156.3 | 9.46198e-05 | |
MA0764.3 | 9.89699e-05 |
Motif ID | q-val | PWM |
---|---|---|
MA0506.2 | 3.63899e-06 | |
MA1826.1 | 0.10563 | |
MA1834.1 | 0.18026 | |
MA1412.1 | 0.18026 | |
MA0103.3 | 0.216734 |
Motif ID | q-val | PWM |
---|---|---|
MA1899.1 | 0.0120988 | |
MA0967.1 | 0.0231571 | |
MA1145.1 | 0.0261796 | |
MA1933.1 | 0.0316458 | |
MA1140.2 | 0.0316458 |
No TOMTOM matches passing threshold
No TOMTOM matches passing threshold
Motif ID | q-val | PWM |
---|---|---|
MA0478.1 | 0.000530903 | |
MA1448.1 | 0.00167406 | |
MA1988.1 | 0.00167406 | |
MA0489.2 | 0.00265684 | |
MA0591.1 | 0.00265684 |
Motif ID | q-val | PWM |
---|---|---|
MA1573.2 | 1.57455e-08 | |
MA0088.2 | 0.0371589 | |
MA1716.1 | 0.0443068 | |
MA1625.1 | 0.416128 | |
MA0525.2 | 0.484907 |
Motif ID | q-val | PWM |
---|---|---|
MA1820.1 | 7.64263e-08 | |
MA1819.1 | 7.64263e-08 | |
MA1817.1 | 8.54992e-08 | |
MA1228.1 | 1.08862e-07 | |
MA1833.1 | 1.83796e-07 |
Motif ID | q-val | PWM |
---|---|---|
MA0748.2 | 0.000173731 | |
MA1818.1 | 0.000529731 | |
MA0998.1 | 0.000529731 | |
MA0975.1 | 0.000591737 | |
MA1244.1 | 0.00127819 |
Motif ID | q-val | PWM |
---|---|---|
MA1833.1 | 0.0158297 | |
MA1820.1 | 0.0158297 | |
MA1713.1 | 0.0158297 | |
MA1817.1 | 0.0158297 | |
MA1819.1 | 0.0158297 |
No TOMTOM matches passing threshold
Motif ID | q-val | PWM |
---|---|---|
MA1257.1 | 1.5136e-06 | |
MA1228.1 | 3.55625e-06 | |
MA1262.1 | 1.01025e-05 | |
MA1240.1 | 1.76848e-05 | |
MA1820.1 | 2.27939e-05 |
Motif ID | q-val | PWM |
---|---|---|
MA0139.1 | 1.38779e-06 | |
MA1929.1 | 9.05582e-06 | |
MA1102.2 | 6.83092e-05 | |
MA1930.1 | 7.63621e-05 | |
MA0531.1 | 7.72704e-05 |
Motif ID | q-val | PWM |
---|---|---|
MA0527.1 | 6.02947e-06 |
Motif ID | q-val | PWM |
---|---|---|
MA1273.1 | 0.0627575 | |
MA1268.1 | 0.0627575 | |
MA1278.1 | 0.0627575 | |
MA1279.1 | 0.0942126 | |
MA0442.2 | 0.0942126 |
Motif ID | q-val | PWM |
---|---|---|
MA1927.1 | 0.137998 | |
MA0998.1 | 0.137998 | |
MA1001.3 | 0.137998 | |
MA0976.2 | 0.137998 | |
MA1819.1 | 0.137998 |
Motif ID | q-val | PWM |
---|---|---|
MA0506.2 | 0.000202055 | |
MA1833.1 | 0.00921625 | |
MA1819.1 | 0.00921971 | |
MA1880.1 | 0.00921971 | |
MA1650.1 | 0.00921971 |
Motif ID | q-val | PWM |
---|---|---|
MA1819.1 | 0.000898193 | |
MA0975.1 | 0.000904884 | |
MA1820.1 | 0.00132517 | |
MA1832.1 | 0.00132517 | |
MA1821.1 | 0.00132517 |
Motif ID | q-val | PWM |
---|---|---|
MA1832.1 | 7.67509e-06 | |
MA1821.1 | 7.67509e-06 | |
MA1833.1 | 1.04831e-05 | |
MA1819.1 | 1.24131e-05 | |
MA1817.1 | 1.72835e-05 |
Motif ID | q-val | PWM |
---|---|---|
MA1716.1 | 0.00103195 | |
MA0088.2 | 0.00103195 | |
MA1573.2 | 0.0104497 |
Motif ID | q-val | PWM |
---|---|---|
MA1596.1 | 0.0262465 | |
MA0587.1 | 0.260434 | |
MA1513.1 | 0.423274 | |
MA1961.1 | 0.423274 | |
MA1712.1 | 0.423274 |
Motif ID | q-val | PWM |
---|---|---|
MA0506.2 | 0.0056098 | |
MA1961.1 | 0.014001 | |
MA1817.1 | 0.0148954 | |
MA1650.1 | 0.0198773 | |
MA1820.1 | 0.0198773 |
No TOMTOM matches passing threshold
Motif ID | q-val | PWM |
---|---|---|
MA0748.2 | 0.287129 | |
MA0998.1 | 0.375951 | |
MA0975.1 | 0.481599 | |
MA0997.1 | 0.481599 | |
MA1748.1 | 0.481599 |
No TOMTOM matches passing threshold
Motif ID | q-val | PWM |
---|---|---|
MA1548.1 | 0.325533 | |
MA1986.1 | 0.325533 | |
MA1428.1 | 0.325533 | |
MA1410.1 | 0.325533 | |
MA1019.1 | 0.325533 |
Motif ID | q-val | PWM |
---|---|---|
MA1980.1 | 0.0719932 | |
MA1615.1 | 0.0719932 | |
MA1095.1 | 0.0719932 | |
MA1098.1 | 0.0719932 | |
MA0599.1 | 0.0719932 |
Motif ID | q-val | PWM |
---|---|---|
MA1596.1 | 6.95891e-06 | |
MA1587.1 | 0.472156 | |
MA1262.1 | 0.472156 | |
MA1820.1 | 0.472156 | |
MA0380.1 | 0.472156 |
No TOMTOM matches passing threshold
No TOMTOM matches passing threshold
Motif ID | q-val | PWM |
---|---|---|
MA0528.2 | 0.0629652 | |
MA1522.1 | 0.175019 | |
MA2029.1 | 0.175019 | |
MA1961.1 | 0.175019 | |
MA1965.1 | 0.175019 |
No TOMTOM matches passing threshold
Motif ID | q-val | PWM |
---|---|---|
MA1890.1 | 0.000582974 | |
MA0742.2 | 0.000582974 | |
MA0685.2 | 0.000582974 | |
MA0516.3 | 0.000582974 | |
MA0740.2 | 0.000582974 |
Motif ID | q-val | PWM |
---|---|---|
MA0060.3 | 0.00316378 | |
MA1644.1 | 0.00413198 | |
MA0316.1 | 0.00462462 | |
MA0314.2 | 0.00491072 | |
MA0502.2 | 0.0573061 |
Motif ID | q-val | PWM |
---|---|---|
MA0076.2 | 9.61333e-06 | |
MA0750.2 | 0.000176732 | |
MA0759.2 | 0.000176732 | |
MA0156.3 | 0.000207048 | |
MA0598.3 | 0.00036351 |
Motif ID | q-val | PWM |
---|---|---|
MA1890.1 | 5.26228e-05 | |
MA1892.1 | 5.26228e-05 | |
MA1961.1 | 5.26228e-05 | |
MA1893.1 | 6.28185e-05 | |
MA0516.3 | 9.59547e-05 |