Skip to content

Commit cc3102e

Browse files
authored
Merge branch 'master' into worktree-wobbly-riding-origami
2 parents 6f6135c + 9fff0e5 commit cc3102e

16 files changed

Lines changed: 191 additions & 119 deletions

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ nosetests.xml
1313

1414
.venv/
1515
venv/
16+
.claude/
1617
profile
1718
profile.svg
1819
.DS_Store

‎docs/Installation.rst‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,26 @@ You can clone the public repository:
1717
.. code-block:: console
1818
1919
$ git clone https://github.com/meyer-lab/tHMM.git
20+
21+
tHMM is built and its dependencies are managed with `uv`_. Once you have
22+
`uv` installed, set up the environment and install all dependencies with:
23+
24+
.. code-block:: console
25+
26+
$ cd tHMM
27+
$ uv sync
28+
29+
You can then run the test suite:
30+
31+
.. code-block:: console
32+
33+
$ uv run pytest
34+
35+
or use any of the package's modules with:
36+
37+
.. code-block:: console
38+
39+
$ uv run python -c "from lineage.LineageTree import LineageTree"
40+
41+
.. _Github repo: https://github.com/meyer-lab/tHMM
42+
.. _uv: https://docs.astral.sh/uv/

‎docs/conf.py‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
# -- Project information -----------------------------------------------------
2323

2424
project = "tHMM"
25-
copyright = "2022, Farnaz Mohammadi, JC Lagarde, Aaron S Meyer"
25+
copyright = "2022-2026, Farnaz Mohammadi, JC Lagarde, Aaron S Meyer"
2626
author = "Farnaz Mohammadi, JC Lagarde, Aaron S Meyer"
2727

2828
# The full version, including alpha/beta/rc tags
@@ -66,11 +66,6 @@
6666
#
6767
html_theme = "sphinx_rtd_theme"
6868

69-
# Add any paths that contain custom static files (such as style sheets) here,
70-
# relative to this directory. They are copied after the builtin static files,
71-
# so a file named "default.css" will overwrite the builtin "default.css".
72-
html_static_path = ["_static"]
73-
7469
autoapi_root = "technical/api"
7570

7671
autodoc_typehints = "description"

‎docs/index.rst‎

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,49 +4,57 @@ Welcome to tHMM's documentation!
44
================================
55

66
tHMM is a Python3 library for clustering data in the form of a binary lineage tree.
7-
This documentation includes an overview of the package, and how to use the functions and classes,
7+
This documentation includes an overview of the package, and how to use the functions and classes,
88
and examples of the application of tHMM in identifying cellular phenotypic heterogeneity in cancer cells under treatment.
99

1010
Features
1111
--------
1212

13-
* Uses lineage tree data for clustering individuals according to their relationship to each other and measurements.
13+
* Uses lineage tree data for clustering individuals according to their relationship to each other and measurements.
1414
* Outputs the number of clusters, transition probability between the clusters, and distribution corresponding to the emission for each cluster.
1515
* Can plot the lineage trees with their associated cluster shown as a color.
1616

1717
Outline
1818
-------
1919

20-
.. toctree:: Overview
20+
.. toctree::
21+
:caption: Overview
2122
:name: overview
2223
:maxdepth: 1
2324

24-
overview.rst
25+
overview
2526

26-
.. toctree:: Installation
27+
.. toctree::
28+
:caption: Installation
2729
:name: install
2830
:maxdepth: 1
2931

30-
installation.rst
32+
Installation
3133

32-
.. toctree:: System Requirements
34+
.. toctree::
35+
:caption: System Requirements
3336
:name: syst-req
3437
:maxdepth: 1
3538

36-
system-reqs.rst
39+
system-reqs
3740

38-
.. toctree:: getting-started
41+
.. toctree::
42+
:caption: Getting Started
3943
:name: getting-started
4044
:maxdepth: 1
4145

42-
tHMM-getting-started.rst
46+
tHMM-getting-started
4347

44-
.. toctree:: Emissions
48+
.. toctree::
49+
:caption: Emissions
4550
:name: stateDistribution
4651
:maxdepth: 1
4752

48-
stateDistributions.rst
53+
stateDistributions
4954

50-
.. toctree:: API Reference
55+
.. toctree::
56+
:caption: API Reference
5157
:name: api
5258
:maxdepth: 1
59+
60+
technical/api/index

‎docs/modules.rst‎

Lines changed: 0 additions & 4 deletions
This file was deleted.

‎docs/requirements.txt‎

Lines changed: 0 additions & 4 deletions
This file was deleted.

‎docs/stateDistributions.rst‎

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ These are assigned as instances of the class object. One can assert that the giv
3434
actually make sense for the distribution. For example, a normal
3535
distribution cannot have a negative or zero standard deviation.
3636

37-
.. code:: ipython3
37+
.. code:: python
38+
3839
import numpy as np
3940
import scipy.stats as sp
4041
@@ -46,7 +47,8 @@ distribution cannot have a negative or zero standard deviation.
4647
self.gamma_scale = gamma_scale
4748
self.params = [self.bern_p, self.gamma_a, self.gamma_scale]
4849
49-
.. code:: ipython3
50+
.. code:: python
51+
5052
#Normal
5153
def __init__(self, norm_loc, norm_scale):
5254
""" 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. """
@@ -73,7 +75,7 @@ The variables `gamma_obs_censor` and `norm_obs_censor` are created and set to 1
7375
We do the censoring later.
7476
The rvs function returns the observed phenotypes as a tuple of lists.
7577

76-
.. code:: ipython3
78+
.. code:: python
7779
7880
# Bernoulli/Gamma
7981
def rvs(self, size: int):
@@ -86,7 +88,8 @@ The rvs function returns the observed phenotypes as a tuple of lists.
8688
# These tuples of observations will go into the cells in the lineage tree.
8789
return bern_obs, gamma_obs, gamma_obs_censor
8890
89-
.. code:: ipython3
91+
.. code:: python
92+
9093
# Normal
9194
def rvs(self, size): # user has to identify what the multivariate (or univariate if he or she so chooses) random variable looks like
9295
""" User-defined way of calculating a random variable given the parameters of the state stored in that observation's object. """
@@ -117,7 +120,8 @@ The fully observed cells are fed to `logpdf` to calculate the likelihood,
117120
and those cells that have missing information are fed to `logsf`.
118121
Those cells that died are then removed in the first example that cell's fate matters.
119122

120-
.. code:: ipython3
123+
.. code:: python
124+
121125
# Bernoulli/Gamma
122126
def logpdf(self, x: np.ndarray):
123127
""" User-defined way of calculating the likelihood of the observation stored in a cell.
@@ -138,7 +142,8 @@ Those cells that died are then removed in the first example that cell's fate mat
138142
139143
return ll
140144
141-
.. code:: ipython3
145+
.. code:: python
146+
142147
# Normal
143148
def logpdf(self, tuple_of_obs): # user has to define how to calculate the likelihood
144149
""" User-defined way of calculating the likelihood of the observation stored in a cell. """
@@ -173,7 +178,7 @@ minimize function of the scipy.optimize to find the parameters and
173178
the function is located in the lineage/states/stateCommon.py
174179

175180

176-
.. code:: ipython3
181+
.. code:: python
177182
178183
# Bernoulli/Gamma
179184
def estimator(self, x: list, gammas: np.array):
@@ -201,7 +206,8 @@ the function is located in the lineage/states/stateCommon.py
201206
202207
self.params[1], self.params[2] = gamma_estimator(γ_obs[g_mask], gamma_obs_censor[g_mask], gammas[g_mask], self.params[1:3]) # gamma shape and scale
203208
204-
.. code:: ipython3
209+
.. code:: python
210+
205211
# Normal
206212
def estimator(self, x: list, gammas: np.array):
207213
""" User-defined way of estimating the parameters given a list of the tuples of observations from a group of cells. """
@@ -225,7 +231,7 @@ Now that we have a functioning Gaussian StateDistribution, let's try it
225231
with the overall model. As in the overview, we first define our initial probability vector and
226232
the state transition probability matrices.
227233

228-
.. code:: ipython3
234+
.. code:: python
229235
230236
from lineage.LineageTree import LineageTree
231237
@@ -236,7 +242,7 @@ the state transition probability matrices.
236242
237243
Creating the Emissions for two states:
238244

239-
.. code:: ipython3
245+
.. code:: python
240246
241247
# E: states are defined as StateDistribution objects
242248
@@ -255,7 +261,7 @@ Creating the Emissions for two states:
255261
256262
Creating the lineage tree:
257263

258-
.. code:: ipython3
264+
.. code:: python
259265
260266
lineage1 = LineageTree.rand_init(pi, T, E, desired_num_cells=2**5 - 1)
261267
# These are the minimal arguments required to instantiate lineages
@@ -266,23 +272,25 @@ Below is the analysis for a single lineage. Note that the state objects
266272
are merely switched. However, the model fairly accurately predicts the
267273
transition matrix and state parameters.
268274

269-
.. code:: ipython3
275+
.. code:: python
276+
277+
from lineage.Analyze import Analyze_list
270278
271-
from lineage.Analyze import Analyze
272279
X = [lineage1] # population just contains one lineage
273-
tHMMobj, pred_states_by_lineage, LL = Analyze(X, 2) # find two states
280+
tHMMobj_list, LL, gammas = Analyze_list([X], 2, write_states=True) # find two states
281+
tHMMobj = tHMMobj_list[0]
274282
275-
.. code:: ipython3
283+
.. code:: python
276284
277285
print(tHMMobj.estimate.pi)
278286
279-
.. code:: ipython3
287+
.. code:: python
280288
281289
print(tHMMobj.estimate.T)
282290
283-
.. code:: ipython3
291+
.. code:: python
284292
285-
for state in range(lineage1.num_states):
293+
for state in range(tHMMobj.num_states):
286294
print("State {}:".format(state))
287295
print(" estimated state:", tHMMobj.estimate.E[state])
288296
print("original parameters given for state:", E[state])
@@ -304,7 +312,7 @@ latent clocks -- a division clock ``T_D`` and a death clock ``T_X`` -- and what
304312
observe is ``min(T_D, T_X)`` together with which one fired. The likelihood has the
305313
three standard competing-risks cases:
306314

307-
.. code:: ipython3
315+
.. code:: python
308316
309317
# transition seen at t: f_D(t) * S_X(t)
310318
# death seen at t: f_X(t) * S_D(t)

‎docs/system-reqs.rst‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,7 @@ OS requirements
2222

2323
Python dependencies
2424
-------------------
25-
`tHMM` requires `virtualenv`. All other required packages can then be installed using `make venv` to establish a virtual environment. The Python packages that will be installed are listed in `requirements.txt`, and can be directly installed using `pip install -r requirements.txt`.
25+
`tHMM` requires Python >=3.10 and is built and managed with `uv <https://docs.astral.sh/uv/>`_.
26+
Once `uv` is installed, all required packages can be installed into a project-local
27+
virtual environment with ``uv sync``, run from the root of the repository.
28+
The package's dependencies are listed in ``pyproject.toml``.

0 commit comments

Comments
 (0)