ridges#
- ridges(data: AnnData, keys: Sequence[str], *, group_by: str | None = None, scale: float = 2.0, mapping: FeatureSpec | None = None, axis: Literal[0, 1] | None = None, threshold: float | None = None, add_keys: Sequence[str] | str | None = None, tooltips: Literal['none'] | Sequence[str] | FeatureSpec | None = None, observations_name: str = 'Barcode', variables_name: str = 'Variable', interactive: bool = False, layers: Sequence[FeatureSpec | LayerSpec] | FeatureSpec | LayerSpec | None = None, ncol: int | None = None, sharex: str | None = None, sharey: str | None = None, widths: list | None = None, heights: list | None = None, hspace: float | None = None, vspace: float | None = None, fit: bool | None = None, align: bool | None = None, guides: str = 'auto', **geom_kwargs) SupPlotsSpec#
Ridge Plot.
- Parameters:
data (
AnnData) – The AnnData object of the single cell data.keys (
Sequence[str]) – The keys to get the values (numerical). e.g., [‘total_counts’, ‘pct_counts_in_top_50_genes’] or a list of gene names.group_by (
str) – The key to group the ridges by (categorical). e.g., ‘cell_type’ or ‘leiden’.scale (
float, default2.0) – Scaling factor for the height of the ridges.mapping (
FeatureSpec | None, defaultNone) – Additional aesthetic mappings for the plot, the result of aes().axis (
{0,1}| None, defaultNone) – axis of the data, 0 for observations and 1 for variables.threshold (
float | None, defaultNone) – If provided, filters out rows where the value column is below the threshold.add_keys (
Sequence[str] | str | None, defaultNone) – Additional keys to include in the dataframe.tooltips (
{'none'}| Sequence[str] | FeatureSpec | None, defaultNone) – Tooltips to show when hovering over the geom. Accepts Sequence[str] or result of layer_tooltips() for more complex tooltips. Use ‘none’ to disable tooltips.observations_name (
str, default'Barcode') – The name to give to barcode (or index) column in the dataframe.variables_name (
str, default'Variable') – The name to give to variable index column in the dataframe.interactive (
bool, defaultFalse) – Whether to make the plot interactive.layers (
Sequence[FeatureSpec | LayerSpec] | FeatureSpec | LayerSpec | None, defaultNone) – Additional layers to add to the plot.ncol (
int, defaultNone) – Number of columns in grid. If not specified, shows plots horizontally, in one row.sharex (
bool, defaultNone) – Controls sharing of axis limits between subplots in the grid. all/True - share limits between all subplots. none/False - do not share limits between subplots. row - share limits between subplots in the same row. col - share limits between subplots in the same column.sharey (
bool, defaultNone) – Controls sharing of axis limits between subplots in the grid. all/True - share limits between all subplots. none/False - do not share limits between subplots. row - share limits between subplots in the same row. col - share limits between subplots in the same column.widths (
list[float], defaultNone) – Relative width of each column of grid, left to right.heights (
list[float], defaultNone) – Relative height of each row of grid, top-down.hspace (
float | None, defaultNone) – Cell horizontal spacing in px.vspace (
float | None, defaultNone) – Cell vertical spacing in px.fit (
bool, defaultTrue) – Whether to stretch each plot to match the aspect ratio of its cell (fit=True), or to preserve the original aspect ratio of plots (fit=False).align (
bool, defaultFalse) – If True, align inner areas (i.e. “geom” bounds) of plots. However, cells containing other (sub)grids are not participating in the plot “inner areas” layouting.guides (
str, default'auto') –- Specifies how guides (legends and colorbars) should be treated in the layout.
’collect’ collect guides from all subplots, removing duplicates.
’keep’ keep guides in their original subplots; do not collect at this level.
’auto’ allow guides to be collected if an upper-level layout uses guides=’collect’;
otherwise, keep them in subplots. Duplicates are identified by comparing visual properties: For legends: title, labels, and all aesthetic values (colors, shapes, sizes, etc.). For colorbars: title, domain limits, breaks, and color gradient.
For more information on gggrid parameters: https://lets-plot.org/python/pages/api/lets_plot.gggrid.html
**geom_kwargs – Additional parameters for the geom_area_ridges layer. For more information on geom_area_ridges parameters, see: https://lets-plot.org/python/pages/api/lets_plot.geom_area_ridges.html
- Returns:
SupPlotsSpec– Ridge plot.
Examples
import numpy as np import scanpy as sc import cellestial as cl data = sc.read_h5ad("data/pbmc3k_pped.h5ad") # get the top 8 genes with the highest mean expression gene_means = np.asarray(data.X.mean(axis=0)).flatten() top8_genes = data.var_names[np.argsort(gene_means)[::-1][:8]].tolist() cl.ridges( data, keys=top8_genes, group_by="cell_type_lvl1", alpha=0.7, scale=2, ncol=2, color="#3f3f3f", guides="collect", )