from matlas.matches import DenovoModisco, DenovoHomer
from vdom.helpers import (b, summary)
from IPython.display import display
import numpy as np
def adjust_motifs(ob):
for motif_name in ob.denovo_pwms.keys():
a = ob.get_pwm(motif_name)
ones = np.sum(a, axis=1)
for i, one in enumerate(ones):
if (one-1.0)!=1:
#print('decrease', motif_name, i)
part = (one-1.0)/4
ob.denovo_pwms[motif_name]['PPM'][i] -= part
return ob
def display_paiwise_pattern_comparison(task_idx, sample_name, modiscodir, homerdir):
display(summary(b(sample_name + " (differential regions)")))
homer_ob = DenovoHomer(homerdir)
homer_ob.fetch_tomtom_matches(save_report=True,
tomtom_dir= "{0}/{1}_tomtomout".format(homerdir, "CISBP_2.00"))
#homer_ob = adjust_motifs(homer_ob)
homer_ob.load_matched_motifs()
homer_ob.get_motif_per_celltype()
modisco_ob = DenovoModisco(modiscodir)
modisco_ob.load_matched_motifs()
modisco_ob.get_motif_per_celltype()
modisco_ob.display_pairwise_tf_table(homer_ob)
return None
def display_denovo_patterns(sample_name, modiscodir, match_threshold=0.05):
display(summary(b(sample_name)))
ob = DenovoModisco(modiscodir)
ob.load_matched_motifs()
ob.get_motif_per_celltype(match_threshold=match_threshold)
ob.display_individual_table()
return None