Skip to content

Commit

Permalink
Merge pull request #70 from kundajelab/fixedgecasesigndisagreement
Browse files Browse the repository at this point in the history
Retrying what was supposed to be PR 67
  • Loading branch information
AvantiShri authored Oct 1, 2020
2 parents cbebfe0 + 65c5f41 commit c25d398
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 12 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ matrix:
include:
- python: 3.6
env: TF_VERSION=1.14.0
- python: 3.8.3
env: TF_VERSION=2.3.0

notifications:
email: true
Expand Down
2 changes: 1 addition & 1 deletion modisco.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: modisco
Version: 0.5.8.0
Version: 0.5.8.1
Summary: TF MOtif Discovery from Importance SCOres
Home-page: https://github.com/kundajelab/tfmodisco
License: UNKNOWN
Expand Down
1 change: 1 addition & 0 deletions modisco/affinitymat/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,7 @@ def __init__(self, n_cores, cross_metric_single_region, verbose=True):
self.cross_metric_single_region = cross_metric_single_region
self.verbose = verbose

#min_overlap is w.r.t. the length of 'filters'
def __call__(self, filters, things_to_scan, min_overlap,
neighbors_of_things_to_scan=None,
return_sparse=False):
Expand Down
17 changes: 10 additions & 7 deletions modisco/aggregator.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ def __call__(self, patterns):
large_patterns, new_assignments =\
self.seqlet_assigner(patterns=large_patterns,
seqlets_to_assign=seqlets_to_assign,
merge_into_existing_patterns=True)
merge_into_existing_patterns=False)
large_patterns = self.postprocessor(large_patterns)
return large_patterns
else:
Expand Down Expand Up @@ -399,13 +399,16 @@ def __call__(self, patterns, seqlets_to_assign,

if (merge_into_existing_patterns):
new_patterns = patterns
for pattern,x in zip(patterns, seqlet_and_alnmnt_grps):
pattern.merge_seqlets_and_alnmts(
seqlets_and_alnmts=x,
aligner=self.pattern_aligner)
else:
new_patterns = [core.AggregatedSeqlet(seqlets_and_alnmts_arr=x)
for x in seqlet_and_alnmnt_grps if len(x) > 0]
#Make a copy of each one
new_patterns = [
core.AggregatedSeqlet(pattern._seqlets_and_alnmts.copy())
for pattern in patterns]

for pattern,x in zip(new_patterns, seqlet_and_alnmnt_grps):
pattern.merge_seqlets_and_alnmts(
seqlets_and_alnmts=x,
aligner=self.pattern_aligner)

return new_patterns, seqlet_assignments

Expand Down
6 changes: 5 additions & 1 deletion modisco/backend/tensorflow_backend.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
from __future__ import division, print_function
import tensorflow as tf
try:
import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()
except:
import tensorflow as tf
import numpy as np
import sys

Expand Down
19 changes: 17 additions & 2 deletions modisco/tfmodisco_workflow/seqlets_to_patterns.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,11 +507,14 @@ class SeqletsToPatternsResults(object):

def __init__(self,
each_round_initcluster_motifs,
patterns, cluster_results,
patterns,
patterns_withoutreassignment,
cluster_results,
total_time_taken, success=True, **kwargs):
self.each_round_initcluster_motifs = each_round_initcluster_motifs
self.success = success
self.patterns = patterns
self.patterns_withoutreassignment = patterns_withoutreassignment
self.cluster_results = cluster_results
self.total_time_taken = total_time_taken
self.__dict__.update(**kwargs)
Expand Down Expand Up @@ -553,11 +556,18 @@ def from_hdf5(cls, grp, track_set):
track_set=track_set)
patterns = util.load_patterns(grp=grp["patterns"],
track_set=track_set)
if "patterns_withoutreassignment" in grp:
patterns_withoutreassignment = util.load_patterns(
grp=grp["patterns_withoutreassignment"],
track_set=track_set)
else: #backwards compatibility
patterns_withoutreassignment = []
cluster_results = None
total_time_taken = None
return cls(
each_round_initcluster_motifs=each_round_initcluster_motifs,
patterns=patterns,
patterns_withoutreassignment=patterns_withoutreassignment,
cluster_results=cluster_results,
total_time_taken=total_time_taken)
else:
Expand All @@ -572,6 +582,9 @@ def save_hdf5(self, grp):
grp=grp.create_group("each_round_initcluster_motifs"))
util.save_patterns(self.patterns,
grp.create_group("patterns"))
util.save_patterns(
self.patterns_withoutreassignment,
grp.create_group("patterns_withoutreassignment"))
self.cluster_results.save_hdf5(grp.create_group("cluster_results"))
grp.attrs['total_time_taken'] = self.total_time_taken

Expand Down Expand Up @@ -656,7 +669,6 @@ def get_cluster_to_aggregate_motif(self, seqlets, cluster_indices,
" with "+str(motif.num_seqlets)
+" seqlets due to sign disagreement")
cluster_to_eliminated_motif[i] = motif
cluster_to_motif[i] = motif
return cluster_to_motif, cluster_to_eliminated_motif


Expand Down Expand Up @@ -892,6 +904,8 @@ def __call__(self, seqlets):
sys.stdout.flush()
reassigned_patterns = self.seqlet_reassigner(merged_patterns)
final_patterns = self.final_postprocessor(reassigned_patterns)
final_patterns_withoutreassignment =\
self.final_postprocessor(merged_patterns)
if (self.verbose):
print("Got "+str(len(final_patterns))
+" patterns after reassignment")
Expand All @@ -908,6 +922,7 @@ def __call__(self, seqlets):
results = SeqletsToPatternsResults(
each_round_initcluster_motifs=each_round_initcluster_motifs,
patterns=final_patterns,
patterns_withoutreassignment=final_patterns_withoutreassignment,
seqlets=filtered_seqlets, #last stage of filtered seqlets
#affmat=filtered_affmat,
cluster_results=cluster_results,
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
description='TF MOtif Discovery from Importance SCOres',
long_description="""Algorithm for discovering consolidated patterns from base-pair-level importance scores""",
url='https://github.com/kundajelab/tfmodisco',
version='0.5.8.0',
version='0.5.8.1',
packages=find_packages(),
package_data={
'': ['cluster/phenograph/louvain/*convert*', 'cluster/phenograph/louvain/*community*', 'cluster/phenograph/louvain/*hierarchy*']
Expand Down

0 comments on commit c25d398

Please sign in to comment.