# 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_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_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: 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:11<00:00, 2.13it/s] Loading Peaks: 3834it [00:03, 1069.35it/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)
1616 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
1080 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
639 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
604 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
603 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
423 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
351 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
329 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
312 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
311 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
268 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
187 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
168 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
150 seqlets
Sequence (PFM) | |
Hypothetical contributions (hCWM) | |
Actual contributions (CWM) |
21 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 |
---|---|---|
MA1817.1 | 1.52282e-10 | |
MA1819.1 | 1.13312e-08 | |
MA1820.1 | 1.62356e-08 | |
MA1821.1 | 2.01962e-08 | |
MA1832.1 | 2.01962e-08 |
Motif ID | q-val | PWM |
---|---|---|
MA1880.1 | 9.95661e-05 | |
MA1893.1 | 0.000677274 | |
MA1892.1 | 0.000677274 | |
MA1833.1 | 0.000677274 | |
MA1961.1 | 0.00103191 |
Motif ID | q-val | PWM |
---|---|---|
MA1268.1 | 3.55829e-06 | |
MA1274.1 | 1.75916e-05 | |
MA1281.1 | 0.000117811 | |
MA1871.1 | 0.000127459 | |
MA1267.1 | 0.000427532 |
Motif ID | q-val | PWM |
---|---|---|
MA1273.1 | 0.266297 | |
MA0452.2 | 0.348179 | |
MA1199.1 | 0.348179 | |
MA0657.1 | 0.348179 | |
MA0563.1 | 0.348179 |
Motif ID | q-val | PWM |
---|---|---|
MA1597.1 | 0.14075 | |
MA1524.2 | 0.322823 | |
MA0095.3 | 0.322823 | |
MA1978.1 | 0.338359 |
Motif ID | q-val | PWM |
---|---|---|
MA0975.1 | 0.125752 | |
MA0399.1 | 0.148583 | |
MA1122.1 | 0.148583 | |
MA1053.1 | 0.148583 | |
MA1034.1 | 0.148583 |
Motif ID | q-val | PWM |
---|---|---|
MA1890.1 | 5.83207e-07 | |
MA1893.1 | 2.19249e-05 | |
MA1892.1 | 2.26221e-05 | |
MA1961.1 | 0.000246162 | |
MA1513.1 | 0.000557243 |
Motif ID | q-val | PWM |
---|---|---|
MA1880.1 | 5.75047e-05 | |
MA0375.1 | 0.000406048 | |
MA1650.1 | 0.00107583 | |
MA1961.1 | 0.00450453 | |
MA1513.1 | 0.00578495 |
No TOMTOM matches passing threshold
Motif ID | q-val | PWM |
---|---|---|
MA1122.1 | 0.00778979 | |
MA0762.1 | 0.0495376 | |
MA0344.1 | 0.151752 | |
MA1420.1 | 0.179276 | |
MA1419.1 | 0.182187 |
Motif ID | q-val | PWM |
---|---|---|
MA1817.1 | 7.20246e-05 | |
MA1819.1 | 0.000931723 | |
MA1961.1 | 0.000931723 | |
MA1513.1 | 0.000931723 | |
MA1832.1 | 0.0013864 |
No TOMTOM matches passing threshold
No TOMTOM matches passing threshold
Motif ID | q-val | PWM |
---|---|---|
MA1833.1 | 1.28114e-07 | |
MA1819.1 | 1.47878e-07 | |
MA1821.1 | 1.47878e-07 | |
MA1817.1 | 3.84509e-07 | |
MA1832.1 | 3.84533e-07 |
Motif ID | q-val | PWM |
---|---|---|
MA1820.1 | 7.80895e-05 | |
MA1833.1 | 7.80895e-05 | |
MA1228.1 | 9.04072e-05 | |
MA1817.1 | 9.04072e-05 | |
MA1819.1 | 0.000155504 |