Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/theislab/pertpy
Browse files Browse the repository at this point in the history
  • Loading branch information
Zethson committed Feb 20, 2024
2 parents 2d2d59b + b29d3a9 commit 1ff95f5
Showing 1 changed file with 48 additions and 17 deletions.
65 changes: 48 additions & 17 deletions pertpy/tools/_coda/_sccoda.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,11 @@ def load(
>>> import pertpy as pt
>>> haber_cells = pt.dt.haber_2017_regions()
>>> sccoda = pt.tl.Sccoda()
>>> mdata = sccoda.load(haber_cells, type="cell_level", generate_sample_level=True, cell_type_identifier="cell_label", \
sample_identifier="batch", covariate_obs=["condition"])
>>> mdata = sccoda.load(haber_cells,
>>> type="cell_level",
>>> generate_sample_level=True,
>>> cell_type_identifier="cell_label",
>>> sample_identifier="batch", covariate_obs=["condition"])
"""
if type == "cell_level":
if generate_sample_level:
Expand Down Expand Up @@ -144,8 +147,12 @@ def prepare(
>>> import pertpy as pt
>>> haber_cells = pt.dt.haber_2017_regions()
>>> sccoda = pt.tl.Sccoda()
>>> mdata = sccoda.load(haber_cells, type="cell_level", generate_sample_level=True, cell_type_identifier="cell_label", \
sample_identifier="batch", covariate_obs=["condition"])
>>> mdata = sccoda.load(haber_cells,
>>> type="cell_level",
>>> generate_sample_level=True,
>>> cell_type_identifier="cell_label",
>>> sample_identifier="batch",
>>> covariate_obs=["condition"])
>>> mdata = sccoda.prepare(mdata, formula="condition", reference_cell_type="Endocrine")
"""
if isinstance(data, MuData):
Expand Down Expand Up @@ -193,10 +200,14 @@ def set_init_mcmc_states(self, rng_key: None, ref_index: np.ndarray, sample_adat
>>> import pertpy as pt
>>> haber_cells = pt.dt.haber_2017_regions()
>>> sccoda = pt.tl.Sccoda()
>>> mdata = sccoda.load(haber_cells, type="cell_level", generate_sample_level=True, cell_type_identifier="cell_label", \
sample_identifier="batch", covariate_obs=["condition"])
>>> mdata = sccoda.load(haber_cells,
>>> type="cell_level",
>>> generate_sample_level=True,
>>> cell_type_identifier="cell_label",
>>> sample_identifier="batch",
>>> covariate_obs=["condition"])
>>> mdata = sccoda.prepare(mdata, formula="condition", reference_cell_type="Endocrine")
>>> adata = sccoda.set_init_mcmc_states(rng_key=42, ref_index=0, sample_adata=mdata['coda'])
>>> adata = sccoda.set_init_mcmc_states(rng_key=42, ref_index=0, sample_adata=mdata["coda"])
"""
# data dimensions
N, D = sample_adata.obsm["covariate_matrix"].shape
Expand Down Expand Up @@ -312,8 +323,12 @@ def make_arviz( # type: ignore
>>> import pertpy as pt
>>> haber_cells = pt.dt.haber_2017_regions()
>>> sccoda = pt.tl.Sccoda()
>>> mdata = sccoda.load(haber_cells, type="cell_level", generate_sample_level=True, cell_type_identifier="cell_label", \
sample_identifier="batch", covariate_obs=["condition"])
>>> mdata = sccoda.load(haber_cells,
>>> type="cell_level",
>>> generate_sample_level=True,
>>> cell_type_identifier="cell_label",
>>> sample_identifier="batch",
>>> covariate_obs=["condition"])
>>> mdata = sccoda.prepare(mdata, formula="condition", reference_cell_type="Endocrine")
>>> sccoda.run_nuts(mdata, num_warmup=100, num_samples=1000, rng_key=42)
>>> arviz_data = sccoda.make_arviz(mdata, num_prior_samples=100)
Expand Down Expand Up @@ -414,8 +429,12 @@ def run_nuts(
>>> import pertpy as pt
>>> haber_cells = pt.dt.haber_2017_regions()
>>> sccoda = pt.tl.Sccoda()
>>> mdata = sccoda.load(haber_cells, type="cell_level", generate_sample_level=True, cell_type_identifier="cell_label", \
sample_identifier="batch", covariate_obs=["condition"])
>>> mdata = sccoda.load(haber_cells,
>>> type="cell_level",
>>> generate_sample_level=True,
>>> cell_type_identifier="cell_label",
>>> sample_identifier="batch",
>>> covariate_obs=["condition"])
>>> mdata = sccoda.prepare(mdata, formula="condition", reference_cell_type="Endocrine")
>>> sccoda.run_nuts(mdata, num_warmup=100, num_samples=1000, rng_key=42)
"""
Expand All @@ -429,8 +448,12 @@ def credible_effects(self, data: AnnData | MuData, modality_key: str = "coda", e
>>> import pertpy as pt
>>> haber_cells = pt.dt.haber_2017_regions()
>>> sccoda = pt.tl.Sccoda()
>>> mdata = sccoda.load(haber_cells, type="cell_level", generate_sample_level=True, cell_type_identifier="cell_label", \
sample_identifier="batch", covariate_obs=["condition"])
>>> mdata = sccoda.load(haber_cells,
>>> type="cell_level",
>>> generate_sample_level=True,
>>> cell_type_identifier="cell_label",
>>> sample_identifier="batch",
>>> covariate_obs=["condition"])
>>> mdata = sccoda.prepare(mdata, formula="condition", reference_cell_type="Endocrine")
>>> sccoda.run_nuts(mdata, num_warmup=100, num_samples=1000, rng_key=42)
>>> credible_effects = sccoda.credible_effects(mdata)
Expand All @@ -445,8 +468,12 @@ def summary(self, data: AnnData | MuData, extended: bool = False, modality_key:
>>> import pertpy as pt
>>> haber_cells = pt.dt.haber_2017_regions()
>>> sccoda = pt.tl.Sccoda()
>>> mdata = sccoda.load(haber_cells, type="cell_level", generate_sample_level=True, cell_type_identifier="cell_label", \
sample_identifier="batch", covariate_obs=["condition"])
>>> mdata = sccoda.load(haber_cells,
>>> type="cell_level",
>>> generate_sample_level=True,
>>> cell_type_identifier="cell_label",
>>> sample_identifier="batch",
>>> covariate_obs=["condition"])
>>> mdata = sccoda.prepare(mdata, formula="condition", reference_cell_type="Endocrine")
>>> sccoda.run_nuts(mdata, num_warmup=100, num_samples=1000, rng_key=42)
>>> sccoda.summary(mdata)
Expand All @@ -461,8 +488,12 @@ def set_fdr(self, data: AnnData | MuData, est_fdr: float, modality_key: str = "c
>>> import pertpy as pt
>>> haber_cells = pt.dt.haber_2017_regions()
>>> sccoda = pt.tl.Sccoda()
>>> mdata = sccoda.load(haber_cells, type="cell_level", generate_sample_level=True, cell_type_identifier="cell_label", \
sample_identifier="batch", covariate_obs=["condition"])
>>> mdata = sccoda.load(haber_cells,
>>> type="cell_level",
>>> generate_sample_level=True,
>>> cell_type_identifier="cell_label",
>>> sample_identifier="batch",
>>> covariate_obs=["condition"])
>>> mdata = sccoda.prepare(mdata, formula="condition", reference_cell_type="Endocrine")
>>> sccoda.run_nuts(mdata, num_warmup=100, num_samples=1000, rng_key=42)
>>> sccoda.set_fdr(mdata, est_fdr=0.4)
Expand Down

0 comments on commit 1ff95f5

Please sign in to comment.