Skip to content

Commit

Permalink
v0.0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
jmschrei committed Sep 16, 2022
1 parent 8e97976 commit a9753c2
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 20 deletions.
2 changes: 1 addition & 1 deletion modiscolite/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
from . import cluster
from . import report

__version__ = '0.0.8'
__version__ = '0.0.9'
6 changes: 5 additions & 1 deletion modiscolite/affinitymat.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,12 @@ def tsne_probs_calc(self, distances_nn, neighbors_nn):
conditional_P = sklearn.manifold._utils._binary_search_perplexity(
distances, self.perplexity, verbose=False)

eps = 1e-8
marginal_sum = conditional_P.sum(axis=-1)
marginal_sum[marginal_sum < eps] = eps

#normalize the conditional_P to sum to 1 across the rows
conditional_P = conditional_P/np.sum(conditional_P, axis=-1)[:,None]
conditional_P = conditional_P / marginal_sum[:,None]

data = []
rows = []
Expand Down
18 changes: 11 additions & 7 deletions modiscolite/aggregator.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ def polish_pattern(pattern, min_frac, min_num, track_set, flank, window_size, bg
track_set=track_set, left_flank_to_add=flank,
right_flank_to_add=flank)

if pattern is None:
return None

# Trim by IC
ppm = pattern.sequence
per_pos_ic = util.compute_per_position_ic(
Expand Down Expand Up @@ -382,13 +385,14 @@ def SimilarPatternsCollapser(patterns, track_set,
min_num=min_num, track_set=track_set, flank=flank_to_add,
window_size=window_size, bg_freq=bg_freq)

for k in range(len(patterns)):
#Replace EVERY case where the parent or child
# pattern is present with the new pattern. This
# effectively does single-linkage.
if (patterns[k]==parent_pattern or
patterns[k]==child_pattern):
patterns[k]=new_pattern
if new_pattern is not None:
for k in range(len(patterns)):
#Replace EVERY case where the parent or child
# pattern is present with the new pattern. This
# effectively does single-linkage.
if (patterns[k]==parent_pattern or
patterns[k]==child_pattern):
patterns[k]=new_pattern

merge_occurred_last_iteration = (len(indices_to_merge) > 0)

Expand Down
8 changes: 2 additions & 6 deletions modiscolite/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ def compute_subpatterns(self, perplexity, n_seeds, n_iterations=-1):
distmat_nn = np.log((1.0/(0.5*np.maximum(affmat_nn, 0.0000001)))-1)
distmat_nn = np.maximum(distmat_nn, 0.0) #eliminate tiny neg floats


distmat_sp = scipy.sparse.coo_matrix(
(np.concatenate(distmat_nn, axis=0),
(np.array([i for i in range(len(seqlet_neighbors))
Expand All @@ -151,11 +150,8 @@ def compute_subpatterns(self, perplexity, n_seeds, n_iterations=-1):
distmat_sp.sort_indices()

#do density adaptation
density_adapted_affmat_transformer =\
affinitymat.NNTsneConditionalProbs(
perplexity=perplexity)
sp_density_adapted_affmat = density_adapted_affmat_transformer(
affmat_nn, seqlet_neighbors)
sp_density_adapted_affmat = affinitymat.NNTsneConditionalProbs(
perplexity=perplexity)(affmat_nn, seqlet_neighbors)

sp_density_adapted_affmat += sp_density_adapted_affmat.T
sp_density_adapted_affmat /= np.sum(sp_density_adapted_affmat.data)
Expand Down
7 changes: 3 additions & 4 deletions modiscolite/tfmodisco.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ def _density_adaptation(affmat_nn, seqlet_neighbors, tsne_perplexity):

affmat_diags = scipy.sparse.diags(1.0 / normfactors)
affmat_nn += affmat_diags


return affmat_nn

def _filter_patterns(patterns, min_seqlet_support, window_size,
Expand Down Expand Up @@ -117,8 +115,9 @@ def _motif_from_clusters(seqlets, track_set, min_overlap,
min_num=min_num, track_set=track_set, flank=flank_to_add,
window_size=window_size, bg_freq=bg_freq)

if np.sign(np.sum(pattern.contrib_scores)) == track_sign:
cluster_to_motif.append(pattern)
if pattern is not None:
if np.sign(np.sum(pattern.contrib_scores)) == track_sign:
cluster_to_motif.append(pattern)

return cluster_to_motif

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='modisco-lite',
version='0.0.8',
version='0.0.9',
author='Jacob Schreiber',
author_email='[email protected]',
packages=['modiscolite'],
Expand Down

0 comments on commit a9753c2

Please sign in to comment.