spateo.plotting.static.glm#

Module Contents#

Functions#

glm_fit(adata, genes, list]] = None, feature_x, ...)

Plot the glm_degs result in a scatterplot.

glm_heatmap(adata, genes, list]] = None, feature_x, ...)

Plot the glm_degs result in a heatmap.

spateo.plotting.static.glm.glm_fit(adata: anndata.AnnData, genes: Optional[Union[str, list]] = None, feature_x: str = None, feature_y: str = 'expression', glm_key: str = 'glm_degs', remove_zero: bool = False, color_key: Optional[str] = None, color_key_cmap: Optional[str] = 'vlag', point_size: float = 14, point_color: Union[str, numpy.ndarray, list] = 'skyblue', line_size: float = 2, line_color: str = 'black', ax_size: Union[tuple, list] = (6, 4), background_color: str = 'white', ncols: int = 4, show_point: bool = True, show_line: bool = True, show_legend: bool = True, save_show_or_return: Literal[save, show, return, both, all] = 'show', save_kwargs: Optional[dict] = None, **kwargs)[source]#

Plot the glm_degs result in a scatterplot.

Parameters:
adata

An Anndata object contain glm_degs result in .uns[glm_key].

genes

A gene name or a list of genes that will be used to plot.

feature_x

The key in .uns[glm_key]['correlation'][gene] that corresponds to the independent variables, such as 'torsion', etc.

feature_y

The key in .uns[glm_key]['correlation'][gene] that corresponds to the dependent variables, such as 'expression', etc.

glm_key

The key in .uns that corresponds to the glm_degs result.

remove_zero

Whether to remove the data equal to 0 saved in .uns[glm_key]['correlation'][gene][feature_y].

color_key

This can either be an explicit dict mapping labels to colors (as strings of form ‘#RRGGBB’), or an array like object providing one color for each distinct category being provided in labels.

color_key_cmap

The name of a matplotlib colormap to use for categorical coloring.

point_size

The scale of the feature_y point size.

point_color

The color of the feature_y point.

line_size

The scale of the fitted line width.

line_color

The color of the fitted line.

ax_size

The width and height of each ax.

background_color

The background color of the figure.

ncols

Number of columns for the figure.

show_point

Whether to show the scatter plot.

show_line

Whether to show the line plot.

show_legend

Whether to show the legend.

save_show_or_return

If 'both', it will save and plot the figure at the same time.

If 'all', the figure will be saved, displayed and the associated axis and other object will be return.

save_kwargs

A dictionary that will be passed to the save_fig function.

By default, it is an empty dictionary and the save_fig function will use the {"path": None, "prefix": 'scatter', "dpi": None, "ext": 'pdf', "transparent": True, "close": True, "verbose": True} as its parameters.

Otherwise, you can provide a dictionary that properly modify those keys according to your needs.

**kwargs

Additional parameters that will be passed into the seaborn.scatterplot function.

spateo.plotting.static.glm.glm_heatmap(adata: anndata.AnnData, genes: Optional[Union[str, list]] = None, feature_x: str = None, feature_y: str = 'expression', glm_key: str = 'glm_degs', lowess_smooth: bool = True, frac: float = 0.2, robust: bool = True, colormap: str = 'vlag', figsize: tuple = (6, 6), background_color: str = 'white', show_legend: bool = True, save_show_or_return: Literal[save, show, return, both, all] = 'show', save_kwargs: Optional[dict] = None, **kwargs)[source]#

Plot the glm_degs result in a heatmap.

Parameters:
adata

An Anndata object contain glm_degs result in .uns[glm_key].

genes

A gene name or a list of genes that will be used to plot.

feature_x

The key in .uns[glm_key]['correlation'][gene] that corresponds to the independent variables, such as 'torsion', etc.

feature_y

The key in .uns[glm_key]['correlation'][gene] that corresponds to the dependent variables, such as 'expression', etc.

glm_key

The key in .uns that corresponds to the glm_degs result.

lowess_smooth

If True, use statsmodels to estimate a nonparametric lowess model (locally weighted linear regression).

frac

Between 0 and 1. The fraction of the data used when estimating each y-value.

robust

If True and vmin or vmax are absent, the colormap range is computed with robust quantiles instead of the extreme values.

colormap

The name of a matplotlib colormap.

figsize

The width and height of figure.

background_color

The background color of the figure.

show_legend

Whether to show the legend.

save_show_or_return

If 'both', it will save and plot the figure at the same time.

If 'all', the figure will be saved, displayed and the associated axis and other object will be return.

save_kwargs

A dictionary that will be passed to the save_fig function.

By default, it is an empty dictionary and the save_fig function will use the {"path": None, "prefix": 'scatter', "dpi": None, "ext": 'pdf', "transparent": True, "close": True, "verbose": True} as its parameters.

Otherwise, you can provide a dictionary that properly modify those keys according to your needs.

**kwargs

Additional parameters that will be passed into the seaborn.heatmap function.