# Filepaths and Hard-coded Defaults
proj_root = "/users/kcochran/projects/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-03_11-35-25_run1_modisco_config.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"])
# digest what's in config file
assay_type, model_type, cell, accession, modisco_dir_base = modisco_out_path.split("/")[-5:]
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)
/users/kcochran//projects/procap_models/modisco_out/procap/bpnetlite_basic_v2/CACO2/ENCSR100LIJ/2022-07-03_11-35-25_run1_modisco cell_type: CACO2 ENCSR100LIJ timestamp: 2022-07-03_11-35-25 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_and_val.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_and_val"
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_slice500.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_slice500.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 *
/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:16<00:00, 1.47it/s] Loading Peaks: 42149it [01:04, 654.64it/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)
12005 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
8340 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
7834 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
7565 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
5575 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
3564 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
2865 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
1971 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
1931 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
1630 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
1355 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
1332 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
1190 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
1171 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
1113 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
615 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
602 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
584 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
473 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
349 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
344 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
270 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
138 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
87 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
45 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
32 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
30 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
23 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
22 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
20 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)
The output directory '/users/kcochran//projects/procap_models/modisco_out/procap/bpnetlite_basic_v2/CACO2/ENCSR100LIJ/2022-07-03_11-35-25_run1_modisco/tomtom' already exists. Its contents will be overwritten. Processing query 1 out of 30 Estimating pi_0 from all 3912 observed p-values. Estimating pi_0. Estimated pi_0=0.972408 Processing query 2 out of 30 Estimating pi_0 from all 3912 observed p-values. Estimating pi_0. Estimated pi_0=1 Processing query 3 out of 30 Estimating pi_0 from all 3912 observed p-values. Estimating pi_0. Estimated pi_0=0.945544 Processing query 4 out of 30 Estimating pi_0 from all 3912 observed p-values. Estimating pi_0. Estimated pi_0=0.985757 Processing query 5 out of 30 Estimating pi_0 from all 3912 observed p-values. Estimating pi_0. Estimated pi_0=0.984217 Processing query 6 out of 30 Estimating pi_0 from all 3912 observed p-values. Estimating pi_0. Estimated pi_0=1 Processing query 7 out of 30 Estimating pi_0 from all 3912 observed p-values. Estimating pi_0. Estimated pi_0=0.985757 Processing query 8 out of 30 Estimating pi_0 from all 3912 observed p-values. Estimating pi_0. Estimated pi_0=0.995263 Processing query 9 out of 30 Estimating pi_0 from all 3912 observed p-values. Estimating pi_0. Estimated pi_0=0.984986 Processing query 10 out of 30 Estimating pi_0 from all 3912 observed p-values. Estimating pi_0. Estimated pi_0=0.970575 Processing query 11 out of 30 Estimating pi_0 from all 3912 observed p-values. Estimating pi_0. Estimated pi_0=0.979582 Processing query 12 out of 30 Estimating pi_0 from all 3912 observed p-values. Estimating pi_0. Estimated pi_0=0.961768 Processing query 13 out of 30 Estimating pi_0 from all 3912 observed p-values. Estimating pi_0. Estimated pi_0=1 Processing query 14 out of 30 Estimating pi_0 from all 3912 observed p-values. Estimating pi_0. Estimated pi_0=1 Processing query 15 out of 30 Estimating pi_0 from all 3912 observed p-values. Estimating pi_0. Estimated pi_0=0.973718 Processing query 16 out of 30 Estimating pi_0 from all 3912 observed p-values. Estimating pi_0. Estimated pi_0=0.987555 Processing query 17 out of 30 Estimating pi_0 from all 3912 observed p-values. Estimating pi_0. Estimated pi_0=0.980105 Processing query 18 out of 30 Estimating pi_0 from all 3912 observed p-values. Estimating pi_0. Estimated pi_0=0.990895 Processing query 19 out of 30 Estimating pi_0 from all 3912 observed p-values. Estimating pi_0. Estimated pi_0=0.99265 Processing query 20 out of 30 Estimating pi_0 from all 3912 observed p-values. Estimating pi_0. Estimated pi_0=1 Processing query 21 out of 30 Estimating pi_0 from all 3912 observed p-values. Estimating pi_0. Estimated pi_0=1 Processing query 22 out of 30 Estimating pi_0 from all 3912 observed p-values. Estimating pi_0. Estimated pi_0=0.983959 Processing query 23 out of 30 Estimating pi_0 from all 3912 observed p-values. Estimating pi_0. Estimated pi_0=0.997575 Processing query 24 out of 30 Estimating pi_0 from all 3912 observed p-values. Estimating pi_0. Estimated pi_0=0.966439 Processing query 25 out of 30 Estimating pi_0 from all 3912 observed p-values. Estimating pi_0. Estimated pi_0=1 Processing query 26 out of 30 Estimating pi_0 from all 3912 observed p-values. Estimating pi_0. Estimated pi_0=1 Processing query 27 out of 30 Estimating pi_0 from all 3912 observed p-values. Estimating pi_0. Estimated pi_0=0.980149 Processing query 28 out of 30 Estimating pi_0 from all 3912 observed p-values. Estimating pi_0. Estimated pi_0=0.971892 Processing query 29 out of 30 Estimating pi_0 from all 3912 observed p-values. Estimating pi_0. Estimated pi_0=0.990315 Processing query 30 out of 30 Estimating pi_0 from all 3912 observed p-values. Estimating pi_0. Estimated pi_0=0.99629 Can't locate HtmlMonolithWr.pm: /root/lib/perl/HtmlMonolithWr.pm: Permission denied at /software/meme/4.11.2/bin/tomtom_xml_to_html line 48. Warning: tomtom_xml_to_html exited abnormally and may have failed to create HTML output.
Motif ID | q-val | PWM |
---|---|---|
MA0516.3-SP2 | 9.93986e-05 | |
MA0742.2-KLF12 | 9.93986e-05 | |
MA0685.2-SP4 | 0.000121574 | |
MA1511.2-KLF10 | 0.000151052 | |
MA0079.5-SP1 | 0.00016145 |
Motif ID | q-val | PWM |
---|---|---|
MA0060.3-NFYA | 1.35364e-05 | |
MA1644.1-NFYC | 1.35364e-05 | |
MA0314.2-HAP3 | 6.65651e-05 | |
MA0316.1-HAP5 | 0.00362119 | |
MA0502.2-NFYB | 0.00981159 |
Motif ID | q-val | PWM |
---|---|---|
MA1474.1-CREB3L4 | 0.00368771 | |
MA1672.1-GBF2 | 0.0138326 | |
MA0692.1-TFEB | 0.0138326 | |
MA0871.2-TFEC | 0.0138326 | |
MA1466.1-ATF6 | 0.0138326 |
Motif ID | q-val | PWM |
---|---|---|
MA0076.2-ELK4 | 6.6659e-06 | |
MA0764.3-ETV4 | 3.5158e-05 | |
MA0759.2-ELK3 | 3.5158e-05 | |
MA0916.1-Ets21C | 3.5158e-05 | |
MA0750.2-ZBTB7A | 3.5158e-05 |
Motif ID | q-val | PWM |
---|---|---|
MA0506.2-Nrf1 | 5.32753e-06 | |
MA1826.1-bHLH145 | 0.263084 | |
MA0103.3-ZEB1 | 0.341382 | |
MA1106.1-HIF1A | 0.386558 | |
MA1061.1-SPT | 0.386558 |
Motif ID | q-val | PWM |
---|---|---|
MA0808.1-TEAD3 | 0.00439319 | |
MA1121.1-TEAD2 | 0.0131795 | |
MA0809.2-TEAD4 | 0.0579623 | |
MA0090.3-TEAD1 | 0.0579623 | |
MA0243.1-sd | 0.0663711 |
Motif ID | q-val | PWM |
---|---|---|
MA0748.2-YY2 | 7.28328e-05 | |
MA0998.1-ERF096 | 0.000822085 | |
MA1004.1-ERF13 | 0.00248407 | |
MA0975.1-CRF2 | 0.00248407 | |
MA1651.1-ZFP42 | 0.00248407 |
Motif ID | q-val | PWM |
---|---|---|
MA0677.1-Nr2f6 | 0.000308755 | |
MA0856.1-RXRG | 0.000308755 | |
MA0512.2-Rxra | 0.000308755 | |
MA1574.1-THRB | 0.000308755 | |
MA1550.1-PPARD | 0.000308755 |
Motif ID | q-val | PWM |
---|---|---|
MA1448.1-fos-1 | 0.00256055 | |
MA0489.2-Jun | 0.00256055 | |
MA1988.1-Atf3 | 0.00256055 | |
MA1928.1-BNC2 | 0.00256055 | |
MA0099.3-FOS::JUN | 0.00256055 |
Motif ID | q-val | PWM |
---|---|---|
MA0139.1-CTCF | 2.41762e-09 | |
MA1929.1-CTCF | 8.43097e-07 | |
MA1930.1-CTCF | 3.84831e-06 | |
MA1102.2-CTCFL | 4.04804e-06 | |
MA0531.1-CTCF | 2.40312e-05 |
Motif ID | q-val | PWM |
---|---|---|
MA0153.2-HNF1B | 9.21234e-08 | |
MA0046.2-HNF1A | 8.02455e-07 | |
MA1212.1-ATHB-13 | 0.169343 | |
MA1198.1-HAT2 | 0.169343 | |
MA0951.1-ATHB-16 | 0.191625 |
Motif ID | q-val | PWM |
---|---|---|
MA0535.1-Mad | 0.00298608 | |
MA1818.1-Zm00001d052229 | 0.00298608 | |
MA1832.1-Zm00001d002364 | 0.00298608 | |
MA1821.1-Zm00001d020595 | 0.00298608 | |
MA1819.1-Zm00001d005892 | 0.00298608 |
Motif ID | q-val | PWM |
---|---|---|
MA0527.1-ZBTB33 | 2.08256e-12 |
Motif ID | q-val | PWM |
---|---|---|
MA1573.2-Thap11 | 1.08358e-08 | |
MA0088.2-ZNF143 | 0.036864 | |
MA1716.1-ZNF76 | 0.0487746 | |
MA0525.2-TP63 | 0.410317 | |
MA1625.1-Stat5b | 0.410317 |
Motif ID | q-val | PWM |
---|---|---|
MA0374.1-RSC3 | 0.155357 | |
MA0375.1-RSC30 | 0.155357 | |
MA1099.2-HES1 | 0.155357 | |
MA1513.1-KLF15 | 0.163495 | |
MA1650.1-ZBTB14 | 0.163495 |
Motif ID | q-val | PWM |
---|---|---|
MA0833.2-ATF4 | 0.00027217 | |
MA1636.1-CEBPG | 0.000870914 | |
MA0488.1-JUN | 0.0263704 | |
MA0025.2-NFIL3 | 0.0263704 | |
MA1702.1-Pdp1 | 0.0311271 |
Motif ID | q-val | PWM |
---|---|---|
MA0018.4-CREB1 | 0.00083782 | |
MA1475.1-CREB3L4 | 0.00439627 | |
MA0492.1-JUND | 0.00489131 | |
MA1131.1-FOSL2::JUN | 0.00489131 | |
MA0605.2-ATF3 | 0.00489131 |
Motif ID | q-val | PWM |
---|---|---|
MA0446.1-fkh | 0.000795262 | |
MA0546.1-pha-4 | 0.000795262 | |
MA0846.1-FOXC2 | 0.000795262 | |
MA1683.1-FOXA3 | 0.000795262 | |
MA0032.2-FOXC1 | 0.00143797 |
Motif ID | q-val | PWM |
---|---|---|
MA1861.1-FoxB | 1.95854e-05 | |
MA1860.1-FoxA-b | 2.01108e-05 | |
MA0845.1-FOXB1 | 0.0375173 | |
MA0032.2-FOXC1 | 0.0416862 | |
MA0148.4-FOXA1 | 0.116902 |
Motif ID | q-val | PWM |
---|---|---|
MA1573.2-Thap11 | 2.28677e-06 | |
MA0088.2-ZNF143 | 0.00421798 | |
MA1716.1-ZNF76 | 0.00455823 | |
MA1625.1-Stat5b | 0.0714219 | |
MA0519.1-Stat5a::Stat5b | 0.0799368 |
No TOMTOM matches passing threshold
Motif ID | q-val | PWM |
---|---|---|
MA0108.2-TBP | 0.000320225 | |
MA1818.1-Zm00001d052229 | 0.00116415 | |
MA0375.1-RSC30 | 0.00685389 | |
MA0123.1-abi4 | 0.0147538 | |
MA1832.1-Zm00001d002364 | 0.0274804 |
Motif ID | q-val | PWM |
---|---|---|
MA0647.1-GRHL1 | 0.00836536 | |
MA1968.1-TFCP2 | 0.0848132 | |
MA0765.3-ETV5 | 0.106193 | |
MA0760.1-ERF | 0.106193 | |
MA0028.2-ELK1 | 0.106193 |
Motif ID | q-val | PWM |
---|---|---|
MA0108.2-TBP | 0.00330394 | |
MA1817.1-Zm00001d020267 | 0.00330394 | |
MA1819.1-Zm00001d005892 | 0.00330394 | |
MA1961.1-PATZ1 | 0.00330394 | |
MA1513.1-KLF15 | 0.00424555 |
Motif ID | q-val | PWM |
---|---|---|
MA0326.1-MAC1 | 0.17111 |
Motif ID | q-val | PWM |
---|---|---|
MA1716.1-ZNF76 | 0.000297526 | |
MA0088.2-ZNF143 | 0.00147016 | |
MA0731.1-BCL6B | 0.431764 | |
MA0463.2-BCL6 | 0.468369 |
Motif ID | q-val | PWM |
---|---|---|
MA1899.1-Mitf | 0.00457826 | |
MA0829.2-SREBF1 | 0.00457826 | |
MA0664.1-MLXIPL | 0.00665676 | |
MA0663.1-MLX | 0.00665676 | |
MA0409.1-TYE7 | 0.00729904 |
Motif ID | q-val | PWM |
---|---|---|
MA0840.1-Creb5 | 0.0417631 | |
MA1695.1-ARF36 | 0.0417631 | |
MA1348.1-TGA9 | 0.0417631 | |
MA1145.1-FOSL2::JUND | 0.0417631 | |
MA0605.2-ATF3 | 0.0417631 |
Motif ID | q-val | PWM |
---|---|---|
MA1880.1-Hey | 0.201306 | |
MA0399.1-SUT1 | 0.269686 | |
MA1695.1-ARF36 | 0.383016 | |
MA1686.1-ARF13 | 0.383016 | |
MA0538.1-daf-12 | 0.46114 |
Motif ID | q-val | PWM |
---|---|---|
MA0155.1-INSM1 | 0.00435869 | |
MA1102.2-CTCFL | 0.0876067 | |
MA1548.1-PLAGL2 | 0.117608 | |
MA1433.1-msn-1 | 0.127532 | |
MA0342.1-MSN4 | 0.191525 |