<jupyter_start><jupyter_text>load TOBIAS<jupyter_code>## dnase, tobias, K562
tobias_data_dnase_k562=pickle.load(open("/srv/scratch/annashch/bias_correction/enzymatic_bias/tobias/dnase/K562.filtered_AtacBias.pickle",'rb'))
tobias_dnase_pssm_forward=np.transpose(tobias_data_dnase_k562.bias['forward'].pssm[0:4])[:,[0,2,3,1]]
tobias_dnase_pssm_reverse=np.transpose(tobias_data_dnase_k562.bias['reverse'].pssm[0:4])[:,[0,2,3,1]]
tobias_dnase_pssm_summed=tobias_dnase_pssm_forward+tobias_dnase_pssm_reverse 

## atac, tobias, GM12878
tobias_data_atac_gm12878=pickle.load(open("/srv/scratch/annashch/bias_correction/enzymatic_bias/tobias/atac/GM12878.merged.filtered_AtacBias.pickle",'rb'))
tobias_atac_pssm_forward=np.transpose(tobias_data_atac_gm12878.bias['forward'].pssm[0:4])[:,[0,2,3,1]]
tobias_atac_pssm_reverse=np.transpose(tobias_data_atac_gm12878.bias['reverse'].pssm[0:4])[:,[0,2,3,1]]
tobias_atac_pssm_summed=tobias_atac_pssm_forward+tobias_atac_pssm_reverse<jupyter_output><empty_output><jupyter_text>load models<jupyter_code>from keras.models import load_model
from keras.utils.generic_utils import get_custom_objects
from kerasAC.metrics import * 
from kerasAC.custom_losses import * 
custom_objects={"recall":recall,
                    "sensitivity":recall,
                    "specificity":specificity,
                    "fpr":fpr,
                    "fnr":fnr,
                    "precision":precision,
                    "f1":f1,
                    "ambig_binary_crossentropy":ambig_binary_crossentropy,
                    "ambig_mean_absolute_error":ambig_mean_absolute_error,
                    "ambig_mean_squared_error":ambig_mean_squared_error,
                    "MultichannelMultinomialNLL":MultichannelMultinomialNLL}
get_custom_objects().update(custom_objects)

dnase_kmer24_model=load_model("/srv/scratch/annashch/bias_correction/enzymatic_bias/profile_model_of_bias/24mer/dnase/bias.dnase.24mer.0.hdf5")
dnase_kmer24_weights=dnase_kmer24_model.layers[1].get_weights()[0].squeeze()
dnase_kmer6_model=load_model("/srv/scratch/annashch/bias_correction/enzymatic_bias/profile_model_of_bias/6mer/dnase/bias.dnase.6mer.0.hdf5")
dnase_kmer6_weights=dnase_kmer6_model.layers[1].get_weights()[0].squeeze()
atac_kmer24_model=load_model("/srv/scratch/annashch/bias_correction/enzymatic_bias/profile_model_of_bias/24mer/atac/bias.atac.24mer.0.hdf5")
atac_kmer24_weights=atac_kmer24_model.layers[1].get_weights()[0].squeeze()
atac_kmer6_model=load_model("/srv/scratch/annashch/bias_correction/enzymatic_bias/profile_model_of_bias/6mer/atac/bias.atac.6mer.0.hdf5")
atac_kmer6_weights=atac_kmer6_model.layers[1].get_weights()[0].squeeze()
dnase_kmer24_weights.shape
f,axes=plt.subplots(nrows=2,ncols=3,dpi=80,figsize=(10,5))
axes[0,0]=plot_bases_on_ax(dnase_kmer6_weights[:,:,0],axes[0,0],show_ticks=True)
axes[0,1]=plot_bases_on_ax(dnase_kmer6_weights[:,:,1],axes[0,1],show_ticks=True)
axes[0,2]=plot_bases_on_ax(dnase_kmer6_weights[:,:,2],axes[0,2],show_ticks=True)
axes[1,0]=plot_bases_on_ax(dnase_kmer6_weights[:,:,3],axes[1,0],show_ticks=True)
axes[1,1]=plot_bases_on_ax(dnase_kmer6_weights[:,:,4],axes[1,1],show_ticks=True)
plt.suptitle("DNASE CNN, 5 filters, kernel size 6, weights ")
plt.subplots_adjust(hspace=0.4)
dnase_kmer24_weights[:,:,0].shape
f,axes=plt.subplots(nrows=5,ncols=1,dpi=80,figsize=(10,8))
axes[0]=plot_bases_on_ax(dnase_kmer24_weights[:,:,0],axes[0],show_ticks=True)
axes[1]=plot_bases_on_ax(dnase_kmer24_weights[:,:,1],axes[1],show_ticks=True)
axes[2]=plot_bases_on_ax(dnase_kmer24_weights[:,:,2],axes[2],show_ticks=True)
axes[3]=plot_bases_on_ax(dnase_kmer24_weights[:,:,3],axes[3],show_ticks=True)
axes[4]=plot_bases_on_ax(dnase_kmer24_weights[:,:,4],axes[4],show_ticks=True)
plt.suptitle("DNASE CNN, 5 filters, kernel size 24, weights ")
plt.subplots_adjust(hspace=0.4)
f,axes=plt.subplots(nrows=2,ncols=3,dpi=80,figsize=(10,5))
axes[0,0]=plot_bases_on_ax(atac_kmer6_weights[:,:,0],axes[0,0],show_ticks=True)
axes[0,1]=plot_bases_on_ax(atac_kmer6_weights[:,:,1],axes[0,1],show_ticks=True)
axes[0,2]=plot_bases_on_ax(atac_kmer6_weights[:,:,2],axes[0,2],show_ticks=True)
axes[1,0]=plot_bases_on_ax(atac_kmer6_weights[:,:,3],axes[1,0],show_ticks=True)
axes[1,1]=plot_bases_on_ax(atac_kmer6_weights[:,:,4],axes[1,1],show_ticks=True)
plt.suptitle("ATAC CNN, 5 filters, kernel size 6, weights ")
plt.subplots_adjust(hspace=0.4)
f,axes=plt.subplots(nrows=5,ncols=1,dpi=80,figsize=(10,8))
axes[0]=plot_bases_on_ax(atac_kmer24_weights[:,:,0],axes[0],show_ticks=True)
axes[1]=plot_bases_on_ax(atac_kmer24_weights[:,:,1],axes[1],show_ticks=True)
axes[2]=plot_bases_on_ax(atac_kmer24_weights[:,:,2],axes[2],show_ticks=True)
axes[3]=plot_bases_on_ax(atac_kmer24_weights[:,:,3],axes[3],show_ticks=True)
axes[4]=plot_bases_on_ax(atac_kmer24_weights[:,:,4],axes[4],show_ticks=True)
plt.suptitle("ATAC CNN, 5 filters, kernel size 24, weights ")
plt.subplots_adjust(hspace=0.4)<jupyter_output><empty_output><jupyter_text>Load KMER PSSM<jupyter_code>ohler_dnase_doublehit=np.loadtxt('/srv/scratch/annashch/bias_correction/enzymatic_bias_kmer/pwm.SeqBias_DNase_doublehit.txt').T
ohler_dnase_singlehit=np.loadtxt('/srv/scratch/annashch/bias_correction/enzymatic_bias_kmer/pwm.SeqBias_DNase_singlehit.txt').T
ohler_atac=np.loadtxt('/srv/scratch/annashch/bias_correction/enzymatic_bias_kmer/pwm.SeqBias_ATAC.txt').T
vierstra_dnase=np.loadtxt('/srv/scratch/annashch/bias_correction/enzymatic_bias_kmer/pwm.vierstra_et_al.6mer-model.txt').T<jupyter_output><empty_output><jupyter_text>plot<jupyter_code>f,axes=plt.subplots(6,dpi=80,figsize=(6,13))
seq_length=tobias_dnase_pssm_forward.shape[0]
axes[0]=plot_bases_on_ax(ohler_dnase_doublehit,axes[0],show_ticks=True)
axes[0].set_title('Ohler DNASE doublehit')
axes[2]=plot_bases_on_ax(ohler_dnase_singlehit,axes[2],show_ticks=True)
axes[2].set_title('Ohler DNASE singlehit')
axes[1]=plot_bases_on_ax(vierstra_dnase,axes[1],show_ticks=True)
axes[1].set_title('Vierstra DNASE')
axes[3]=plot_bases_on_ax(ohler_atac,axes[3],show_ticks=True)
axes[3].set_title('Ohler ATAC')
axes[4]=plot_bases_on_ax(dnase_kmer6_weights,axes[4],show_ticks=True)
axes[4].set_title('DNASE CNN, 1 filter, kernel size 6, weights')
axes[5]=plot_bases_on_ax(atac_kmer6_weights,axes[5],show_ticks=True)
axes[5].set_title('ATAC CNN, 1 filter, kernel size 6, weights')

plt.subplots_adjust(hspace=0.4)
f,axes=plt.subplots(4,dpi=80,figsize=(16,10))
seq_length=tobias_dnase_pssm_forward.shape[0]
axes[0]=plot_bases_on_ax(tobias_dnase_pssm_forward,axes[0],show_ticks=True)
axes[0].set_title('TOBIAS DNASE PSSM Forward')
axes[1]=plot_bases_on_ax(tobias_dnase_pssm_reverse,axes[1],show_ticks=True)
axes[1].set_title('TOBIAS DNASE PSSM Reverse')
axes[2]=plot_bases_on_ax(tobias_dnase_pssm_summed,axes[2],show_ticks=True)
axes[2].set_title('TOBIAS DNASE PSSM Summed')
axes[3]=plot_bases_on_ax(dnase_kmer24_weights,axes[3],show_ticks=True)
axes[3].set_title('DNASE CNN, 1 filter, kernel size 24, weights')
plt.subplots_adjust(hspace=0.4)
f,axes=plt.subplots(4,dpi=80,figsize=(16,10))
seq_length=tobias_atac_pssm_forward.shape[0]
axes[0]=plot_bases_on_ax(tobias_atac_pssm_forward,axes[0],show_ticks=True)
axes[0].set_title('TOBIAS ATAC PSSM Forward')
axes[1]=plot_bases_on_ax(tobias_atac_pssm_reverse,axes[1],show_ticks=True)
axes[1].set_title('TOBIAS ATAC PSSM Reverse')
axes[2]=plot_bases_on_ax(tobias_atac_pssm_summed,axes[2],show_ticks=True)
axes[2].set_title('TOBIAS ATAC PSSM Summed')
axes[3]=plot_bases_on_ax(atac_kmer24_weights,axes[3],show_ticks=True)
axes[3].set_title('ATAC CNN, 1 filter, kernel size 24, weights')
plt.subplots_adjust(hspace=0.4)<jupyter_output><empty_output><jupyter_text>BPNET kmer scores<jupyter_code>dnase_6mer_bpnet=np.loadtxt("/srv/scratch/annashch/bias_correction/enzymatic_bias/qc_prof_mod_predictions/tmp.txt")
plot_seq_importance(dnase_6mer_bpnet.T,xlim=(0,7),ylim=(-100,5),figsize=(6,4))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15600050690660247, 'fraction_numerical': 0.0470155873780256, 'mean_word_length': 11.667736757624398, 'pattern_counts': {'":': 11, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '331471', 'license': 'MIT', 'n_tokens_mistral': 3730, 'n_tokens_neox': 3525, 'n_words': 208, 'path': 'enzymatic_bias/compare_bias_pwm.ipynb', 'repo_name': 'kundajelab/bias_correction', 'size': '7891'}