Skip to content

Plots

Plot data extractors and matplotlib plots for single cell results.

Two layers. The extract_* functions pull what one plot needs out of an experiment into a polars frame and need nothing beyond the core package. The plots draw from the same data, take the object or the frame its extractor returns, and need matplotlib, the plots extra (pip install bixverse[plots]). matplotlib is imported on first use of a plot, not with this module. Hand a plot the frame when you want to restyle it, or draw the same data with another library.

Where to start. embedding_plot for an obs column on an embedding, feature_plot for genes on an embedding, dot_plot, stacked_violin_plot and heatmap_plot for markers across groups, feature_scatter_plot for two genes against each other. The QC plots (violin_plot, density_plot, joint_plot) take the CellQc from bv.qc.run_cell_qc or a frame. paga_plot and milo_nhood_plot take the result of bv.traj.run_paga and the tested MiloR from bv.de.

What lands where. Nothing here writes to the experiment. Every plot reads the kept cells of a SingleCells, SingleCellsSubset, MetaCells or SingleCellsMultiModal and returns a matplotlib object: the single panel plots take an optional ax and return it, the multi-panel ones return the Figure. The extractors return one row per kept cell (per meta cell for MetaCells), long over genes where the plot needs it. Gene arguments are var ids.

import matplotlib.pyplot as plt

genes = sc.gene_ids()[:4].tolist()
bv.pl.embedding_plot(sc, "umap", "cell_grp", label_by="cell_grp")
bv.pl.feature_plot(sc, genes, "umap", ncol=2)
bv.pl.dot_plot(sc, genes, "cell_grp")

frame = bv.pl.extract_embedding_data(sc, "umap", obs_cols=["cell_grp"])
plt.show()

Gotchas. The embedding has to exist (bv.embed.umap and friends; "pca" works after bv.pp.calculate_pca). Numeric obs columns get a colour bar, and label_by refuses them: cluster ids stored as numbers need discrete=True. Point and label sizes are in mm and point_size=None picks a size from the cell count; above 100,000 cells the points are rasterised. density_plot needs a CellQc run with groups. violin_plot and density_plot take a plain frame too, with grouping_column and variable; the outliers are then recomputed by MAD per group.

Worked through in A guide to single-cell plotting functions.

Embeddings

Plot data extractors and matplotlib plots for single cell results.

Two layers. The extract_* functions pull what one plot needs out of an experiment into a polars frame and need nothing beyond the core package. The plots draw from the same data, take the object or the frame its extractor returns, and need matplotlib, the plots extra (pip install bixverse[plots]). matplotlib is imported on first use of a plot, not with this module. Hand a plot the frame when you want to restyle it, or draw the same data with another library.

Where to start. embedding_plot for an obs column on an embedding, feature_plot for genes on an embedding, dot_plot, stacked_violin_plot and heatmap_plot for markers across groups, feature_scatter_plot for two genes against each other. The QC plots (violin_plot, density_plot, joint_plot) take the CellQc from bv.qc.run_cell_qc or a frame. paga_plot and milo_nhood_plot take the result of bv.traj.run_paga and the tested MiloR from bv.de.

What lands where. Nothing here writes to the experiment. Every plot reads the kept cells of a SingleCells, SingleCellsSubset, MetaCells or SingleCellsMultiModal and returns a matplotlib object: the single panel plots take an optional ax and return it, the multi-panel ones return the Figure. The extractors return one row per kept cell (per meta cell for MetaCells), long over genes where the plot needs it. Gene arguments are var ids.

import matplotlib.pyplot as plt

genes = sc.gene_ids()[:4].tolist()
bv.pl.embedding_plot(sc, "umap", "cell_grp", label_by="cell_grp")
bv.pl.feature_plot(sc, genes, "umap", ncol=2)
bv.pl.dot_plot(sc, genes, "cell_grp")

frame = bv.pl.extract_embedding_data(sc, "umap", obs_cols=["cell_grp"])
plt.show()

Gotchas. The embedding has to exist (bv.embed.umap and friends; "pca" works after bv.pp.calculate_pca). Numeric obs columns get a colour bar, and label_by refuses them: cluster ids stored as numbers need discrete=True. Point and label sizes are in mm and point_size=None picks a size from the cell count; above 100,000 cells the points are rasterised. density_plot needs a CellQc run with groups. violin_plot and density_plot take a plain frame too, with grouping_column and variable; the outliers are then recomputed by MAD per group.

embedding_plot

embedding_plot(
    x: ScOrMc | DataFrame,
    embedding: str,
    colour_by: str,
    *,
    label_by: str | None = None,
    discrete: bool | None = None,
    embd_modality: Modality = "rna",
    point_size: float | None = None,
    point_alpha: float = 0.5,
    raster: bool | None = None,
    palette: Palette | None = None,
    label_size: float = 3.0,
    label_color: str = "black",
    label_font: str = "bold",
    ax: Axes | None = None,
) -> Axes

An embedding coloured by an obs column.

Parameters:

Name Type Description Default
x ScOrMc | DataFrame

The object, or extract_embedding_data output holding colour_by (and label_by).

required
embedding str

The embedding name, also the axis labels.

required
colour_by str

Column to colour by. Strings, Enums and booleans get the discrete palette in level order, numbers a colour bar.

required
label_by str | None

Column to label the group centroids by.

None
discrete bool | None

Force a discrete scale.

None
embd_modality Modality

Where the embedding lives.

'rna'
point_size float | None

Point size in mm; Seurat's auto size when None.

None
point_alpha float

Point alpha.

0.5
raster bool | None

Rasterise the points (vector output); None does above 100,000 cells.

None
palette Palette | None

"main" for discrete, "sequential" for continuous when None.

None
label_size float

Label size in mm.

3.0
label_color str

Label colour.

'black'
label_font str

"bold", "normal" or "italic".

'bold'
ax Axes | None

Axes to draw on.

None

Returns:

Type Description
Axes

The axes.

Examples:

>>> ax = bv.pl.embedding_plot(
...     sc, "umap", "leiden", label_by="leiden", discrete=True
... )
>>> ax = bv.pl.embedding_plot(sc, "umap", "lib_size", point_alpha=0.2)

extract_embedding_data

extract_embedding_data(
    sc: ScOrMc,
    embedding: str,
    *,
    obs_cols: Sequence[str] | None = None,
    modality: Modality = "rna",
) -> DataFrame

Embedding coordinates for plotting.

Parameters:

Name Type Description Default
sc ScOrMc

The experiment, a subset or meta cells.

required
embedding str

The embedding name, "pca" for the PCA scores.

required
obs_cols Sequence[str] | None

obs columns to attach.

None
modality Modality

Where the embedding lives: "rna", or "adt" / "atac" / "wnn" on a SingleCellsMultiModal.

'rna'

Returns:

Type Description
DataFrame

cell_id, dim_1 ... dim_k (float64) and the obs columns, one

DataFrame

row per kept cell (or meta cell).

Raises:

Type Description
ValueError

If the embedding is missing.

Examples:

>>> frame = bv.pl.extract_embedding_data(sc, "umap", obs_cols=["leiden"])

Genes on an embedding

Plot data extractors and matplotlib plots for single cell results.

Two layers. The extract_* functions pull what one plot needs out of an experiment into a polars frame and need nothing beyond the core package. The plots draw from the same data, take the object or the frame its extractor returns, and need matplotlib, the plots extra (pip install bixverse[plots]). matplotlib is imported on first use of a plot, not with this module. Hand a plot the frame when you want to restyle it, or draw the same data with another library.

Where to start. embedding_plot for an obs column on an embedding, feature_plot for genes on an embedding, dot_plot, stacked_violin_plot and heatmap_plot for markers across groups, feature_scatter_plot for two genes against each other. The QC plots (violin_plot, density_plot, joint_plot) take the CellQc from bv.qc.run_cell_qc or a frame. paga_plot and milo_nhood_plot take the result of bv.traj.run_paga and the tested MiloR from bv.de.

What lands where. Nothing here writes to the experiment. Every plot reads the kept cells of a SingleCells, SingleCellsSubset, MetaCells or SingleCellsMultiModal and returns a matplotlib object: the single panel plots take an optional ax and return it, the multi-panel ones return the Figure. The extractors return one row per kept cell (per meta cell for MetaCells), long over genes where the plot needs it. Gene arguments are var ids.

import matplotlib.pyplot as plt

genes = sc.gene_ids()[:4].tolist()
bv.pl.embedding_plot(sc, "umap", "cell_grp", label_by="cell_grp")
bv.pl.feature_plot(sc, genes, "umap", ncol=2)
bv.pl.dot_plot(sc, genes, "cell_grp")

frame = bv.pl.extract_embedding_data(sc, "umap", obs_cols=["cell_grp"])
plt.show()

Gotchas. The embedding has to exist (bv.embed.umap and friends; "pca" works after bv.pp.calculate_pca). Numeric obs columns get a colour bar, and label_by refuses them: cluster ids stored as numbers need discrete=True. Point and label sizes are in mm and point_size=None picks a size from the cell count; above 100,000 cells the points are rasterised. density_plot needs a CellQc run with groups. violin_plot and density_plot take a plain frame too, with grouping_column and variable; the outliers are then recomputed by MAD per group.

feature_plot

feature_plot(
    x: ScOrMc | DataFrame,
    features: Sequence[str] | None = None,
    embedding: str | None = None,
    *,
    feature_labels: Mapping[str, str] | None = None,
    scale: bool = False,
    clip: float | None = None,
    expr_modality: ExprModality = "rna",
    embd_modality: Modality = "rna",
    expr_sc: ScOrMc | None = None,
    layer: Layer = "norm",
    point_size: float | None = None,
    point_alpha: float = 0.5,
    raster: bool | None = None,
    label_by: str | None = None,
    label_size: float = 3.0,
    label_color: str = "black",
    label_font: str = "bold",
    highlight_features: bool = False,
    highlight_quantile: float = 0.25,
    scale_mode: Literal["free", "shared"] = "free",
    palette: ContinuousPalette = "sequential",
    ncol: int | None = None,
) -> Figure

Feature expression over an embedding, one panel per feature.

With scale_mode="free" every panel gets its own colour bar, so a weak gene is not flattened by the loudest one; "shared" uses one colour bar over the pooled expression. Points are drawn low to high.

Parameters:

Name Type Description Default
x ScOrMc | DataFrame

The object, or extract_feature_plot_data output.

required
features Sequence[str] | None

Feature ids from expr_modality. Not needed for a frame.

None
embedding str | None

The embedding name, also the axis labels.

None
feature_labels Mapping[str, str] | None

Feature id to panel title.

None
scale bool

z-score the expression.

False
clip float | None

Clip the z-scores, with scale.

None
expr_modality ExprModality

"rna", "adt" or "atac".

'rna'
embd_modality Modality

"rna", "adt", "atac" or "wnn".

'rna'
expr_sc ScOrMc | None

Where the expression comes from, e.g. the gene activity of an ATAC experiment; None for x.

None
layer Layer

"norm" or "magic".

'norm'
point_size float | None

Point size in mm; Seurat's auto size when None.

None
point_alpha float

Point alpha.

0.5
raster bool | None

Rasterise the points; None does above 100,000 cells.

None
label_by str | None

obs column to label the group centroids by.

None
label_size float

Label size in mm.

3.0
label_color str

Label colour.

'black'
label_font str

"bold", "normal" or "italic".

'bold'
highlight_features bool

Push the cells at or below highlight_quantile (per feature) into a grey background layer and draw the rest larger.

False
highlight_quantile float

The background quantile.

0.25
scale_mode Literal['free', 'shared']

"free" or "shared" colour bars.

'free'
palette ContinuousPalette

The continuous palette.

'sequential'
ncol int | None

Panel columns; a square-ish grid when None.

None

Returns:

Type Description
Figure

The figure.

Raises:

Type Description
ValueError

Without features and embedding for an object.

Examples:

>>> fig = bv.pl.feature_plot(sc, genes, "umap", highlight_features=True, ncol=2)

extract_feature_plot_data

extract_feature_plot_data(
    sc: ScOrMc,
    features: Sequence[str],
    embedding: str,
    *,
    scale: bool = False,
    clip: float | None = None,
    obs_cols: Sequence[str] | None = None,
    expr_modality: ExprModality = "rna",
    embd_modality: Modality = "rna",
    layer: Layer = "norm",
    expr_sc: ScOrMc | None = None,
) -> DataFrame

Per-cell expression on an embedding, long.

The expression and the embedding modality are chosen independently, so RNA can colour an ADT embedding and either can go on a WNN one. Both key on the kept cell ids. Rows stay in kept cell order within each gene. With expr_sc the expression comes from another object over the same cells, such as the gene activity of an ATAC experiment on its UMAP.

Parameters:

Name Type Description Default
sc ScOrMc

The experiment, a subset or meta cells.

required
features Sequence[str]

Feature ids from expr_modality.

required
embedding str

The embedding name.

required
scale bool

z-score each feature.

False
clip float | None

Clip the z-scores, with scale.

None
obs_cols Sequence[str] | None

obs columns to attach.

None
expr_modality ExprModality

"rna", "adt" or "atac".

'rna'
embd_modality Modality

"rna", "adt", "atac" or "wnn".

'rna'
layer Layer

"norm" or "magic".

'norm'
expr_sc ScOrMc | None

Where the expression comes from; None for sc. Joined on the cell ids, so only cells kept in both are drawn.

None

Returns:

Type Description
DataFrame

cell_id, dim_*, the obs columns, gene (Enum) and expression.

Examples:

>>> long = bv.pl.extract_feature_plot_data(sc, genes, "umap", scale=True)

Markers across groups

Plot data extractors and matplotlib plots for single cell results.

Two layers. The extract_* functions pull what one plot needs out of an experiment into a polars frame and need nothing beyond the core package. The plots draw from the same data, take the object or the frame its extractor returns, and need matplotlib, the plots extra (pip install bixverse[plots]). matplotlib is imported on first use of a plot, not with this module. Hand a plot the frame when you want to restyle it, or draw the same data with another library.

Where to start. embedding_plot for an obs column on an embedding, feature_plot for genes on an embedding, dot_plot, stacked_violin_plot and heatmap_plot for markers across groups, feature_scatter_plot for two genes against each other. The QC plots (violin_plot, density_plot, joint_plot) take the CellQc from bv.qc.run_cell_qc or a frame. paga_plot and milo_nhood_plot take the result of bv.traj.run_paga and the tested MiloR from bv.de.

What lands where. Nothing here writes to the experiment. Every plot reads the kept cells of a SingleCells, SingleCellsSubset, MetaCells or SingleCellsMultiModal and returns a matplotlib object: the single panel plots take an optional ax and return it, the multi-panel ones return the Figure. The extractors return one row per kept cell (per meta cell for MetaCells), long over genes where the plot needs it. Gene arguments are var ids.

import matplotlib.pyplot as plt

genes = sc.gene_ids()[:4].tolist()
bv.pl.embedding_plot(sc, "umap", "cell_grp", label_by="cell_grp")
bv.pl.feature_plot(sc, genes, "umap", ncol=2)
bv.pl.dot_plot(sc, genes, "cell_grp")

frame = bv.pl.extract_embedding_data(sc, "umap", obs_cols=["cell_grp"])
plt.show()

Gotchas. The embedding has to exist (bv.embed.umap and friends; "pca" works after bv.pp.calculate_pca). Numeric obs columns get a colour bar, and label_by refuses them: cluster ids stored as numbers need discrete=True. Point and label sizes are in mm and point_size=None picks a size from the cell count; above 100,000 cells the points are rasterised. density_plot needs a CellQc run with groups. violin_plot and density_plot take a plain frame too, with grouping_column and variable; the outliers are then recomputed by MAD per group.

dot_plot

dot_plot(
    x: ScOrMc | DataFrame,
    features: Sequence[str] | None = None,
    grouping_variable: str | None = None,
    *,
    feature_labels: Mapping[str, str] | None = None,
    feature_grouping: Mapping[str, str] | None = None,
    scale_exp: bool = True,
    modality: ExprModality = "rna",
    cluster_groups: bool = True,
    palette: ContinuousPalette = "sequential",
    ax: Axes | None = None,
) -> Axes

Marker expression across groups, colour the scaled mean and size the percent expressing.

The first feature sits at the top. With feature_grouping the features are blocked by group (groups in order of first appearance) and the blocks labelled on the right.

Parameters:

Name Type Description Default
x ScOrMc | DataFrame

The object, or extract_dot_plot_data output.

required
features Sequence[str] | None

Feature ids. Not needed for a frame.

None
grouping_variable str | None

obs column to group by. Not needed for a frame.

None
feature_labels Mapping[str, str] | None

Feature id to display label.

None
feature_grouping Mapping[str, str] | None

Feature id (or display label, with feature_labels) to group, e.g. a cell type.

None
scale_exp bool

Min-max scale the means per feature.

True
modality ExprModality

"rna" or "adt".

'rna'
cluster_groups bool

Order the groups by a complete-linkage clustering of their scaled expression profiles.

True
palette ContinuousPalette

The continuous palette.

'sequential'
ax Axes | None

Axes to draw on.

None

Returns:

Type Description
Axes

The axes.

Examples:

>>> ax = bv.pl.dot_plot(sc, genes, "cell_grp", cluster_groups=False)

extract_dot_plot_data

extract_dot_plot_data(
    sc: ScOrMc,
    features: Sequence[str],
    grouping_variable: str,
    *,
    scale_exp: bool = True,
    modality: ExprModality = "rna",
) -> DataFrame

Per-group mean expression and percent expressing.

Means run over every cell of the group, zeros included. Cells with a missing group are left out and only groups that occur are kept, on every source.

Parameters:

Name Type Description Default
sc ScOrMc

The experiment, a subset or meta cells.

required
features Sequence[str]

Gene ids, ADT feature ids for "adt", peak or tile ids (chr:start-end) for "atac".

required
grouping_variable str

obs column to group by.

required
scale_exp bool

Min-max scale the means per feature into scaled_exp.

True
modality ExprModality

"rna", "adt" on a SingleCellsMultiModal, or "atac" for peak accessibility (its norm is the TF-IDF).

'rna'

Returns:

Type Description
DataFrame

gene and group (Enums, in feature and level order), mean_exp,

DataFrame

pct_exp (0 to 100) and scaled_exp, gene-major.

Raises:

Type Description
ValueError

If nothing matched or the grouping is entirely missing.

Examples:

>>> dots = bv.pl.extract_dot_plot_data(sc, genes, "leiden")

stacked_violin_plot

stacked_violin_plot(
    x: ScOrMc | DataFrame,
    features: Sequence[str] | None = None,
    grouping_variable: str | None = None,
    *,
    feature_labels: Mapping[str, str] | None = None,
    scale: bool = False,
    clip: float | None = None,
    modality: ExprModality = "rna",
    layer: Layer = "norm",
    palette: Palette = "main",
) -> Figure

Expression across groups, one row of violins per feature.

Parameters:

Name Type Description Default
x ScOrMc | DataFrame

The object, or extract_gene_violin_data output.

required
features Sequence[str] | None

Feature ids, one row each. Not needed for a frame.

None
grouping_variable str | None

obs column to group by. Not needed for a frame.

None
feature_labels Mapping[str, str] | None

Feature id to row label.

None
scale bool

z-score the expression.

False
clip float | None

Clip the z-scores, with scale.

None
modality ExprModality

"rna" or "adt".

'rna'
layer Layer

"norm" or "magic".

'norm'
palette Palette

The discrete palette for the groups.

'main'

Returns:

Type Description
Figure

The figure, one axes per feature, the first on top.

Examples:

>>> fig = bv.pl.stacked_violin_plot(sc, genes, "cell_grp", scale=True, clip=3.0)

extract_gene_violin_data

extract_gene_violin_data(
    sc: ScOrMc,
    features: Sequence[str],
    grouping_variable: str,
    *,
    scale: bool = False,
    clip: float | None = None,
    modality: ExprModality = "rna",
    layer: Layer = "norm",
) -> DataFrame

Per-cell expression with its group, long.

Parameters:

Name Type Description Default
sc ScOrMc

The experiment, a subset or meta cells.

required
features Sequence[str]

Gene ids, ADT feature ids for "adt", peak or tile ids (chr:start-end) for "atac".

required
grouping_variable str

obs column to group by.

required
scale bool

z-score each feature across the cells.

False
clip float | None

Clip the z-scores to [-clip, clip], with scale.

None
modality ExprModality

"rna", "adt" on a SingleCellsMultiModal, or "atac" for peak accessibility (its norm is the TF-IDF).

'rna'
layer Layer

"norm", or "magic" for the imputed layer of run_magic.

'norm'

Returns:

Type Description
DataFrame

cell_id, group (Enum in level order), gene (Enum in feature

DataFrame

order) and expression, gene-major.

Examples:

>>> violin = bv.pl.extract_gene_violin_data(sc, genes, "leiden")

heatmap_plot

heatmap_plot(
    x: ScOrMc | DataFrame,
    features: Sequence[str] | None = None,
    grouping_variable: str | None = None,
    *,
    feature_labels: Mapping[str, str] | None = None,
    feature_grouping: Mapping[str, str] | None = None,
    scale: bool = True,
    clip: float | None = 2.5,
    modality: ExprModality = "rna",
    max_cells_per_group: int | None = None,
    seed: int = 42,
    group_gap: float = 0.002,
    show_feature_labels: bool | None = None,
    palette: ContinuousPalette = "diverging",
    ax: Axes | None = None,
) -> Axes

Genes x cells, cells blocked by group with a colour strip per group. Every block is one image.

Parameters:

Name Type Description Default
x ScOrMc | DataFrame

The object, or extract_gene_expression output holding grouping_variable.

required
features Sequence[str] | None

Feature ids, one row each, in this order. Not needed for a frame.

None
grouping_variable str | None

obs column to block the cells by; Enum levels set the order.

None
feature_labels Mapping[str, str] | None

Feature id to row label.

None
feature_grouping Mapping[str, str] | None

Feature id (or label) to group, blocking the rows; groups in order of first appearance.

None
scale bool

z-score per gene; the colour range is then centred on zero.

True
clip float | None

Clip the z-scores.

2.5
modality ExprModality

"rna" or "adt".

'rna'
max_cells_per_group int | None

Subsample every group to at most this many.

None
seed int

Seed for the subsampling.

42
group_gap float

Width of each gap as a fraction of the axis, [0, 0.1].

0.002
show_feature_labels bool | None

Gene names on the right; None shows up to 80.

None
palette ContinuousPalette

The continuous palette; "diverging" runs blue to red.

'diverging'
ax Axes | None

Axes to draw on.

None

Returns:

Type Description
Axes

The axes.

Raises:

Type Description
ValueError

Without grouping_variable, or an out of range gap.

Examples:

>>> ax = bv.pl.heatmap_plot(sc, genes, "cell_grp", max_cells_per_group=200)

extract_gene_expression

extract_gene_expression(
    sc: ScOrMc,
    features: Sequence[str],
    *,
    obs_cols: Sequence[str] | None = None,
    scale: bool = False,
    clip: float | None = None,
    modality: ExprModality = "rna",
    layer: Layer = "norm",
) -> DataFrame

Per-cell expression, one column per feature.

RNA from the store reads the gene-major file in Rust; ADT counts, the MAGIC layer and meta cells come from memory. Unknown features warn and drop.

Parameters:

Name Type Description Default
sc ScOrMc

The experiment, a subset or meta cells.

required
features Sequence[str]

Gene ids, ADT feature ids for "adt", peak or tile ids (chr:start-end) for "atac".

required
obs_cols Sequence[str] | None

obs columns to attach.

None
scale bool

z-score each feature across the rows.

False
clip float | None

Clip the z-scores to [-clip, clip], with scale.

None
modality ExprModality

"rna", "adt" on a SingleCellsMultiModal, or "atac" for peak accessibility (its norm is the TF-IDF).

'rna'
layer Layer

"norm", or "magic" for the imputed layer of run_magic.

'norm'

Returns:

Type Description
DataFrame

cell_id, one float64 column per matched feature, then the obs

DataFrame

columns.

Raises:

Type Description
ValueError

If nothing matched, on ADT without a multi-modal object or ADT counts, or a missing MAGIC layer.

Examples:

>>> expr = bv.pl.extract_gene_expression(
...     sc, genes, obs_cols=["leiden"], scale=True, clip=3.0
... )

Two genes against each other

Plot data extractors and matplotlib plots for single cell results.

Two layers. The extract_* functions pull what one plot needs out of an experiment into a polars frame and need nothing beyond the core package. The plots draw from the same data, take the object or the frame its extractor returns, and need matplotlib, the plots extra (pip install bixverse[plots]). matplotlib is imported on first use of a plot, not with this module. Hand a plot the frame when you want to restyle it, or draw the same data with another library.

Where to start. embedding_plot for an obs column on an embedding, feature_plot for genes on an embedding, dot_plot, stacked_violin_plot and heatmap_plot for markers across groups, feature_scatter_plot for two genes against each other. The QC plots (violin_plot, density_plot, joint_plot) take the CellQc from bv.qc.run_cell_qc or a frame. paga_plot and milo_nhood_plot take the result of bv.traj.run_paga and the tested MiloR from bv.de.

What lands where. Nothing here writes to the experiment. Every plot reads the kept cells of a SingleCells, SingleCellsSubset, MetaCells or SingleCellsMultiModal and returns a matplotlib object: the single panel plots take an optional ax and return it, the multi-panel ones return the Figure. The extractors return one row per kept cell (per meta cell for MetaCells), long over genes where the plot needs it. Gene arguments are var ids.

import matplotlib.pyplot as plt

genes = sc.gene_ids()[:4].tolist()
bv.pl.embedding_plot(sc, "umap", "cell_grp", label_by="cell_grp")
bv.pl.feature_plot(sc, genes, "umap", ncol=2)
bv.pl.dot_plot(sc, genes, "cell_grp")

frame = bv.pl.extract_embedding_data(sc, "umap", obs_cols=["cell_grp"])
plt.show()

Gotchas. The embedding has to exist (bv.embed.umap and friends; "pca" works after bv.pp.calculate_pca). Numeric obs columns get a colour bar, and label_by refuses them: cluster ids stored as numbers need discrete=True. Point and label sizes are in mm and point_size=None picks a size from the cell count; above 100,000 cells the points are rasterised. density_plot needs a CellQc run with groups. violin_plot and density_plot take a plain frame too, with grouping_column and variable; the outliers are then recomputed by MAD per group.

feature_scatter_plot

feature_scatter_plot(
    x: ScOrMc | DataFrame,
    feature_1: str | None = None,
    feature_2: str | None = None,
    *,
    geom: Literal["density", "hex"] = "density",
    remove_zeros: bool = True,
    smoothness: float = 10.0,
    bins: int = 60,
    modality: ExprModality = "rna",
    point_size: float = 2.5,
    point_alpha: float = 0.5,
    raster: bool | None = None,
    palette: ContinuousPalette = "viridis",
    ax: Axes | None = None,
) -> Axes

Two features against each other, coloured by point density or binned into hexagons.

Parameters:

Name Type Description Default
x ScOrMc | DataFrame

The object, or extract_feature_pair output.

required
feature_1 str | None

x feature, optionally _rna / _adt suffixed. The axis label for a frame.

None
feature_2 str | None

y feature, as feature_1.

None
geom Literal['density', 'hex']

"density" (per-point 2D KDE) or "hex".

'density'
remove_zeros bool

Drop cells where both are zero.

True
smoothness float

KDE bandwidth, in quarters of a standard deviation.

10.0
bins int

Hexagons across x.

60
modality ExprModality

Fallback modality for unsuffixed features.

'rna'
point_size float

Point size in mm.

2.5
point_alpha float

Point alpha.

0.5
raster bool | None

Rasterise the points; None does above 100,000 cells.

None
palette ContinuousPalette

The continuous palette.

'viridis'
ax Axes | None

Axes to draw on.

None

Returns:

Type Description
Axes

The axes.

Examples:

>>> ax = bv.pl.feature_scatter_plot(sc, genes[0], genes[1], geom="hex")

extract_feature_pair

extract_feature_pair(
    sc: ScOrMc,
    feature_1: str,
    feature_2: str,
    *,
    obs_cols: Sequence[str] | None = None,
    scale: bool = False,
    clip: float | None = None,
    modality: ExprModality = "rna",
    layer: Layer = "norm",
) -> DataFrame

Two features side by side for a scatter.

A _rna or _adt suffix on either feature picks its modality; without one, modality applies. Rows stay in kept cell order.

Parameters:

Name Type Description Default
sc ScOrMc

The experiment, a subset or meta cells.

required
feature_1 str

First feature, with an optional _rna / _adt suffix.

required
feature_2 str

Second feature, same convention.

required
obs_cols Sequence[str] | None

obs columns to attach.

None
scale bool

z-score each feature across the cells.

False
clip float | None

Clip the z-scores to [-clip, clip], with scale.

None
modality ExprModality

Default modality for a feature without a suffix.

'rna'
layer Layer

"norm", or "magic" for the imputed layer of run_magic.

'norm'

Returns:

Type Description
DataFrame

cell_id, feature_1, feature_2 and the obs columns, over the

DataFrame

cells both features cover.

Examples:

>>> pair = bv.pl.extract_feature_pair(sc, genes[0], genes[1])

Quality control

Plot data extractors and matplotlib plots for single cell results.

Two layers. The extract_* functions pull what one plot needs out of an experiment into a polars frame and need nothing beyond the core package. The plots draw from the same data, take the object or the frame its extractor returns, and need matplotlib, the plots extra (pip install bixverse[plots]). matplotlib is imported on first use of a plot, not with this module. Hand a plot the frame when you want to restyle it, or draw the same data with another library.

Where to start. embedding_plot for an obs column on an embedding, feature_plot for genes on an embedding, dot_plot, stacked_violin_plot and heatmap_plot for markers across groups, feature_scatter_plot for two genes against each other. The QC plots (violin_plot, density_plot, joint_plot) take the CellQc from bv.qc.run_cell_qc or a frame. paga_plot and milo_nhood_plot take the result of bv.traj.run_paga and the tested MiloR from bv.de.

What lands where. Nothing here writes to the experiment. Every plot reads the kept cells of a SingleCells, SingleCellsSubset, MetaCells or SingleCellsMultiModal and returns a matplotlib object: the single panel plots take an optional ax and return it, the multi-panel ones return the Figure. The extractors return one row per kept cell (per meta cell for MetaCells), long over genes where the plot needs it. Gene arguments are var ids.

import matplotlib.pyplot as plt

genes = sc.gene_ids()[:4].tolist()
bv.pl.embedding_plot(sc, "umap", "cell_grp", label_by="cell_grp")
bv.pl.feature_plot(sc, genes, "umap", ncol=2)
bv.pl.dot_plot(sc, genes, "cell_grp")

frame = bv.pl.extract_embedding_data(sc, "umap", obs_cols=["cell_grp"])
plt.show()

Gotchas. The embedding has to exist (bv.embed.umap and friends; "pca" works after bv.pp.calculate_pca). Numeric obs columns get a colour bar, and label_by refuses them: cluster ids stored as numbers need discrete=True. Point and label sizes are in mm and point_size=None picks a size from the cell count; above 100,000 cells the points are rasterised. density_plot needs a CellQc run with groups. violin_plot and density_plot take a plain frame too, with grouping_column and variable; the outliers are then recomputed by MAD per group.

violin_plot

violin_plot(
    x: CellQc | DataFrame,
    grouping_column: str | None = None,
    variable: str | None = None,
    *,
    direction: Direction = "twosided",
    threshold: float = 3.0,
    group_name: str | None = None,
    var_name: str | None = None,
    log_scale: bool | None = None,
    show_outlier: bool = True,
    raster: bool | None = None,
    palette: Palette = "main",
    ax: Axes | None = None,
) -> Figure

QC violins.

For a CellQc one panel per metric, cells coloured by its final outlier call, grouped by the QC groups. For a frame one panel of variable across grouping_column, outliers recomputed by MAD within each group.

Parameters:

Name Type Description Default
x CellQc | DataFrame

A CellQc, or a frame with the metric.

required
grouping_column str | None

Frame only: the x-axis groups.

None
variable str | None

Frame only: the metric.

None
direction Direction

Frame only: which tail(s) count as outliers.

'twosided'
threshold float

Frame only: MADs for an outlier.

3.0
group_name str | None

x-axis label.

None
var_name str | None

y-axis label.

None
log_scale bool | None

log10 y-axis; False for a CellQc, True for a frame when None.

None
show_outlier bool

Colour the cells by outlier call; otherwise by group.

True
raster bool | None

Rasterise the cells; None does above 100,000.

None
palette Palette

Discrete palette for the groups without show_outlier.

'main'
ax Axes | None

Frame only: axes to draw on.

None

Returns:

Type Description
Figure

The figure.

Raises:

Type Description
ValueError

For a frame without grouping_column and variable, or ax with a CellQc.

Examples:

>>> fig = bv.pl.violin_plot(qc, group_name="sample")
>>> ax = bv.pl.violin_plot(obs, "sample_id", "lib_size")

density_plot

density_plot(
    x: CellQc | DataFrame,
    grouping_column: str | None = None,
    variable: str | None = None,
    *,
    direction: Direction = "twosided",
    threshold: float = 3.0,
    var_name: str | None = None,
    log_scale: bool | None = None,
    adjust_position_label: float = 0.0,
    palette: Palette = "main",
    ax: Axes | None = None,
) -> Figure

QC densities per group with the outlier groups named.

For a CellQc (grouped, so per_group_stats exists) one panel per metric with the group calls it holds. For a frame one panel, outlier groups recomputed by MAD over the group medians.

Parameters:

Name Type Description Default
x CellQc | DataFrame

A grouped CellQc, or a frame with the metric.

required
grouping_column str | None

Frame only: the groups.

None
variable str | None

Frame only: the metric.

None
direction Direction

Frame only: which tail(s) count as outliers.

'twosided'
threshold float

Frame only: MADs for an outlier.

3.0
var_name str | None

x-axis label.

None
log_scale bool | None

log10 x-axis (densities on the log scale); False for a CellQc, True for a frame when None.

None
adjust_position_label float

x offset of the labels.

0.0
palette Palette

Discrete palette for the groups and labels.

'main'
ax Axes | None

Frame only: axes to draw on.

None

Returns:

Type Description
Figure

The figure.

Raises:

Type Description
ValueError

On an ungrouped CellQc, or a frame without grouping_column and variable.

Examples:

>>> fig = bv.pl.density_plot(qc)

joint_plot

joint_plot(
    x: CellQc | DataFrame,
    library_size: str | None = None,
    nb_features: str | None = None,
    *,
    log_scale: bool = False,
    palette: ContinuousPalette = "sequential",
    x_label: str | None = None,
    y_label: str | None = None,
) -> Figure

Genes per cell against UMIs per cell, hexbinned with marginal histograms. Any two count columns work, e.g. ATAC fragments against TSS enrichment, with the labels set.

Parameters:

Name Type Description Default
x CellQc | DataFrame

A CellQc, or a frame with both columns.

required
library_size str | None

Library size column; "log10_lib_size" for a CellQc and "lib_size" for a frame when None.

None
nb_features str | None

Genes per cell column; "log10_nnz" / "nnz".

None
log_scale bool

log10 both axes first.

False
palette ContinuousPalette

The continuous palette; the histograms take its middle.

'sequential'
x_label str | None

x-axis label; "Genes per cell" when None.

None
y_label str | None

y-axis label; "UMIs per cell" when None.

None

Returns:

Type Description
Figure

The figure: the hexbin and the two marginal histograms.

Examples:

>>> fig = bv.pl.joint_plot(qc)

tss_profile_plot

tss_profile_plot(
    x: DataFrame,
    *,
    value: Literal[
        "enrichment", "insertions"
    ] = "enrichment",
    palette: Palette = "main",
    ax: Axes | None = None,
) -> Figure

Tn5 insertions around the TSSs, one line per group (Signac TSSPlot).

Parameters:

Name Type Description Default
x DataFrame

The first frame of bv.atac.fragment_profiles.

required
value Literal['enrichment', 'insertions']

"enrichment" (over the flank background) or the raw "insertions".

'enrichment'
palette Palette

Discrete palette for the groups.

'main'
ax Axes | None

Axes to draw on.

None

Returns:

Type Description
Figure

The figure.

Examples:

>>> tss, lengths = bv.atac.fragment_profiles(x, frags, gtf, group_by="leiden")
>>> fig = bv.pl.tss_profile_plot(tss)

fragment_length_plot

fragment_length_plot(
    x: DataFrame,
    *,
    log_scale: bool = False,
    palette: Palette = "main",
    ax: Axes | None = None,
) -> Figure

Fragment length distribution, one line per group (Signac FragmentHistogram).

A good library shows the nucleosome-free peak under 147 bp and the mono- and di-nucleosome peaks near 200 and 400 bp.

Parameters:

Name Type Description Default
x DataFrame

The second frame of bv.atac.fragment_profiles.

required
log_scale bool

log10 y-axis.

False
palette Palette

Discrete palette for the groups.

'main'
ax Axes | None

Axes to draw on.

None

Returns:

Type Description
Figure

The figure.

Examples:

>>> fig = bv.pl.fragment_length_plot(lengths)

lsi_depth_plot

lsi_depth_plot(
    x: DataFrame,
    *,
    threshold: float = 0.75,
    ax: Axes | None = None,
) -> Figure

Correlation of each LSI component with the library size (Signac DepthCor).

A component that tracks sequencing depth carries depth, not biology; Signac drops the first one by default when it does. Components the LSI left out of the embedding are drawn hollow.

Parameters:

Name Type Description Default
x DataFrame

bv.atac.get_lsi_depth_cor(x).

required
threshold float

Dashed guides at +-threshold.

0.75
ax Axes | None

Axes to draw on.

None

Returns:

Type Description
Figure

The figure.

Raises:

Type Description
ValueError

If x lacks component or depth_cor.

Examples:

>>> fig = bv.pl.lsi_depth_plot(bv.atac.get_lsi_depth_cor(x))

Graphs over an embedding

Plot data extractors and matplotlib plots for single cell results.

Two layers. The extract_* functions pull what one plot needs out of an experiment into a polars frame and need nothing beyond the core package. The plots draw from the same data, take the object or the frame its extractor returns, and need matplotlib, the plots extra (pip install bixverse[plots]). matplotlib is imported on first use of a plot, not with this module. Hand a plot the frame when you want to restyle it, or draw the same data with another library.

Where to start. embedding_plot for an obs column on an embedding, feature_plot for genes on an embedding, dot_plot, stacked_violin_plot and heatmap_plot for markers across groups, feature_scatter_plot for two genes against each other. The QC plots (violin_plot, density_plot, joint_plot) take the CellQc from bv.qc.run_cell_qc or a frame. paga_plot and milo_nhood_plot take the result of bv.traj.run_paga and the tested MiloR from bv.de.

What lands where. Nothing here writes to the experiment. Every plot reads the kept cells of a SingleCells, SingleCellsSubset, MetaCells or SingleCellsMultiModal and returns a matplotlib object: the single panel plots take an optional ax and return it, the multi-panel ones return the Figure. The extractors return one row per kept cell (per meta cell for MetaCells), long over genes where the plot needs it. Gene arguments are var ids.

import matplotlib.pyplot as plt

genes = sc.gene_ids()[:4].tolist()
bv.pl.embedding_plot(sc, "umap", "cell_grp", label_by="cell_grp")
bv.pl.feature_plot(sc, genes, "umap", ncol=2)
bv.pl.dot_plot(sc, genes, "cell_grp")

frame = bv.pl.extract_embedding_data(sc, "umap", obs_cols=["cell_grp"])
plt.show()

Gotchas. The embedding has to exist (bv.embed.umap and friends; "pca" works after bv.pp.calculate_pca). Numeric obs columns get a colour bar, and label_by refuses them: cluster ids stored as numbers need discrete=True. Point and label sizes are in mm and point_size=None picks a size from the cell count; above 100,000 cells the points are rasterised. density_plot needs a CellQc run with groups. violin_plot and density_plot take a plain frame too, with grouping_column and variable; the outliers are then recomputed by MAD per group.

GraphPlotData dataclass

GraphPlotData(
    nodes: DataFrame, edges: DataFrame, embedding: str
)

A graph laid out on an embedding: the PAGA or Milo node-link plot.

Attributes:

Name Type Description
nodes DataFrame

One row per node with its position dim_1, dim_2.

edges DataFrame

from, to, weight and the segment ends x, y, xend, yend, each edge once.

embedding str

The embedding the nodes sit in, for the axis labels.

paga_plot

paga_plot(
    sc: ScOrMc,
    paga_res: PagaRes,
    *,
    embedding: str = "umap",
    threshold: float = 0.01,
    tree_only: bool = False,
    node_colour_by: str | None = None,
    show_cells: bool = True,
    label: bool = True,
    embd_modality: Modality = "rna",
    centroid: Literal["median", "mean"] = "median",
    point_size: float | None = None,
    point_alpha: float = 0.4,
    raster: bool | None = None,
    cell_colour: str = GREY["grey80"],
    edge_colour: str = GREY["grey40"],
    edge_width: tuple[float, float] = (0.2, 3.0),
    max_node_size: float = 12.0,
    palette: Palette | None = None,
    label_size: float = 3.0,
    label_color: str = "black",
    label_font: str = "bold",
    ax: Axes | None = None,
) -> Axes

The PAGA graph over an embedding, every cluster at the centroid of its cells.

Node area tracks the cell count, edge width the connectivity.

Parameters:

Name Type Description Default
sc ScOrMc

The object PAGA ran on.

required
paga_res PagaRes

The run_paga result.

required
embedding str

The embedding to place the nodes in.

'umap'
threshold float

Edges below this connectivity are dropped.

0.01
tree_only bool

Draw the maximum spanning forest.

False
node_colour_by str | None

A numeric obs column summarised per cluster, e.g. the pseudotime; the nodes are coloured by cluster otherwise.

None
show_cells bool

Draw the cells underneath.

True
label bool

Label the nodes.

True
embd_modality Modality

Where the embedding lives.

'rna'
centroid Literal['median', 'mean']

How a cluster's position is summarised.

'median'
point_size float | None

Cell size in mm; Seurat's auto size when None.

None
point_alpha float

Cell alpha.

0.4
raster bool | None

Rasterise the cells; None does above 100,000.

None
cell_colour str

Colour of the cells.

GREY['grey80']
edge_colour str

Colour of the edges.

GREY['grey40']
edge_width tuple[float, float]

Edge width range in mm.

(0.2, 3.0)
max_node_size float

Diameter of the largest node in mm.

12.0
palette Palette | None

"main" for clusters, "sequential" for node_colour_by when None.

None
label_size float

Label size in mm.

3.0
label_color str

Label colour.

'black'
label_font str

"bold", "normal" or "italic".

'bold'
ax Axes | None

Axes to draw on.

None

Returns:

Type Description
Axes

The axes.

Examples:

>>> ax = bv.pl.paga_plot(sc, paga, embedding="umap", threshold=0.05)

extract_paga_plot_data

extract_paga_plot_data(
    sc: ScOrMc,
    paga_res: PagaRes,
    *,
    embedding: str = "umap",
    cluster_col: str | None = None,
    threshold: float = 0.01,
    tree_only: bool = False,
    centroid: Literal["median", "mean"] = "median",
    node_stat_col: str | None = None,
    modality: Modality = "rna",
) -> GraphPlotData

The PAGA graph with every cluster at the centroid of its cells.

Parameters:

Name Type Description Default
sc ScOrMc

The object PAGA ran on.

required
paga_res PagaRes

The run_paga result.

required
embedding str

The embedding to place the nodes in.

'umap'
cluster_col str | None

The clustering. Defaults to PAGA's, and anything else errors: one clustering's nodes with another's edges look right and are wrong.

None
threshold float

Edges below this connectivity are dropped.

0.01
tree_only bool

The maximum spanning forest instead of the full graph.

False
centroid Literal['median', 'mean']

How a cluster's position is summarised.

'median'
node_stat_col str | None

A numeric obs column summarised per cluster the same way, into stat.

None
modality Modality

Where the embedding lives.

'rna'

Returns:

Type Description
GraphPlotData

Nodes cluster (Enum in graph order), dim_1, dim_2, n_cells

GraphPlotData

and optionally stat, without empty clusters; edges with from /

GraphPlotData

to as cluster labels.

Raises:

Type Description
ValueError

On a different cluster_col, cells whose cluster PAGA does not know, or a non-numeric node_stat_col.

Examples:

>>> graph = bv.pl.extract_paga_plot_data(sc, paga, threshold=0.05)

milo_nhood_plot

milo_nhood_plot(
    sc: ScOrMc,
    milo_res: MiloR,
    *,
    embedding: str = "umap",
    alpha: float = 0.1,
    overlap: int = 1,
    colour_by: Literal[
        "logFC", "majority_celltype"
    ] = "logFC",
    show_cells: bool = True,
    embd_modality: Modality = "rna",
    point_size: float | None = None,
    point_alpha: float = 0.4,
    raster: bool | None = None,
    cell_colour: str = GREY["grey90"],
    edge_colour: str = GREY["grey50"],
    edge_width: tuple[float, float] = (0.1, 1.5),
    size_range: tuple[float, float] = (0.5, 4.0),
    palette: Palette | None = None,
    ax: Axes | None = None,
) -> Axes

The Milo neighbourhood graph over an embedding.

With colour_by="logFC" the significant neighbourhoods are filled by logFC on a range centred on zero, drawn on top with the strongest last; the rest stay white underneath.

Parameters:

Name Type Description Default
sc ScOrMc

The object the Milo result was built on.

required
milo_res MiloR

A tested MiloR.

required
embedding str

The embedding to place the nodes in.

'umap'
alpha float

SpatialFDR threshold for significance.

0.1
overlap int

Minimum shared cells for an edge.

1
colour_by Literal['logFC', 'majority_celltype']

"logFC", or "majority_celltype" after add_nhoods_info.

'logFC'
show_cells bool

Draw the cells underneath.

True
embd_modality Modality

Where the embedding lives.

'rna'
point_size float | None

Cell size in mm; Seurat's auto size when None.

None
point_alpha float

Cell alpha.

0.4
raster bool | None

Rasterise the cells; None does above 100,000.

None
cell_colour str

Colour of the cells.

GREY['grey90']
edge_colour str

Colour of the edges.

GREY['grey50']
edge_width tuple[float, float]

Edge width range in mm.

(0.1, 1.5)
size_range tuple[float, float]

Node diameter range in mm.

(0.5, 4.0)
palette Palette | None

"diverging" (red enriched) for logFC, "main" for cell types when None.

None
ax Axes | None

Axes to draw on.

None

Returns:

Type Description
Axes

The axes.

Raises:

Type Description
ValueError

On "majority_celltype" before add_nhoods_info.

Examples:

>>> ax = bv.pl.milo_nhood_plot(sc, milo, embedding="umap", alpha=0.1)

extract_milo_plot_data

extract_milo_plot_data(
    sc: ScOrMc,
    milo_res: MiloR,
    *,
    embedding: str = "umap",
    alpha: float = 0.1,
    overlap: int = 1,
    modality: Modality = "rna",
) -> GraphPlotData

The Milo neighbourhood graph with every neighbourhood at its index cell.

Parameters:

Name Type Description Default
sc ScOrMc

The object the Milo result was built on.

required
milo_res MiloR

A tested MiloR.

required
embedding str

The embedding to place the nodes in.

'umap'
alpha float

SpatialFDR threshold for is_sig.

0.1
overlap int

Minimum shared cells for an edge.

1
modality Modality

Where the embedding lives.

'rna'

Returns:

Type Description
GraphPlotData

Nodes Nhood (0-based), dim_1, dim_2, size, every column of the

GraphPlotData

test and is_sig; edges with weight the shared cells.

Raises:

Type Description
ValueError

If untested, or the cell count moved since.

Examples:

>>> milo_graph = bv.pl.extract_milo_plot_data(sc, milo, alpha=0.1)

Palettes

Plot data extractors and matplotlib plots for single cell results.

Two layers. The extract_* functions pull what one plot needs out of an experiment into a polars frame and need nothing beyond the core package. The plots draw from the same data, take the object or the frame its extractor returns, and need matplotlib, the plots extra (pip install bixverse[plots]). matplotlib is imported on first use of a plot, not with this module. Hand a plot the frame when you want to restyle it, or draw the same data with another library.

Where to start. embedding_plot for an obs column on an embedding, feature_plot for genes on an embedding, dot_plot, stacked_violin_plot and heatmap_plot for markers across groups, feature_scatter_plot for two genes against each other. The QC plots (violin_plot, density_plot, joint_plot) take the CellQc from bv.qc.run_cell_qc or a frame. paga_plot and milo_nhood_plot take the result of bv.traj.run_paga and the tested MiloR from bv.de.

What lands where. Nothing here writes to the experiment. Every plot reads the kept cells of a SingleCells, SingleCellsSubset, MetaCells or SingleCellsMultiModal and returns a matplotlib object: the single panel plots take an optional ax and return it, the multi-panel ones return the Figure. The extractors return one row per kept cell (per meta cell for MetaCells), long over genes where the plot needs it. Gene arguments are var ids.

import matplotlib.pyplot as plt

genes = sc.gene_ids()[:4].tolist()
bv.pl.embedding_plot(sc, "umap", "cell_grp", label_by="cell_grp")
bv.pl.feature_plot(sc, genes, "umap", ncol=2)
bv.pl.dot_plot(sc, genes, "cell_grp")

frame = bv.pl.extract_embedding_data(sc, "umap", obs_cols=["cell_grp"])
plt.show()

Gotchas. The embedding has to exist (bv.embed.umap and friends; "pca" works after bv.pp.calculate_pca). Numeric obs columns get a colour bar, and label_by refuses them: cluster ids stored as numbers need discrete=True. Point and label sizes are in mm and point_size=None picks a size from the cell count; above 100,000 cells the points are rasterised. density_plot needs a CellQc run with groups. violin_plot and density_plot take a plain frame too, with grouping_column and variable; the outliers are then recomputed by MAD per group.

bx_colors

bx_colors(
    palette: Palette = "main",
    *,
    n: int = 20,
    reverse: bool = False,
) -> list[str]

The bixverse palettes.

Palettes shorter than n are ramped up (in RGB).

Parameters:

Name Type Description Default
palette Palette

"main" (MetBrewer Austria), "sequential" (Benedictus), "diverging" (Hiroshige, red to blue), "viridis" or "spectral" (reversed Spectral, indigo to dark red).

'main'
n int

Number of colours.

20
reverse bool

Reverse the order.

False

Returns:

Type Description
list[str]

Hex colours.

Examples:

>>> colours = bv.pl.bx_colors("sequential", n=5)