Skip to content

Commit

Permalink
Merge pull request #80 from kundajelab/bugfix
Browse files Browse the repository at this point in the history
Changing sum-to-1 error to a warning for calculating information content
  • Loading branch information
AvantiShri committed Jan 22, 2021
2 parents 150f4a4 + 7c282df commit 1058bac
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions modisco/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,9 +474,14 @@ def compute_per_position_ic(ppm, background, pseudocount):
assert len(ppm.shape)==2
assert ppm.shape[1]==len(background),\
"Make sure the letter axis is the second axis"
assert (np.max(np.abs(np.sum(ppm, axis=1)-1.0)) < 1e-5),(
"Probabilities don't sum to 1 along axis 1 in "
+str(ppm)+"\n"+str(np.sum(ppm, axis=1)))
if (np.max(np.abs(np.sum(ppm, axis=1)-1.0)) < 1e-5):
print("WARNING: Probabilities don't sum to 1 in all the rows; this can"
+" be caused by zero-padding. Will renormalize. PPM:\n"
+str(ppm)
+"\nProbability sums:\n"
+str(np.sum(ppm, axis=1)))
ppm = ppm/np.sum(ppm, axis=1)[:,None]

alphabet_len = len(background)
ic = ((np.log((ppm+pseudocount)/(1 + pseudocount*alphabet_len))/np.log(2))
*ppm - (np.log(background)*background/np.log(2))[None,:])
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.10.0',
version='0.5.10.1',
packages=find_packages(),
package_data={
'': ['cluster/phenograph/louvain/*convert*', 'cluster/phenograph/louvain/*community*', 'cluster/phenograph/louvain/*hierarchy*']
Expand Down

0 comments on commit 1058bac

Please sign in to comment.