diff --git a/docs/_static/docstring_previews/tasccoda_draw_effects.png b/docs/_static/docstring_previews/tasccoda_draw_effects.png new file mode 100644 index 00000000..db91633b Binary files /dev/null and b/docs/_static/docstring_previews/tasccoda_draw_effects.png differ diff --git a/docs/_static/docstring_previews/tasccoda_draw_tree.png b/docs/_static/docstring_previews/tasccoda_draw_tree.png new file mode 100644 index 00000000..ee6f61ee Binary files /dev/null and b/docs/_static/docstring_previews/tasccoda_draw_tree.png differ diff --git a/docs/_static/docstring_previews/tasccoda_effects_umap.png b/docs/_static/docstring_previews/tasccoda_effects_umap.png new file mode 100644 index 00000000..1e493b31 Binary files /dev/null and b/docs/_static/docstring_previews/tasccoda_effects_umap.png differ diff --git a/pertpy/plot/_coda.py b/pertpy/plot/_coda.py index 51059671..492a1f82 100644 --- a/pertpy/plot/_coda.py +++ b/pertpy/plot/_coda.py @@ -112,9 +112,6 @@ def stacked_barplot( # pragma: no cover >>> mdata = sccoda.load(haber_cells, type="cell_level", generate_sample_level=True, cell_type_identifier="cell_label", \ sample_identifier="batch", covariate_obs=["condition"]) >>> sccoda.plot_stacked_barplot(mdata, feature_name="samples") - - Preview: - .. image:: ../_static/docstring_previews/sccoda_stacked_barplot.png """ warnings.warn( "This function is deprecated and will be removed in pertpy 0.8.0!" @@ -188,9 +185,6 @@ def effects_barplot( # pragma: no cover >>> mdata = sccoda.prepare(mdata, formula="condition", reference_cell_type="Endocrine") >>> sccoda.run_nuts(mdata, num_warmup=100, num_samples=1000, rng_key=42) >>> sccoda.plot_effects_barplot(mdata) - - Preview: - .. image:: ../_static/docstring_previews/sccoda_effects_barplot.png """ warnings.warn( "This function is deprecated and will be removed in pertpy 0.8.0!" @@ -268,9 +262,6 @@ def boxplots( # pragma: no cover >>> mdata = sccoda.load(haber_cells, type="cell_level", generate_sample_level=True, cell_type_identifier="cell_label", \ sample_identifier="batch", covariate_obs=["condition"]) >>> sccoda.plot_boxplots(mdata, feature_name="condition", add_dots=True) - - Preview: - .. image:: ../_static/docstring_previews/sccoda_boxplots.png """ warnings.warn( "This function is deprecated and will be removed in pertpy 0.8.0!" @@ -341,9 +332,6 @@ def rel_abundance_dispersion_plot( # pragma: no cover >>> mdata = sccoda.prepare(mdata, formula="condition", reference_cell_type="Endocrine") >>> sccoda.run_nuts(mdata, num_warmup=100, num_samples=1000, rng_key=42) >>> sccoda.plot_rel_abundance_dispersion_plot(mdata) - - Preview: - .. image:: ../_static/docstring_previews/sccoda_rel_abundance_dispersion_plot.png """ warnings.warn( "This function is deprecated and will be removed in pertpy 0.8.0!" @@ -512,8 +500,6 @@ def draw_effects( # pragma: no cover >>> ) >>> tasccoda.run_nuts(mdata, num_samples=1000, num_warmup=100, rng_key=42) >>> tasccoda.plot_draw_effects(mdata, covariate="Health[T.Inflamed]", tree="lineage") - - Preview: #TODO: Add preview """ warnings.warn( "This function is deprecated and will be removed in pertpy 0.8.0!" @@ -603,8 +589,6 @@ def effects_umap( # pragma: no cover >>> "effect_df_condition[T.Hpoly.Day10]"], >>> cluster_key="nsbm_level_1", >>> ) - - Preview: #TODO: Add preview """ warnings.warn( "This function is deprecated and will be removed in pertpy 0.8.0!" diff --git a/pertpy/tools/_coda/_base_coda.py b/pertpy/tools/_coda/_base_coda.py index b7a68e11..03b00e55 100644 --- a/pertpy/tools/_coda/_base_coda.py +++ b/pertpy/tools/_coda/_base_coda.py @@ -1864,6 +1864,9 @@ def plot_draw_tree( # pragma: no cover >>> ) >>> tasccoda.run_nuts(mdata, num_samples=1000, num_warmup=100, rng_key=42) >>> tasccoda.plot_draw_tree(mdata, tree="lineage") + + Preview: + .. image:: /_static/docstring_previews/tasccoda_draw_tree.png """ try: from ete3 import CircleFace, NodeStyle, TextFace, Tree, TreeStyle, faces @@ -1954,7 +1957,10 @@ def plot_draw_effects( # pragma: no cover >>> mdata, formula="Health", reference_cell_type="automatic", tree_key="lineage", pen_args={"phi": 0} >>> ) >>> tasccoda.run_nuts(mdata, num_samples=1000, num_warmup=100, rng_key=42) - >>> pt.pl.coda.draw_effects(mdata, covariate="Health[T.Inflamed]", tree="lineage") + >>> tasccoda.plot_draw_effects(mdata, covariate="Health[T.Inflamed]", tree="lineage") + + Preview: + .. image:: /_static/docstring_previews/tasccoda_draw_effects.png """ try: from ete3 import CircleFace, NodeStyle, TextFace, Tree, TreeStyle, faces @@ -2124,15 +2130,17 @@ def plot_effects_umap( # pragma: no cover Examples: Example with tascCODA: >>> import pertpy as pt + >>> import scanpy as sc >>> import schist >>> adata = pt.dt.haber_2017_regions() - >>> schist.inference.nested_model(adata, samples=100, random_seed=5678) + >>> sc.pp.neighbors(adata) + >>> schist.inference.nested_model(adata, n_init=100, random_seed=5678) >>> tasccoda_model = pt.tl.Tasccoda() >>> tasccoda_data = tasccoda_model.load(adata, type="cell_level", >>> cell_type_identifier="nsbm_level_1", >>> sample_identifier="batch", covariate_obs=["condition"], >>> levels_orig=["nsbm_level_4", "nsbm_level_3", "nsbm_level_2", "nsbm_level_1"], - >>> add_level_name=True)sccoda = pt.tl.Sccoda() + >>> add_level_name=True) >>> tasccoda_model.prepare( >>> tasccoda_data, >>> modality_key="coda", @@ -2144,12 +2152,19 @@ def plot_effects_umap( # pragma: no cover >>> tasccoda_model.run_nuts( ... tasccoda_data, modality_key="coda", rng_key=1234, num_samples=10000, num_warmup=1000 ... ) + >>> tasccoda_model.run_nuts( + ... tasccoda_data, modality_key="coda", rng_key=1234, num_samples=10000, num_warmup=1000 + ... ) + >>> sc.tl.umap(tasccoda_data["rna"]) >>> tasccoda_model.plot_effects_umap(tasccoda_data, >>> effect_name=["effect_df_condition[T.Salmonella]", >>> "effect_df_condition[T.Hpoly.Day3]", >>> "effect_df_condition[T.Hpoly.Day10]"], >>> cluster_key="nsbm_level_1", >>> ) + + Preview: + .. image:: /_static/docstring_previews/tasccoda_effects_umap.png """ # TODO: Add effect_name parameter and cluster_key and test the example data_rna = data[modality_key_1]