diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index e7db07216..b6687a00f 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -21,6 +21,5 @@ jobs: with: file: ./coverage.xml flags: unittests - env_vars: OS,PYTHON - name: codecov-umbrella + token: ${{ secrets.CODECOV_TOKEN }} fail_ci_if_error: true diff --git a/lineage/HMM/E_step.py b/lineage/HMM/E_step.py index d39f6c6f7..2f44b62ab 100644 --- a/lineage/HMM/E_step.py +++ b/lineage/HMM/E_step.py @@ -140,9 +140,8 @@ def get_beta( cIDXs = np.arange(MSD.shape[0]) cIDXs = np.delete(cIDXs, leaves_idx) - cIDXs = np.flip(cIDXs) - for pii in cIDXs: + for pii in reversed(cIDXs): ch_ii = cell_to_daughters[pii, :] ratt = (beta[ch_ii, :] / MSD_array[ch_ii, :]) @ T.T fac1 = np.prod(ratt, axis=0) * ELMSD[pii, :] diff --git a/lineage/HMM/M_step.py b/lineage/HMM/M_step.py index 9a4ded7f9..8a4e99f5d 100644 --- a/lineage/HMM/M_step.py +++ b/lineage/HMM/M_step.py @@ -46,7 +46,7 @@ def get_all_zetas( TbetaMSD = np.clip(betaMSD @ T.T, np.finfo(float).eps, np.inf) cIDXs = np.arange(gammas.shape[0]) - cIDXs = np.delete(cIDXs, leaves_idx, axis=0) + cIDXs = np.delete(cIDXs, leaves_idx) dIDXs = cell_to_daughters[cIDXs, :] diff --git a/lineage/import_lineage.py b/lineage/import_lineage.py index 07bc87644..79bc8467d 100644 --- a/lineage/import_lineage.py +++ b/lineage/import_lineage.py @@ -198,8 +198,8 @@ def assign_observs_MCF10A(cell, lineage, uniq_id: int): parent_id = lineage["motherID"].unique() # cell fate: die = 0, divide = 1 - if not ( - uniq_id in parent_id + if ( + uniq_id not in parent_id ): # if the cell has not divided, means either died or reached experiment end time if ( np.max(lineage.loc[lineage["TID"] == uniq_id]["tmin"]) == t_end diff --git a/lineage/states/StateDistributionGaPhs.py b/lineage/states/StateDistributionGaPhs.py index 41ffa36ba..1002862c0 100644 --- a/lineage/states/StateDistributionGaPhs.py +++ b/lineage/states/StateDistributionGaPhs.py @@ -12,12 +12,12 @@ class StateDistribution: def __init__( self, - bern_p1=0.9, - bern_p2=0.75, - gamma_a1=7.0, - gamma_scale1=3, - gamma_a2=14.0, - gamma_scale2=6, + bern_p1: float = 0.9, + bern_p2: float = 0.75, + gamma_a1: float = 7.0, + gamma_scale1: float = 3.0, + gamma_a2: float = 14.0, + gamma_scale2: float = 6.0, ): # user has to identify what parameters to use for each state """Initialization function should take in just in the parameters for the observations that comprise the multivariate random variable emission they expect their data to have.""" self.params = np.array( diff --git a/lineage/states/StateDistributionGamma.py b/lineage/states/StateDistributionGamma.py index a77421de5..a142ba21e 100644 --- a/lineage/states/StateDistributionGamma.py +++ b/lineage/states/StateDistributionGamma.py @@ -13,7 +13,9 @@ class StateDistribution: StateDistribution for cells with gamma distributed times. """ - def __init__(self, bern_p=0.9, gamma_a=7, gamma_scale=4.5): + def __init__( + self, bern_p: float = 0.9, gamma_a: float = 7.0, gamma_scale: float = 4.5 + ): """Initialization function should take in just in the parameters for the observations that comprise the multivariate random variable emission they expect their data to have. In this case, we used Gamma distribution for cell lifetime, which has 2 parameters; shape and scale. diff --git a/lineage/states/stateCommon.py b/lineage/states/stateCommon.py index cd0b5b3ea..09d136015 100644 --- a/lineage/states/stateCommon.py +++ b/lineage/states/stateCommon.py @@ -59,12 +59,12 @@ def gamma_LL( def gamma_estimator( - gamma_obs: list[np.ndarray], - time_cen: list[np.ndarray], - gammas: list[np.ndarray], - x0: np.ndarray, + gamma_obs: list[arr_type], + time_cen: list[arr_type], + gammas: list[arr_type], + x0: arr_type, phase: str = "all", -) -> npt.NDArray[np.float64]: +) -> arr_type: """ This is a weighted, closed-form estimator for two parameters of the Gamma distribution for estimating shared shape and separate scale parameters of several drug concentrations at once. @@ -100,7 +100,7 @@ def gamma_estimator( else: linc = () - bnd = Bounds(-4.0, 7.0, keep_feasible=True) + bnd = Bounds(-4.0, 7.0, keep_feasible=False) with np.errstate(all="raise"): res = minimize( diff --git a/poetry.lock b/poetry.lock index fcbb9c0b4..efefc95da 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1226,13 +1226,13 @@ diagrams = ["jinja2", "railroad-diagrams"] [[package]] name = "pytest" -version = "8.0.1" +version = "8.0.2" description = "pytest: simple powerful testing with Python" optional = false python-versions = ">=3.8" files = [ - {file = "pytest-8.0.1-py3-none-any.whl", hash = "sha256:3e4f16fe1c0a9dc9d9389161c127c3edc5d810c38d6793042fb81d9f48a59fca"}, - {file = "pytest-8.0.1.tar.gz", hash = "sha256:267f6563751877d772019b13aacbe4e860d73fe8f651f28112e9ac37de7513ae"}, + {file = "pytest-8.0.2-py3-none-any.whl", hash = "sha256:edfaaef32ce5172d5466b5127b42e0d6d35ebbe4453f0e3505d96afd93f6b096"}, + {file = "pytest-8.0.2.tar.gz", hash = "sha256:d4051d623a2e0b7e51960ba963193b09ce6daeb9759a451844a21e4ddedfc1bd"}, ] [package.dependencies] @@ -1302,13 +1302,13 @@ testing = ["filelock"] [[package]] name = "python-dateutil" -version = "2.8.2" +version = "2.9.0" description = "Extensions to the standard Python datetime module" optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,>=2.7" files = [ - {file = "python-dateutil-2.8.2.tar.gz", hash = "sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86"}, - {file = "python_dateutil-2.8.2-py2.py3-none-any.whl", hash = "sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9"}, + {file = "python-dateutil-2.9.0.tar.gz", hash = "sha256:78e73e19c63f5b20ffa567001531680d939dc042bf7850431877645523c66709"}, + {file = "python_dateutil-2.9.0-py2.py3-none-any.whl", hash = "sha256:cbf2f1da5e6083ac2fbfd4da39a25f34312230110440f424a14c7558bb85d82e"}, ] [package.dependencies] @@ -1774,13 +1774,13 @@ files = [ [[package]] name = "typing-extensions" -version = "4.9.0" +version = "4.10.0" description = "Backported and Experimental Type Hints for Python 3.8+" optional = false python-versions = ">=3.8" files = [ - {file = "typing_extensions-4.9.0-py3-none-any.whl", hash = "sha256:af72aea155e91adfc61c3ae9e0e342dbc0cba726d6cba4b6c72c1f34e47291cd"}, - {file = "typing_extensions-4.9.0.tar.gz", hash = "sha256:23478f88c37f27d76ac8aee6c905017a143b0b1b886c3c9f66bc2fd94f9f5783"}, + {file = "typing_extensions-4.10.0-py3-none-any.whl", hash = "sha256:69b1a937c3a517342112fb4c6df7e72fc39a38e7891a5730ed4985b5214b5475"}, + {file = "typing_extensions-4.10.0.tar.gz", hash = "sha256:b0abd7c89e8fb96f98db18d86106ff1d90ab692004eb746cf6eda2682f91b3cb"}, ] [[package]]