# 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_17-52-41_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_bias/bpnetlite_basic_v2/K562/ENCSR261KBX/2022-07-26_17-52-41_run1_modisco/ cell_type: K562 ENCSR261KBX timestamp: 2022-07-26_17-52-41 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:12<00:00, 1.86it/s] Loading Peaks: 3834it [00:04, 821.80it/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)
2961 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
2918 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
2206 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
1847 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
854 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
366 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
210 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
139 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
138 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
125 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
113 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
75 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
74 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
73 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
68 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
64 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
60 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
54 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
46 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
41 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 |
---|---|---|
MA1513.1 | 0.0170675 | |
MA1959.1 | 0.0245984 | |
MA0685.2 | 0.0245984 | |
MA1890.1 | 0.0245984 | |
MA1713.1 | 0.0245984 |
Motif ID | q-val | PWM |
---|---|---|
MA2022.1 | 1.03823e-08 | |
MA1833.1 | 2.79993e-08 | |
MA1239.1 | 2.79993e-08 | |
MA1228.1 | 6.6697e-08 | |
MA1257.1 | 6.71537e-08 |
Motif ID | q-val | PWM |
---|---|---|
MA1615.1 | 0.00918128 | |
MA1712.1 | 0.0298034 | |
MA0163.1 | 0.0298034 | |
MA1841.1 | 0.0298034 | |
MA1976.1 | 0.0298034 |
Motif ID | q-val | PWM |
---|---|---|
MA1821.1 | 5.66981e-06 | |
MA1832.1 | 8.78758e-06 | |
MA1818.1 | 1.33304e-05 | |
MA1833.1 | 3.22322e-05 | |
MA1817.1 | 3.22322e-05 |
Motif ID | q-val | PWM |
---|---|---|
MA0374.1 | 0.0280737 | |
MA1513.1 | 0.0280737 | |
MA1880.1 | 0.0280737 | |
MA1650.1 | 0.0362984 | |
MA1961.1 | 0.0362984 |
Motif ID | q-val | PWM |
---|---|---|
MA1976.1 | 0.00290309 | |
MA1430.1 | 0.0160478 | |
MA1410.1 | 0.0167802 | |
MA0163.1 | 0.0206275 | |
MA1841.1 | 0.0341084 |
Motif ID | q-val | PWM |
---|---|---|
MA2022.1 | 7.34368e-05 | |
MA1833.1 | 0.000415367 | |
MA1246.1 | 0.000415367 | |
MA1890.1 | 0.000440045 | |
MA1257.1 | 0.00112716 |
Motif ID | q-val | PWM |
---|---|---|
MA1035.1 | 0.195739 | |
MA1096.1 | 0.195739 | |
MA1067.1 | 0.195739 | |
MA1841.1 | 0.229984 | |
MA1054.1 | 0.288355 |
No TOMTOM matches passing threshold
Motif ID | q-val | PWM |
---|---|---|
MA1880.1 | 0.0185105 | |
MA1899.1 | 0.104708 | |
MA1878.1 | 0.104708 | |
MA1102.2 | 0.104708 | |
MA0146.2 | 0.104708 |
Motif ID | q-val | PWM |
---|---|---|
MA1880.1 | 0.00256607 | |
MA1650.1 | 0.0342193 | |
MA1892.1 | 0.0342193 | |
MA1051.1 | 0.0649158 | |
MA0147.3 | 0.0649158 |
Motif ID | q-val | PWM |
---|---|---|
MA1596.1 | 0.000228822 | |
MA1587.1 | 0.0148212 | |
MA1232.1 | 0.0299065 | |
MA2022.1 | 0.051092 | |
MA1239.1 | 0.051092 |
No TOMTOM matches passing threshold
Motif ID | q-val | PWM |
---|---|---|
MA1841.1 | 0.0597562 | |
MA1031.1 | 0.0598503 | |
MA1615.1 | 0.0682328 | |
MA1410.1 | 0.0682328 | |
MA1428.1 | 0.0682328 |
Motif ID | q-val | PWM |
---|---|---|
MA1880.1 | 0.0373465 | |
MA1713.1 | 0.0448176 | |
MA0374.1 | 0.0608831 | |
MA1961.1 | 0.075625 | |
MA0535.1 | 0.075625 |
Motif ID | q-val | PWM |
---|---|---|
MA1540.2 | 0.0347133 | |
MA1990.1 | 0.11541 |
Motif ID | q-val | PWM |
---|---|---|
MA0599.1 | 0.295108 | |
MA0516.3 | 0.295108 | |
MA0066.1 | 0.295108 | |
MA0742.2 | 0.295108 | |
MA1833.1 | 0.295108 |
No TOMTOM matches passing threshold
Motif ID | q-val | PWM |
---|---|---|
MA1587.1 | 0.00398675 | |
MA1596.1 | 0.00398675 | |
MA1581.1 | 0.0429213 | |
MA0358.1 | 0.375661 | |
MA0003.4 | 0.375661 |
Motif ID | q-val | PWM |
---|---|---|
MA1650.1 | 0.0274155 | |
MA1053.1 | 0.0274155 | |
MA0375.1 | 0.0274155 | |
MA1833.1 | 0.0274155 | |
MA1051.1 | 0.0274155 |