Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added tasccoda example plots #527

Merged
merged 5 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 0 additions & 16 deletions pertpy/plot/_coda.py
Original file line number Diff line number Diff line change
Expand Up @@ -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!"
Expand Down Expand Up @@ -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!"
Expand Down Expand Up @@ -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!"
Expand Down Expand Up @@ -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!"
Expand Down Expand Up @@ -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!"
Expand Down Expand Up @@ -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!"
Expand Down
21 changes: 18 additions & 3 deletions pertpy/tools/_coda/_base_coda.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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",
Expand All @@ -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]
Expand Down
Loading