Skip to content

Commit

Permalink
Merge pull request #9 from pachterlab/dev
Browse files Browse the repository at this point in the history
bump main to 0260
  • Loading branch information
gennadygorin authored Apr 17, 2023
2 parents e7c2430 + d7e3ff5 commit a7a5db3
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 14 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = monod
version = 0.2.5.0
version = 0.2.6.0
author = Gennady Gorin, Lior Pachter
author_email = [email protected], [email protected]
description = the Monod package fits CME models to sequencing data.
Expand Down
30 changes: 24 additions & 6 deletions src/monod/cme_toolbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,24 +144,42 @@ def get_log_name_str(self):
TeX-formatted log-parameter names for the current transcriptional model.
Useful for plot labels.
"""
param_str = []
if self.bio_model == "Constitutive":
return (r"$\log_{10} \beta$", r"$\log_{10} \gamma$")
param_str += [r"$\log_{10} \beta$", r"$\log_{10} \gamma$"]
elif self.bio_model == "Delay":
return (r"$\log_{10} b$", r"$\log_{10} \beta$", r"$\log_{10} \tau^{-1}$")
param_str += [
r"$\log_{10} b$",
r"$\log_{10} \beta$",
r"$\log_{10} \tau^{-1}$",
]
elif self.bio_model == "DelayedSplicing":
return (r"$\log_{10} b$", r"$\log_{10} \tau^{-1}$", r"$\log_{10} \gamma$")
param_str += [
r"$\log_{10} b$",
r"$\log_{10} \tau^{-1}$",
r"$\log_{10} \gamma$",
]
elif self.bio_model == "Bursty":
return (r"$\log_{10} b$", r"$\log_{10} \beta$", r"$\log_{10} \gamma$")
param_str += [r"$\log_{10} b$", r"$\log_{10} \beta$", r"$\log_{10} \gamma$"]
elif self.bio_model == "Extrinsic":
return (r"$\log_{10} \alpha$", r"$\log_{10} \beta$", r"$\log_{10} \gamma$")
param_str += [
r"$\log_{10} \alpha$",
r"$\log_{10} \beta$",
r"$\log_{10} \gamma$",
]
elif self.bio_model == "CIR":
return (r"$\log_{10} b$", r"$\log_{10} \beta$", r"$\log_{10} \gamma$")
param_str += [r"$\log_{10} b$", r"$\log_{10} \beta$", r"$\log_{10} \gamma$"]
else:
raise ValueError(
"Please select a biological noise model from {}.".format(
self.available_biomodels
)
)
if self.amb_model == "Equal":
param_str += [r"$\log_{10} p$"]
elif self.amb_model == "Unequal":
param_str += [r"$\log_{10} p_N$", r"$\log_{10} p_M$"]
return param_str

def get_num_params(self):
"""Return the number of parameters for the model instance.
Expand Down
13 changes: 7 additions & 6 deletions src/monod/extract_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,9 @@ def __init__(self, attr_names, *input_data):
for j in range(len(input_data)):
setattr(self, attr_names[j], input_data[j])

def get_noise_decomp(self, sizefactor="pf", lognormalize=True, pcount=0, which_variance_measure='CV2'):
def get_noise_decomp(
self, sizefactor="pf", lognormalize=True, pcount=0, which_variance_measure="CV2"
):
"""
This method performs normalization and variance stabilization on the raw data, and
reports the fractions of normalized variance retained and removed as a result of the process.
Expand Down Expand Up @@ -312,14 +314,13 @@ def get_noise_decomp(self, sizefactor="pf", lognormalize=True, pcount=0, which_v
S = np.copy(self.layers[1])
U = np.copy(self.layers[0])

if which_variance_measure == 'CV2':
var_fun = lambda X: X.var(1) / (X.mean(1)**2)
elif which_variance_measure == 'var':
if which_variance_measure == "CV2":
var_fun = lambda X: X.var(1) / (X.mean(1) ** 2)
elif which_variance_measure == "var":
var_fun = lambda X: X.var(1)
elif which_variance_measure == 'Fano':
elif which_variance_measure == "Fano":
var_fun = lambda X: X.var(1) / (X.mean(1))


var_S = var_fun(S)
var_U = var_fun(U)
# CV2_S = S.var(1) / S.mean(1) ** 2
Expand Down
2 changes: 1 addition & 1 deletion src/monod/preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import scipy
from scipy import sparse

code_ver_global = "025" # bumping up version early Nov
code_ver_global = "026" # bumping up version early Nov

########################
## Debug and error logging
Expand Down

0 comments on commit a7a5db3

Please sign in to comment.