pertpy 0.10.0__py3-none-any.whl → 0.11.0__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 +1 -1
  13. pertpy/tools/_augur.py +106 -98
  14. pertpy/tools/_cinemaot.py +74 -114
  15. pertpy/tools/_coda/_base_coda.py +129 -145
  16. pertpy/tools/_coda/_sccoda.py +66 -69
  17. pertpy/tools/_coda/_tasccoda.py +71 -79
  18. pertpy/tools/_dialogue.py +48 -40
  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 -45
  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.0.dist-info}/METADATA +36 -20
  40. pertpy-0.11.0.dist-info/RECORD +58 -0
  41. {pertpy-0.10.0.dist-info → pertpy-0.11.0.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.0.dist-info}/WHEEL +0 -0
@@ -23,8 +23,8 @@ 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
@@ -423,80 +424,76 @@ class Sccoda(CompositionalModel2):
423
424
  *args,
424
425
  **kwargs,
425
426
  ):
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
- """
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
+ """ # noqa: D205
440
440
  return super().run_nuts(data, modality_key, num_samples, num_warmup, rng_key, copy, *args, **kwargs)
441
441
 
442
442
  run_nuts.__doc__ = CompositionalModel2.run_nuts.__doc__ + run_nuts.__doc__
443
443
 
444
444
  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
- """
445
+ """Examples:
446
+ >>> import pertpy as pt
447
+ >>> haber_cells = pt.dt.haber_2017_regions()
448
+ >>> sccoda = pt.tl.Sccoda()
449
+ >>> mdata = sccoda.load(haber_cells,
450
+ >>> type="cell_level",
451
+ >>> generate_sample_level=True,
452
+ >>> cell_type_identifier="cell_label",
453
+ >>> sample_identifier="batch",
454
+ >>> covariate_obs=["condition"])
455
+ >>> mdata = sccoda.prepare(mdata, formula="condition", reference_cell_type="Endocrine")
456
+ >>> sccoda.run_nuts(mdata, num_warmup=100, num_samples=1000, rng_key=42)
457
+ >>> credible_effects = sccoda.credible_effects(mdata).
458
+ """ # noqa: D205
460
459
  return super().credible_effects(data, modality_key, est_fdr)
461
460
 
462
461
  credible_effects.__doc__ = CompositionalModel2.credible_effects.__doc__ + credible_effects.__doc__
463
462
 
464
463
  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
- """
464
+ """Examples:
465
+ >>> import pertpy as pt
466
+ >>> haber_cells = pt.dt.haber_2017_regions()
467
+ >>> sccoda = pt.tl.Sccoda()
468
+ >>> mdata = sccoda.load(haber_cells,
469
+ >>> type="cell_level",
470
+ >>> generate_sample_level=True,
471
+ >>> cell_type_identifier="cell_label",
472
+ >>> sample_identifier="batch",
473
+ >>> covariate_obs=["condition"])
474
+ >>> mdata = sccoda.prepare(mdata, formula="condition", reference_cell_type="Endocrine")
475
+ >>> sccoda.run_nuts(mdata, num_warmup=100, num_samples=1000, rng_key=42)
476
+ >>> sccoda.summary(mdata).
477
+ """ # noqa: D205
480
478
  return super().summary(data, extended, modality_key, *args, **kwargs)
481
479
 
482
480
  summary.__doc__ = CompositionalModel2.summary.__doc__ + summary.__doc__
483
481
 
484
482
  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
- """
483
+ """Examples:
484
+ >>> import pertpy as pt
485
+ >>> haber_cells = pt.dt.haber_2017_regions()
486
+ >>> sccoda = pt.tl.Sccoda()
487
+ >>> mdata = sccoda.load(haber_cells,
488
+ >>> type="cell_level",
489
+ >>> generate_sample_level=True,
490
+ >>> cell_type_identifier="cell_label",
491
+ >>> sample_identifier="batch",
492
+ >>> covariate_obs=["condition"])
493
+ >>> mdata = sccoda.prepare(mdata, formula="condition", reference_cell_type="Endocrine")
494
+ >>> sccoda.run_nuts(mdata, num_warmup=100, num_samples=1000, rng_key=42)
495
+ >>> sccoda.set_fdr(mdata, est_fdr=0.4).
496
+ """ # noqa: D205
500
497
  return super().set_fdr(data, est_fdr, modality_key, *args, **kwargs)
501
498
 
502
499
  set_fdr.__doc__ = CompositionalModel2.set_fdr.__doc__ + set_fdr.__doc__
@@ -31,8 +31,7 @@ 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
@@ -594,84 +590,80 @@ class Tasccoda(CompositionalModel2):
594
590
  *args,
595
591
  **kwargs,
596
592
  ):
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
- """
593
+ """Examples:
594
+ >>> import pertpy as pt
595
+ >>> adata = pt.dt.tasccoda_example()
596
+ >>> tasccoda = pt.tl.Tasccoda()
597
+ >>> mdata = tasccoda.load(
598
+ >>> adata, type="sample_level",
599
+ >>> levels_agg=["Major_l1", "Major_l2", "Major_l3", "Major_l4", "Cluster"],
600
+ >>> key_added="lineage", add_level_name=True
601
+ >>> )
602
+ >>> mdata = tasccoda.prepare(
603
+ >>> mdata, formula="Health", reference_cell_type="automatic", tree_key="lineage", pen_args={"phi": 0}
604
+ >>> )
605
+ >>> tasccoda.run_nuts(mdata, num_samples=1000, num_warmup=100, rng_key=42).
606
+ """ # noqa: D205
612
607
  return super().run_nuts(data, modality_key, num_samples, num_warmup, rng_key, copy, *args, **kwargs)
613
608
 
614
609
  run_nuts.__doc__ = CompositionalModel2.run_nuts.__doc__ + run_nuts.__doc__
615
610
 
616
611
  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
- """
612
+ """Examples:
613
+ >>> import pertpy as pt
614
+ >>> adata = pt.dt.tasccoda_example()
615
+ >>> tasccoda = pt.tl.Tasccoda()
616
+ >>> mdata = tasccoda.load(
617
+ >>> adata, type="sample_level",
618
+ >>> levels_agg=["Major_l1", "Major_l2", "Major_l3", "Major_l4", "Cluster"],
619
+ >>> key_added="lineage", add_level_name=True
620
+ >>> )
621
+ >>> mdata = tasccoda.prepare(
622
+ >>> mdata, formula="Health", reference_cell_type="automatic", tree_key="lineage", pen_args={"phi": 0}
623
+ >>> )
624
+ >>> tasccoda.run_nuts(mdata, num_samples=1000, num_warmup=100, rng_key=42)
625
+ >>> tasccoda.summary(mdata).
626
+ """ # noqa: D205
633
627
  return super().summary(data, extended, modality_key, *args, **kwargs)
634
628
 
635
629
  summary.__doc__ = CompositionalModel2.summary.__doc__ + summary.__doc__
636
630
 
637
631
  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
- """
632
+ """Examples:
633
+ >>> import pertpy as pt
634
+ >>> adata = pt.dt.tasccoda_example()
635
+ >>> tasccoda = pt.tl.Tasccoda()
636
+ >>> mdata = tasccoda.load(
637
+ >>> adata, type="sample_level",
638
+ >>> levels_agg=["Major_l1", "Major_l2", "Major_l3", "Major_l4", "Cluster"],
639
+ >>> key_added="lineage", add_level_name=True
640
+ >>> )
641
+ >>> mdata = tasccoda.prepare(
642
+ >>> mdata, formula="Health", reference_cell_type="automatic", tree_key="lineage", pen_args={"phi": 0}
643
+ >>> )
644
+ >>> tasccoda.run_nuts(mdata, num_samples=1000, num_warmup=100, rng_key=42)
645
+ >>> tasccoda.credible_effects(mdata).
646
+ """ # noqa: D205
654
647
  return super().credible_effects(data, modality_key, est_fdr)
655
648
 
656
649
  credible_effects.__doc__ = CompositionalModel2.credible_effects.__doc__ + credible_effects.__doc__
657
650
 
658
651
  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
- """
652
+ """Examples:
653
+ >>> import pertpy as pt
654
+ >>> adata = pt.dt.tasccoda_example()
655
+ >>> tasccoda = pt.tl.Tasccoda()
656
+ >>> mdata = tasccoda.load(
657
+ >>> adata, type="sample_level",
658
+ >>> levels_agg=["Major_l1", "Major_l2", "Major_l3", "Major_l4", "Cluster"],
659
+ >>> key_added="lineage", add_level_name=True
660
+ >>> )
661
+ >>> mdata = tasccoda.prepare(
662
+ >>> mdata, formula="Health", reference_cell_type="automatic", tree_key="lineage", pen_args={"phi": 0}
663
+ >>> )
664
+ >>> tasccoda.run_nuts(mdata, num_samples=1000, num_warmup=100, rng_key=42)
665
+ >>> tasccoda.set_fdr(mdata, est_fdr=0.4).
666
+ """ # noqa: D205
675
667
  return super().set_fdr(data, est_fdr, modality_key, *args, **kwargs)
676
668
 
677
669
  set_fdr.__doc__ = CompositionalModel2.set_fdr.__doc__ + set_fdr.__doc__