Plotting¶
ROI Visualization functions¶
cell_map¶
-
spatialtis.plotting.
cell_map
(adata, query, geom='shape', selected_types=None, type_key=None, shape_key=None, centroid_key=None, size=None, title=None, palette=None, display=None, save=None, return_plot=False)[source]¶ (bokeh) Visualize cells in ROI
- Parameters
adata (anndata._core.anndata.AnnData) – AnnData object for plotting
query (Dict) – A Dict use to select which ROI to display, eg: {“Patients”: “Patient 1”, “ROI”: “ROI3”}, “Patients” and “ROI” are keys in AnnData.obs
geom (str) – “shape” or “point”
selected_types (Optional[Sequence]) – Select interested cell types to perform analysis
type_key (Optional[str]) – The key to store cell types in AnnData.obs (Default: spatialtis.CONFIG.CELL_TYPE_KEY)
shape_key (Optional[str]) – The key to store cell shape in AnnData.obs (Default: spatialtis.CONFIG.SHAPE_KEY)
centroid_key (Optional[str]) – The key to store cell centroid in AnnData.obs (Default: spatialtis.CONFIG.CENTROID_KEY)
size (Optional[Sequence[int]]) – The size of the plot in pixels
title (Optional[str]) – The title of the plot
palette (Optional[Union[Sequence[str], str]]) – Control the color of plot, sequence of color in hex, or name of palettes
display (Optional[bool]) – Whether to display the plot
save (Optional[Union[str, pathlib.Path]]) – The path to save your plot
return_plot (bool) – Whether to return the plot instance
expression_map¶
-
spatialtis.plotting.
expression_map
(adata, query, selected_types=None, type_key=None, marker_key=None, centroid_key=None, order=None, expression_min=None, expression_max=None, use='bar3d', renderer='canvas', axis_size=(100, 100, 80), size=(800, 500), palette=None, display=None, return_plot=False)[source]¶ (pyecharts) Visualize marker expression in ROI
Warning
There are problems in saving this plot even in .html. for now please use save bottom.
- Parameters
adata (anndata._core.anndata.AnnData) – AnnData object for plotting
query (Dict) – A Dict use to select which ROI to display, eg: {“Patients”: “Patient 1”, “ROI”: “ROI3”}, “Patients” and “ROI” are keys in AnnData.obs
selected_types (Optional[Sequence]) – Select interested cell types to perform analysis
type_key (Optional[str]) – The key to store cell types in AnnData.obs (Default: spatialtis.CONFIG.CELL_TYPE_KEY)
marker_key (Optional[str]) – The key to store markers in AnnData.var (Default: spatialtis.CONFIG.MARKER_KEY)
centroid_key (Optional[str]) – The key to store cell centroid in AnnData.obs (Default: spatialtis.CONFIG.CENTROID_KEY)
order (Optional[Sequence]) – array of marker name, display as order
expression_min (Optional[float]) – setting threshold for min of expression
expression_max (Optional[float]) – setting threshold for max of expression
use (str) – Options are “bar3d” and “scatter”
renderer (str) – Options are “canvas” and “svg”; “svg” is not perfect at this moment.
axis_size (tuple) – the length of x,y,z axis
size (tuple) – The size of the plot in pixels
palette (Optional[Sequence]) –
Control the color of plot, sequence of color in hex, or name of palettes
display (Optional[bool]) – Whether to display the plot
return_plot (bool) – Whether to return the plot instance
cell_neighbors¶
-
spatialtis.plotting.
cell_neighbors
(adata, query, use='interactive', type_key=None, centroid_key=None, neighbors_key=None, **kwargs)[source]¶ (pyecharts) Visualize cell neighbors in ROI
- Parameters
adata (anndata._core.anndata.AnnData) – AnnData object for plotting
query (Dict) – A Dict use to select which ROI to display, eg: {“Patients”: “Patient 1”, “ROI”: “ROI3”}, “Patients” and “ROI” are keys in AnnData.obs
use (str) – Options are “interactive” and “_static”
type_key (Optional[str]) – The key to store cell types in AnnData.obs (Default: spatialtis.CONFIG.CELL_TYPE_KEY)
centroid_key (Optional[str]) – The key to store cell centroid in AnnData.obs (Default: spatialtis.CONFIG.CENTROID_KEY)
neighbors_key (Optional[str]) – The key to store cell neighbors in AnnData.obs
**kwargs – Pass to Graph plot (interactive) or Graph plot
cell_communities¶
-
spatialtis.plotting.
cell_communities
(adata, query, min_cell=10, use='interactive', centroid_key=None, community_key=None, neighbors_key=None, **kwargs)[source]¶ (pyecharts, matplotlib) Visualize cell communities
- Parameters
adata (anndata._core.anndata.AnnData) – AnnData object for plotting
query (Dict) – A Dict use to select which ROI to display, eg: {“Patients”: “Patient 1”, “ROI”: “ROI3”}, “Patients” and “ROI” are keys in AnnData.obs
min_cell (int) – Only show communities with at least a number of cells
use (str) – Options are “interactive” and “_static”. For big ROI, “interactive” is much faster using WebGL
centroid_key (Optional[str]) – The key to store cell centroid in AnnData.obs (Default: spatialtis.CONFIG.CENTROID_KEY)
community_key (Optional[str]) – The key to store cell communities in AnnData.obs
neighbors_key (Optional[str]) – The key to store cell neighbors in AnnData.obs
**kwargs –
Pass to Graph plot (interactive) or Graph plot
Analysis Visualization functions¶
plotting.cell_components¶
-
spatialtis.plotting.
cell_components
(adata, groupby, selected_types=None, key=None, **kwargs)[source]¶ (bokeh) Plotting function for cell components
- Parameters
adata (anndata._core.anndata.AnnData) – AnnData object for plotting
groupby (Sequence[str]) – How your experiments data grouped, (Default: spatialtis.CONFIG.EXP_OBS)
selected_types (Optional[Sequence]) – Select interested cell types to perform analysis
key (Optional[str]) – The key stores the data for plotting in AnnData.uns
**kwargs – Pass to Stacked-bar plot
plotting.cell_co_occurrence¶
-
spatialtis.plotting.
cell_co_occurrence
(adata, groupby=None, selected_types=None, use='dot', key=None, **kwargs)[source]¶ (matplotlib) plotting function for cell co-occurrence
- Parameters
adata (anndata._core.anndata.AnnData) – AnnData object for plotting
groupby (Optional[Sequence[str]]) – How your experiments data grouped, (Default: spatialtis.CONFIG.EXP_OBS)
selected_types (Optional[Sequence]) – Select interested cell types to perform analysis
use (str) – Options are “dot” and “heatmap”
key (Optional[str]) – The key stores the data for plotting in AnnData.uns
**kwargs – Pass to Tri-Dotplot or Heatmap
plotting.cell_density¶
-
spatialtis.plotting.
cell_density
(adata, groupby=None, selected_types=None, key=None, **kwargs)[source]¶ (bokeh) plotting function for cell density
- Parameters
adata (anndata._core.anndata.AnnData) – AnnData object for plotting
groupby (Optional[Sequence[str]]) – How your experiments data grouped, (Default: spatialtis.CONFIG.EXP_OBS)
selected_types (Optional[Sequence]) – Select interested cell types to perform analysis
key (Optional[str]) – The key stores the data for plotting in AnnData.uns
**kwargs – Pass to Violin plot
plotting.cell_morphology¶
-
spatialtis.plotting.
cell_morphology
(adata, groupby=None, selected_types=None, key=None, **kwargs)[source]¶ (bokeh) plotting function for cell morphology
- Parameters
adata (anndata._core.anndata.AnnData) – AnnData object for plotting
groupby (Optional[Sequence[str]]) – How your experiments data grouped, (Default: spatialtis.CONFIG.EXP_OBS)
selected_types (Optional[Sequence]) – Select interested cell types to perform analysis
key (Optional[str]) – The key stores the data for plotting in AnnData.uns
**kwargs –
Pass to Violin plot
plotting.neighborhood_analysis¶
-
spatialtis.plotting.
neighborhood_analysis
(adata, groupby=None, selected_types=None, key=None, use='dot_matrix', **kwargs)[source]¶ (“dot_matrix”, “heatmap”: matplotlib) plotting function for neighborhood analysis
- Parameters
adata (anndata._core.anndata.AnnData) – AnnData object for plotting
groupby (Optional[Sequence[str]]) – How your experiments data grouped, (Default: spatialtis.CONFIG.EXP_OBS)
selected_types (Optional[Sequence]) – Select interested cell types to perform analysis
key (Optional[str]) – The key stores the data for plotting in AnnData.uns
use (str) – Options are “dot_matrix” and “heatmap”
**kwargs –
Pass to Dot-matrix plot or Heatmap
plotting.spatial_enrichment_analysis¶
-
spatialtis.plotting.
spatial_enrichment_analysis
(adata, groupby=None, selected_types=None, use='dot_matrix', key=None, **kwargs)[source]¶ (matplotlib) plotting function for plotting enrichment analysis
- Parameters
adata (anndata._core.anndata.AnnData) – AnnData object for plotting
groupby (Optional[Sequence[str]]) – How your experiments data grouped, (Default: spatialtis.CONFIG.EXP_OBS)
selected_types (Optional[Sequence]) – Select interested cell types to perform analysis
use (str) – Options are “dot_matrix” and “heatmap”
key (Optional[str]) – The key stores the data for plotting in AnnData.uns
**kwargs –
Pass to Dot-matrix plot or Heatmap
plotting.spatial_distribution¶
-
spatialtis.plotting.
spatial_distribution
(adata, groupby=None, selected_types=None, key=None, use='dot', **kwargs)[source]¶ (matplotlib) plotting function for plotting distribution
- Parameters
adata (anndata._core.anndata.AnnData) – AnnData object for plotting
groupby (Optional[Sequence[str]]) – How your experiments data grouped, (Default: spatialtis.CONFIG.EXP_OBS)
selected_types (Optional[Sequence]) – Select interested cell types to perform analysis
key (Optional[str]) – The key stores the data for plotting in AnnData.uns
use (str) – Options are “dot” and “heatmap”
**kwargs –
plotting.spatial_heterogeneity¶
-
spatialtis.plotting.
spatial_heterogeneity
(adata, groupby=None, key=None, metric='heterogeneity', **kwargs)[source]¶ (bokeh) plotting function for cell morphology
- Parameters
adata (anndata._core.anndata.AnnData) – AnnData object for plotting
groupby (Optional[Sequence[str]]) – How your experiments data grouped, (Default: spatialtis.CONFIG.EXP_OBS)
key (Optional[str]) – The key stores the data for plotting in AnnData.uns
metric (str) – “heterogeneity” or “KL”, “KL” only available if you use shannon entropy
**kwargs –
Pass to Violin plot or Stacked-bar plot
plotting.exp_neighcells¶
-
spatialtis.plotting.
exp_neighcells
(adata, key=None, score=0.5, palette=None, **kwargs)[source]¶ (pyecharts) plotting function for expression influenced by neighbor cells
- Parameters
adata (anndata._core.anndata.AnnData) – AnnData object for plotting
key (Optional[str]) – The key stores the data for plotting in AnnData.uns
score (float) – Threshold for score
palette (Optional[Sequence]) – Control the color
**kwargs – Pass to Sankey plot