pertpy 0.10.0__py3-none-any.whl → 0.11.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. pertpy/__init__.py +5 -1
  2. pertpy/_doc.py +1 -3
  3. pertpy/_types.py +6 -0
  4. pertpy/data/_dataloader.py +68 -24
  5. pertpy/data/_datasets.py +9 -9
  6. pertpy/metadata/__init__.py +2 -1
  7. pertpy/metadata/_cell_line.py +133 -25
  8. pertpy/metadata/_look_up.py +13 -19
  9. pertpy/metadata/_moa.py +1 -1
  10. pertpy/preprocessing/_guide_rna.py +138 -44
  11. pertpy/preprocessing/_guide_rna_mixture.py +17 -19
  12. pertpy/tools/__init__.py +4 -3
  13. pertpy/tools/_augur.py +106 -98
  14. pertpy/tools/_cinemaot.py +74 -114
  15. pertpy/tools/_coda/_base_coda.py +134 -148
  16. pertpy/tools/_coda/_sccoda.py +69 -70
  17. pertpy/tools/_coda/_tasccoda.py +74 -80
  18. pertpy/tools/_dialogue.py +48 -41
  19. pertpy/tools/_differential_gene_expression/_base.py +21 -31
  20. pertpy/tools/_differential_gene_expression/_checks.py +4 -6
  21. pertpy/tools/_differential_gene_expression/_dge_comparison.py +5 -6
  22. pertpy/tools/_differential_gene_expression/_edger.py +6 -10
  23. pertpy/tools/_differential_gene_expression/_pydeseq2.py +1 -1
  24. pertpy/tools/_differential_gene_expression/_simple_tests.py +3 -3
  25. pertpy/tools/_differential_gene_expression/_statsmodels.py +8 -5
  26. pertpy/tools/_distances/_distance_tests.py +1 -2
  27. pertpy/tools/_distances/_distances.py +31 -46
  28. pertpy/tools/_enrichment.py +7 -22
  29. pertpy/tools/_milo.py +19 -15
  30. pertpy/tools/_mixscape.py +73 -75
  31. pertpy/tools/_perturbation_space/_clustering.py +4 -4
  32. pertpy/tools/_perturbation_space/_comparison.py +4 -4
  33. pertpy/tools/_perturbation_space/_discriminator_classifiers.py +83 -32
  34. pertpy/tools/_perturbation_space/_perturbation_space.py +10 -10
  35. pertpy/tools/_perturbation_space/_simple.py +12 -14
  36. pertpy/tools/_scgen/_scgen.py +16 -17
  37. pertpy/tools/_scgen/_scgenvae.py +2 -2
  38. pertpy/tools/_scgen/_utils.py +3 -1
  39. {pertpy-0.10.0.dist-info → pertpy-0.11.1.dist-info}/METADATA +42 -24
  40. pertpy-0.11.1.dist-info/RECORD +58 -0
  41. {pertpy-0.10.0.dist-info → pertpy-0.11.1.dist-info}/licenses/LICENSE +1 -0
  42. pertpy/tools/_kernel_pca.py +0 -50
  43. pertpy-0.10.0.dist-info/RECORD +0 -58
  44. {pertpy-0.10.0.dist-info → pertpy-0.11.1.dist-info}/WHEEL +0 -0
@@ -2,7 +2,6 @@ from __future__ import annotations
2
2
 
3
3
  from typing import TYPE_CHECKING, Literal
4
4
 
5
- import arviz as az
6
5
  import jax.numpy as jnp
7
6
  import numpy as np
8
7
  import numpyro as npy
@@ -17,14 +16,15 @@ from rich import print
17
16
  from pertpy.tools._coda._base_coda import CompositionalModel2, from_scanpy
18
17
 
19
18
  if TYPE_CHECKING:
19
+ import arviz as az
20
20
  import pandas as pd
21
21
 
22
22
  config.update("jax_enable_x64", True)
23
23
 
24
24
 
25
25
  class Sccoda(CompositionalModel2):
26
- """
27
- Statistical model for single-cell differential composition analysis with specification of a reference cell type.
26
+ r"""Statistical model for single-cell differential composition analysis with specification of a reference cell type.
27
+
28
28
  This is the standard scCODA model and recommended for all uses.
29
29
 
30
30
  The hierarchical formulation of the model for one sample is:
@@ -45,7 +45,6 @@ class Sccoda(CompositionalModel2):
45
45
 
46
46
  For further information, see `scCODA is a Bayesian model for compositional single-cell data analysis`
47
47
  (Büttner, Ostner et al., NatComms, 2021)
48
-
49
48
  """
50
49
 
51
50
  def __init__(self, *args, **kwargs):
@@ -83,7 +82,7 @@ class Sccoda(CompositionalModel2):
83
82
  modality_key_2: Key to the aggregated sample-level AnnData object in the MuData object.
84
83
 
85
84
  Returns:
86
- MuData: MuData object with cell-level AnnData (`mudata[modality_key_1]`) and aggregated sample-level AnnData (`mudata[modality_key_2]`).
85
+ :class:`mudata.MuData` object with cell-level AnnData (`mudata[modality_key_1]`) and aggregated sample-level AnnData (`mudata[modality_key_2]`).
87
86
 
88
87
  Examples:
89
88
  >>> import pertpy as pt
@@ -108,8 +107,12 @@ class Sccoda(CompositionalModel2):
108
107
  else:
109
108
  adata_coda = AnnData()
110
109
  mdata = MuData({modality_key_1: adata, modality_key_2: adata_coda})
110
+ mdata.pull_obs()
111
+ mdata.pull_var()
111
112
  else:
112
113
  mdata = MuData({modality_key_1: AnnData(), modality_key_2: adata})
114
+ mdata.pull_obs()
115
+ mdata.pull_var()
113
116
  return mdata
114
117
 
115
118
  def prepare(
@@ -184,8 +187,7 @@ class Sccoda(CompositionalModel2):
184
187
  return adata
185
188
 
186
189
  def set_init_mcmc_states(self, rng_key: None, ref_index: np.ndarray, sample_adata: AnnData) -> AnnData: # type: ignore
187
- """
188
- Sets initial MCMC state values for scCODA model
190
+ """Sets initial MCMC state values for scCODA model.
189
191
 
190
192
  Args:
191
193
  rng_key: RNG value to be set
@@ -237,8 +239,7 @@ class Sccoda(CompositionalModel2):
237
239
  ref_index,
238
240
  sample_adata: AnnData,
239
241
  ):
240
- """
241
- Implements scCODA model in numpyro
242
+ """Implements scCODA model in numpyro.
242
243
 
243
244
  Args:
244
245
  counts: Count data array
@@ -306,7 +307,7 @@ class Sccoda(CompositionalModel2):
306
307
  num_prior_samples: int = 500,
307
308
  use_posterior_predictive: bool = True,
308
309
  ) -> az.InferenceData:
309
- """Creates arviz object from model results for MCMC diagnosis
310
+ """Creates arviz object from model results for MCMC diagnosis.
310
311
 
311
312
  Args:
312
313
  data: AnnData object or MuData object.
@@ -316,7 +317,7 @@ class Sccoda(CompositionalModel2):
316
317
  use_posterior_predictive: If True, the posterior predictive will be calculated.
317
318
 
318
319
  Returns:
319
- az.InferenceData: arviz_data with all MCMC information
320
+ :class:`arviz.InferenceData`: arviz_data with all MCMC information
320
321
 
321
322
  Examples:
322
323
  >>> import pertpy as pt
@@ -405,6 +406,8 @@ class Sccoda(CompositionalModel2):
405
406
  else:
406
407
  prior = None
407
408
 
409
+ import arviz as az
410
+
408
411
  # Create arviz object
409
412
  arviz_data = az.from_numpyro(
410
413
  self.mcmc, prior=prior, posterior_predictive=posterior_predictive, dims=dims, coords=coords
@@ -423,80 +426,76 @@ class Sccoda(CompositionalModel2):
423
426
  *args,
424
427
  **kwargs,
425
428
  ):
426
- """
427
- Examples:
428
- >>> import pertpy as pt
429
- >>> haber_cells = pt.dt.haber_2017_regions()
430
- >>> sccoda = pt.tl.Sccoda()
431
- >>> mdata = sccoda.load(haber_cells,
432
- >>> type="cell_level",
433
- >>> generate_sample_level=True,
434
- >>> cell_type_identifier="cell_label",
435
- >>> sample_identifier="batch",
436
- >>> covariate_obs=["condition"])
437
- >>> mdata = sccoda.prepare(mdata, formula="condition", reference_cell_type="Endocrine")
438
- >>> sccoda.run_nuts(mdata, num_warmup=100, num_samples=1000, rng_key=42)
439
- """
429
+ """Examples:
430
+ >>> import pertpy as pt
431
+ >>> haber_cells = pt.dt.haber_2017_regions()
432
+ >>> sccoda = pt.tl.Sccoda()
433
+ >>> mdata = sccoda.load(haber_cells,
434
+ >>> type="cell_level",
435
+ >>> generate_sample_level=True,
436
+ >>> cell_type_identifier="cell_label",
437
+ >>> sample_identifier="batch",
438
+ >>> covariate_obs=["condition"])
439
+ >>> mdata = sccoda.prepare(mdata, formula="condition", reference_cell_type="Endocrine")
440
+ >>> sccoda.run_nuts(mdata, num_warmup=100, num_samples=1000, rng_key=42).
441
+ """ # noqa: D205
440
442
  return super().run_nuts(data, modality_key, num_samples, num_warmup, rng_key, copy, *args, **kwargs)
441
443
 
442
444
  run_nuts.__doc__ = CompositionalModel2.run_nuts.__doc__ + run_nuts.__doc__
443
445
 
444
446
  def credible_effects(self, data: AnnData | MuData, modality_key: str = "coda", est_fdr: float = None) -> pd.Series:
445
- """
446
- Examples:
447
- >>> import pertpy as pt
448
- >>> haber_cells = pt.dt.haber_2017_regions()
449
- >>> sccoda = pt.tl.Sccoda()
450
- >>> mdata = sccoda.load(haber_cells,
451
- >>> type="cell_level",
452
- >>> generate_sample_level=True,
453
- >>> cell_type_identifier="cell_label",
454
- >>> sample_identifier="batch",
455
- >>> covariate_obs=["condition"])
456
- >>> mdata = sccoda.prepare(mdata, formula="condition", reference_cell_type="Endocrine")
457
- >>> sccoda.run_nuts(mdata, num_warmup=100, num_samples=1000, rng_key=42)
458
- >>> credible_effects = sccoda.credible_effects(mdata)
459
- """
447
+ """Examples:
448
+ >>> import pertpy as pt
449
+ >>> haber_cells = pt.dt.haber_2017_regions()
450
+ >>> sccoda = pt.tl.Sccoda()
451
+ >>> mdata = sccoda.load(haber_cells,
452
+ >>> type="cell_level",
453
+ >>> generate_sample_level=True,
454
+ >>> cell_type_identifier="cell_label",
455
+ >>> sample_identifier="batch",
456
+ >>> covariate_obs=["condition"])
457
+ >>> mdata = sccoda.prepare(mdata, formula="condition", reference_cell_type="Endocrine")
458
+ >>> sccoda.run_nuts(mdata, num_warmup=100, num_samples=1000, rng_key=42)
459
+ >>> credible_effects = sccoda.credible_effects(mdata).
460
+ """ # noqa: D205
460
461
  return super().credible_effects(data, modality_key, est_fdr)
461
462
 
462
463
  credible_effects.__doc__ = CompositionalModel2.credible_effects.__doc__ + credible_effects.__doc__
463
464
 
464
465
  def summary(self, data: AnnData | MuData, extended: bool = False, modality_key: str = "coda", *args, **kwargs):
465
- """
466
- Examples:
467
- >>> import pertpy as pt
468
- >>> haber_cells = pt.dt.haber_2017_regions()
469
- >>> sccoda = pt.tl.Sccoda()
470
- >>> mdata = sccoda.load(haber_cells,
471
- >>> type="cell_level",
472
- >>> generate_sample_level=True,
473
- >>> cell_type_identifier="cell_label",
474
- >>> sample_identifier="batch",
475
- >>> covariate_obs=["condition"])
476
- >>> mdata = sccoda.prepare(mdata, formula="condition", reference_cell_type="Endocrine")
477
- >>> sccoda.run_nuts(mdata, num_warmup=100, num_samples=1000, rng_key=42)
478
- >>> sccoda.summary(mdata)
479
- """
466
+ """Examples:
467
+ >>> import pertpy as pt
468
+ >>> haber_cells = pt.dt.haber_2017_regions()
469
+ >>> sccoda = pt.tl.Sccoda()
470
+ >>> mdata = sccoda.load(haber_cells,
471
+ >>> type="cell_level",
472
+ >>> generate_sample_level=True,
473
+ >>> cell_type_identifier="cell_label",
474
+ >>> sample_identifier="batch",
475
+ >>> covariate_obs=["condition"])
476
+ >>> mdata = sccoda.prepare(mdata, formula="condition", reference_cell_type="Endocrine")
477
+ >>> sccoda.run_nuts(mdata, num_warmup=100, num_samples=1000, rng_key=42)
478
+ >>> sccoda.summary(mdata).
479
+ """ # noqa: D205
480
480
  return super().summary(data, extended, modality_key, *args, **kwargs)
481
481
 
482
482
  summary.__doc__ = CompositionalModel2.summary.__doc__ + summary.__doc__
483
483
 
484
484
  def set_fdr(self, data: AnnData | MuData, est_fdr: float, modality_key: str = "coda", *args, **kwargs):
485
- """
486
- Examples:
487
- >>> import pertpy as pt
488
- >>> haber_cells = pt.dt.haber_2017_regions()
489
- >>> sccoda = pt.tl.Sccoda()
490
- >>> mdata = sccoda.load(haber_cells,
491
- >>> type="cell_level",
492
- >>> generate_sample_level=True,
493
- >>> cell_type_identifier="cell_label",
494
- >>> sample_identifier="batch",
495
- >>> covariate_obs=["condition"])
496
- >>> mdata = sccoda.prepare(mdata, formula="condition", reference_cell_type="Endocrine")
497
- >>> sccoda.run_nuts(mdata, num_warmup=100, num_samples=1000, rng_key=42)
498
- >>> sccoda.set_fdr(mdata, est_fdr=0.4)
499
- """
485
+ """Examples:
486
+ >>> import pertpy as pt
487
+ >>> haber_cells = pt.dt.haber_2017_regions()
488
+ >>> sccoda = pt.tl.Sccoda()
489
+ >>> mdata = sccoda.load(haber_cells,
490
+ >>> type="cell_level",
491
+ >>> generate_sample_level=True,
492
+ >>> cell_type_identifier="cell_label",
493
+ >>> sample_identifier="batch",
494
+ >>> covariate_obs=["condition"])
495
+ >>> mdata = sccoda.prepare(mdata, formula="condition", reference_cell_type="Endocrine")
496
+ >>> sccoda.run_nuts(mdata, num_warmup=100, num_samples=1000, rng_key=42)
497
+ >>> sccoda.set_fdr(mdata, est_fdr=0.4).
498
+ """ # noqa: D205
500
499
  return super().set_fdr(data, est_fdr, modality_key, *args, **kwargs)
501
500
 
502
501
  set_fdr.__doc__ = CompositionalModel2.set_fdr.__doc__ + set_fdr.__doc__
@@ -2,7 +2,6 @@ from __future__ import annotations
2
2
 
3
3
  from typing import TYPE_CHECKING, Literal
4
4
 
5
- import arviz as az
6
5
  import jax.numpy as jnp
7
6
  import numpy as np
8
7
  import numpyro as npy
@@ -25,14 +24,14 @@ from pertpy.tools._coda._base_coda import (
25
24
  )
26
25
 
27
26
  if TYPE_CHECKING:
27
+ import arviz as az
28
28
  import pandas as pd
29
29
 
30
30
  config.update("jax_enable_x64", True)
31
31
 
32
32
 
33
33
  class Tasccoda(CompositionalModel2):
34
- """
35
- Statistical model for tree-aggregated differential composition analysis (tascCODA, Ostner et al., 2021).
34
+ r"""Statistical model for tree-aggregated differential composition analysis (tascCODA, Ostner et al., 2021).
36
35
 
37
36
  The hierarchical formulation of the model for one sample is:
38
37
 
@@ -99,7 +98,7 @@ class Tasccoda(CompositionalModel2):
99
98
  modality_key_2: Key to the aggregated sample-level AnnData object in the MuData object.
100
99
 
101
100
  Returns:
102
- MuData: MuData object with cell-level AnnData (`mudata[modality_key_1]`) and aggregated sample-level AnnData (`mudata[modality_key_2]`).
101
+ :class:`mudata.MuData` object with cell-level AnnData (`mudata[modality_key_1]`) and aggregated sample-level AnnData (`mudata[modality_key_2]`).
103
102
 
104
103
  Examples:
105
104
  >>> import pertpy as pt
@@ -111,7 +110,6 @@ class Tasccoda(CompositionalModel2):
111
110
  >>> key_added="lineage", add_level_name=True
112
111
  >>> )
113
112
  """
114
-
115
113
  if type == "cell_level":
116
114
  adata_coda = from_scanpy(
117
115
  adata=adata,
@@ -198,9 +196,8 @@ class Tasccoda(CompositionalModel2):
198
196
  if tree_key is None:
199
197
  raise ValueError("Please specify the key in .uns that contains the tree structure!")
200
198
 
201
- # Scoped import due to installation issues
202
199
  try:
203
- import ete3 as ete
200
+ import ete4 as ete
204
201
  except ImportError:
205
202
  raise ImportError(
206
203
  "To use tasccoda please install additional dependencies as `pip install pertpy[coda]`"
@@ -236,7 +233,7 @@ class Tasccoda(CompositionalModel2):
236
233
 
237
234
  # number of leaves for each internal node (important for aggregation penalty lambda_1)
238
235
  if "node_leaves" not in pen_args:
239
- node_leaves = [len(n.get_leaves()) for n in phy_tree.idx_dict.values()]
236
+ node_leaves = [len(n.leaves()) for n in phy_tree.idx_dict.values()]
240
237
  node_leaves.reverse()
241
238
  pen_args["node_leaves"] = np.delete(np.array(node_leaves[:-1]), refs)
242
239
 
@@ -245,7 +242,7 @@ class Tasccoda(CompositionalModel2):
245
242
  # Collapse singularities in the tree
246
243
  phy_tree = collapse_singularities_2(adata.uns[tree_key])
247
244
 
248
- node_names = [n.name for n in phy_tree.iter_descendants()]
245
+ node_names = [n.name for n in phy_tree.descendants()]
249
246
 
250
247
  # Get ancestor matrix
251
248
  A, T = get_a_2(phy_tree, leaf_order=adata.var.index.tolist(), node_order=node_names)
@@ -256,7 +253,7 @@ class Tasccoda(CompositionalModel2):
256
253
  # Ancestors of reference are a reference, too!
257
254
  # Get names of reference nodes
258
255
  reference_cell_type = adata.uns["scCODA_params"]["reference_cell_type"]
259
- ref_nodes = [n.name for n in phy_tree.search_nodes(name=reference_cell_type)[0].get_ancestors()[:-1]]
256
+ ref_nodes = [n.name for n in list(next(phy_tree.search_nodes(name=reference_cell_type)).ancestors())[:-1]]
260
257
  ref_nodes = [reference_cell_type] + ref_nodes
261
258
  adata.uns["scCODA_params"]["reference_nodes"] = ref_nodes
262
259
 
@@ -267,12 +264,12 @@ class Tasccoda(CompositionalModel2):
267
264
 
268
265
  # number of leaves for each internal node (important for aggregation penalty lambda_1)
269
266
  if "node_leaves" not in pen_args:
270
- node_leaves = [len(n.get_leaves()) for n in phy_tree.iter_descendants()]
267
+ node_leaves = [len(list(n.leaves())) for n in phy_tree.descendants()]
271
268
  pen_args["node_leaves"] = np.delete(np.array(node_leaves), ref_idxs)
272
269
 
273
270
  # No valid tree structure
274
271
  else:
275
- raise ValueError("Tree structure is not a toytree or ete3 tree object")
272
+ raise ValueError("Tree structure is not a toytree or ete4 tree object")
276
273
 
277
274
  # Default spike-and-slab LASSO parameters
278
275
  if "lambda_0" not in pen_args:
@@ -309,8 +306,7 @@ class Tasccoda(CompositionalModel2):
309
306
  return adata
310
307
 
311
308
  def set_init_mcmc_states(self, rng_key: None, ref_index: np.ndarray, sample_adata: AnnData) -> AnnData: # type: ignore
312
- """
313
- Sets initial MCMC state values for tascCODA model
309
+ """Sets initial MCMC state values for tascCODA model.
314
310
 
315
311
  Args:
316
312
  rng_key: RNG value to be set
@@ -387,7 +383,7 @@ class Tasccoda(CompositionalModel2):
387
383
  ref_index: np.ndarray,
388
384
  sample_adata: AnnData,
389
385
  ):
390
- """Implements tascCODA model in numpyro
386
+ """Implements tascCODA model in numpyro.
391
387
 
392
388
  Args:
393
389
  counts: Count data array
@@ -472,7 +468,7 @@ class Tasccoda(CompositionalModel2):
472
468
  num_prior_samples: int = 500,
473
469
  use_posterior_predictive: bool = True,
474
470
  ) -> az.InferenceData:
475
- """Creates arviz object from model results for MCMC diagnosis
471
+ """Creates arviz object from model results for MCMC diagnosis.
476
472
 
477
473
  Args:
478
474
  data: AnnData object or MuData object.
@@ -482,7 +478,7 @@ class Tasccoda(CompositionalModel2):
482
478
  use_posterior_predictive: If True, the posterior predictive will be calculated.
483
479
 
484
480
  Returns:
485
- arviz.InferenceData: arviz_data
481
+ :class:`arviz.InferenceData`: arviz_data
486
482
 
487
483
  Examples:
488
484
  >>> import pertpy as pt
@@ -576,6 +572,8 @@ class Tasccoda(CompositionalModel2):
576
572
  else:
577
573
  prior = None
578
574
 
575
+ import arviz as az
576
+
579
577
  # Create arviz object
580
578
  arviz_data = az.from_numpyro(
581
579
  self.mcmc, prior=prior, posterior_predictive=posterior_predictive, dims=dims, coords=coords
@@ -594,84 +592,80 @@ class Tasccoda(CompositionalModel2):
594
592
  *args,
595
593
  **kwargs,
596
594
  ):
597
- """
598
- Examples:
599
- >>> import pertpy as pt
600
- >>> adata = pt.dt.tasccoda_example()
601
- >>> tasccoda = pt.tl.Tasccoda()
602
- >>> mdata = tasccoda.load(
603
- >>> adata, type="sample_level",
604
- >>> levels_agg=["Major_l1", "Major_l2", "Major_l3", "Major_l4", "Cluster"],
605
- >>> key_added="lineage", add_level_name=True
606
- >>> )
607
- >>> mdata = tasccoda.prepare(
608
- >>> mdata, formula="Health", reference_cell_type="automatic", tree_key="lineage", pen_args={"phi": 0}
609
- >>> )
610
- >>> tasccoda.run_nuts(mdata, num_samples=1000, num_warmup=100, rng_key=42)
611
- """
595
+ """Examples:
596
+ >>> import pertpy as pt
597
+ >>> adata = pt.dt.tasccoda_example()
598
+ >>> tasccoda = pt.tl.Tasccoda()
599
+ >>> mdata = tasccoda.load(
600
+ >>> adata, type="sample_level",
601
+ >>> levels_agg=["Major_l1", "Major_l2", "Major_l3", "Major_l4", "Cluster"],
602
+ >>> key_added="lineage", add_level_name=True
603
+ >>> )
604
+ >>> mdata = tasccoda.prepare(
605
+ >>> mdata, formula="Health", reference_cell_type="automatic", tree_key="lineage", pen_args={"phi": 0}
606
+ >>> )
607
+ >>> tasccoda.run_nuts(mdata, num_samples=1000, num_warmup=100, rng_key=42).
608
+ """ # noqa: D205
612
609
  return super().run_nuts(data, modality_key, num_samples, num_warmup, rng_key, copy, *args, **kwargs)
613
610
 
614
611
  run_nuts.__doc__ = CompositionalModel2.run_nuts.__doc__ + run_nuts.__doc__
615
612
 
616
613
  def summary(self, data: AnnData | MuData, extended: bool = False, modality_key: str = "coda", *args, **kwargs):
617
- """
618
- Examples:
619
- >>> import pertpy as pt
620
- >>> adata = pt.dt.tasccoda_example()
621
- >>> tasccoda = pt.tl.Tasccoda()
622
- >>> mdata = tasccoda.load(
623
- >>> adata, type="sample_level",
624
- >>> levels_agg=["Major_l1", "Major_l2", "Major_l3", "Major_l4", "Cluster"],
625
- >>> key_added="lineage", add_level_name=True
626
- >>> )
627
- >>> mdata = tasccoda.prepare(
628
- >>> mdata, formula="Health", reference_cell_type="automatic", tree_key="lineage", pen_args={"phi": 0}
629
- >>> )
630
- >>> tasccoda.run_nuts(mdata, num_samples=1000, num_warmup=100, rng_key=42)
631
- >>> tasccoda.summary(mdata)
632
- """
614
+ """Examples:
615
+ >>> import pertpy as pt
616
+ >>> adata = pt.dt.tasccoda_example()
617
+ >>> tasccoda = pt.tl.Tasccoda()
618
+ >>> mdata = tasccoda.load(
619
+ >>> adata, type="sample_level",
620
+ >>> levels_agg=["Major_l1", "Major_l2", "Major_l3", "Major_l4", "Cluster"],
621
+ >>> key_added="lineage", add_level_name=True
622
+ >>> )
623
+ >>> mdata = tasccoda.prepare(
624
+ >>> mdata, formula="Health", reference_cell_type="automatic", tree_key="lineage", pen_args={"phi": 0}
625
+ >>> )
626
+ >>> tasccoda.run_nuts(mdata, num_samples=1000, num_warmup=100, rng_key=42)
627
+ >>> tasccoda.summary(mdata).
628
+ """ # noqa: D205
633
629
  return super().summary(data, extended, modality_key, *args, **kwargs)
634
630
 
635
631
  summary.__doc__ = CompositionalModel2.summary.__doc__ + summary.__doc__
636
632
 
637
633
  def credible_effects(self, data: AnnData | MuData, modality_key: str = "coda", est_fdr: float = None) -> pd.Series:
638
- """
639
- Examples:
640
- >>> import pertpy as pt
641
- >>> adata = pt.dt.tasccoda_example()
642
- >>> tasccoda = pt.tl.Tasccoda()
643
- >>> mdata = tasccoda.load(
644
- >>> adata, type="sample_level",
645
- >>> levels_agg=["Major_l1", "Major_l2", "Major_l3", "Major_l4", "Cluster"],
646
- >>> key_added="lineage", add_level_name=True
647
- >>> )
648
- >>> mdata = tasccoda.prepare(
649
- >>> mdata, formula="Health", reference_cell_type="automatic", tree_key="lineage", pen_args={"phi": 0}
650
- >>> )
651
- >>> tasccoda.run_nuts(mdata, num_samples=1000, num_warmup=100, rng_key=42)
652
- >>> tasccoda.credible_effects(mdata)
653
- """
634
+ """Examples:
635
+ >>> import pertpy as pt
636
+ >>> adata = pt.dt.tasccoda_example()
637
+ >>> tasccoda = pt.tl.Tasccoda()
638
+ >>> mdata = tasccoda.load(
639
+ >>> adata, type="sample_level",
640
+ >>> levels_agg=["Major_l1", "Major_l2", "Major_l3", "Major_l4", "Cluster"],
641
+ >>> key_added="lineage", add_level_name=True
642
+ >>> )
643
+ >>> mdata = tasccoda.prepare(
644
+ >>> mdata, formula="Health", reference_cell_type="automatic", tree_key="lineage", pen_args={"phi": 0}
645
+ >>> )
646
+ >>> tasccoda.run_nuts(mdata, num_samples=1000, num_warmup=100, rng_key=42)
647
+ >>> tasccoda.credible_effects(mdata).
648
+ """ # noqa: D205
654
649
  return super().credible_effects(data, modality_key, est_fdr)
655
650
 
656
651
  credible_effects.__doc__ = CompositionalModel2.credible_effects.__doc__ + credible_effects.__doc__
657
652
 
658
653
  def set_fdr(self, data: AnnData | MuData, est_fdr: float, modality_key: str = "coda", *args, **kwargs):
659
- """
660
- Examples:
661
- >>> import pertpy as pt
662
- >>> adata = pt.dt.tasccoda_example()
663
- >>> tasccoda = pt.tl.Tasccoda()
664
- >>> mdata = tasccoda.load(
665
- >>> adata, type="sample_level",
666
- >>> levels_agg=["Major_l1", "Major_l2", "Major_l3", "Major_l4", "Cluster"],
667
- >>> key_added="lineage", add_level_name=True
668
- >>> )
669
- >>> mdata = tasccoda.prepare(
670
- >>> mdata, formula="Health", reference_cell_type="automatic", tree_key="lineage", pen_args={"phi": 0}
671
- >>> )
672
- >>> tasccoda.run_nuts(mdata, num_samples=1000, num_warmup=100, rng_key=42)
673
- >>> tasccoda.set_fdr(mdata, est_fdr=0.4)
674
- """
654
+ """Examples:
655
+ >>> import pertpy as pt
656
+ >>> adata = pt.dt.tasccoda_example()
657
+ >>> tasccoda = pt.tl.Tasccoda()
658
+ >>> mdata = tasccoda.load(
659
+ >>> adata, type="sample_level",
660
+ >>> levels_agg=["Major_l1", "Major_l2", "Major_l3", "Major_l4", "Cluster"],
661
+ >>> key_added="lineage", add_level_name=True
662
+ >>> )
663
+ >>> mdata = tasccoda.prepare(
664
+ >>> mdata, formula="Health", reference_cell_type="automatic", tree_key="lineage", pen_args={"phi": 0}
665
+ >>> )
666
+ >>> tasccoda.run_nuts(mdata, num_samples=1000, num_warmup=100, rng_key=42)
667
+ >>> tasccoda.set_fdr(mdata, est_fdr=0.4).
668
+ """ # noqa: D205
675
669
  return super().set_fdr(data, est_fdr, modality_key, *args, **kwargs)
676
670
 
677
671
  set_fdr.__doc__ = CompositionalModel2.set_fdr.__doc__ + set_fdr.__doc__