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 |
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
|
point_alpha
|
float
|
Point alpha. |
0.5
|
raster
|
bool | None
|
Rasterise the points (vector output); |
None
|
palette
|
Palette | None
|
|
None
|
label_size
|
float
|
Label size in mm. |
3.0
|
label_color
|
str
|
Label colour. |
'black'
|
label_font
|
str
|
|
'bold'
|
ax
|
Axes | None
|
Axes to draw on. |
None
|
Returns:
| Type | Description |
|---|---|
Axes
|
The axes. |
Examples:
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, |
required |
obs_cols
|
Sequence[str] | None
|
obs columns to attach. |
None
|
modality
|
Modality
|
Where the embedding lives: |
'rna'
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
|
DataFrame
|
row per kept cell (or meta cell). |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the embedding is missing. |
Examples:
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 |
required |
features
|
Sequence[str] | None
|
Feature ids from |
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 |
None
|
expr_modality
|
ExprModality
|
|
'rna'
|
embd_modality
|
Modality
|
|
'rna'
|
expr_sc
|
ScOrMc | None
|
Where the expression comes from, e.g. the gene activity
of an ATAC experiment; |
None
|
layer
|
Layer
|
|
'norm'
|
point_size
|
float | None
|
Point size in mm; Seurat's auto size when |
None
|
point_alpha
|
float
|
Point alpha. |
0.5
|
raster
|
bool | None
|
Rasterise the points; |
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'
|
highlight_features
|
bool
|
Push the cells at or below |
False
|
highlight_quantile
|
float
|
The background quantile. |
0.25
|
scale_mode
|
Literal['free', 'shared']
|
|
'free'
|
palette
|
ContinuousPalette
|
The continuous palette. |
'sequential'
|
ncol
|
int | None
|
Panel columns; a square-ish grid when |
None
|
Returns:
| Type | Description |
|---|---|
Figure
|
The figure. |
Raises:
| Type | Description |
|---|---|
ValueError
|
Without |
Examples:
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 |
required |
embedding
|
str
|
The embedding name. |
required |
scale
|
bool
|
z-score each feature. |
False
|
clip
|
float | None
|
Clip the z-scores, with |
None
|
obs_cols
|
Sequence[str] | None
|
obs columns to attach. |
None
|
expr_modality
|
ExprModality
|
|
'rna'
|
embd_modality
|
Modality
|
|
'rna'
|
layer
|
Layer
|
|
'norm'
|
expr_sc
|
ScOrMc | None
|
Where the expression comes from; |
None
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
|
Examples:
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 |
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
|
None
|
scale_exp
|
bool
|
Min-max scale the means per feature. |
True
|
modality
|
ExprModality
|
|
'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:
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 |
required |
grouping_variable
|
str
|
obs column to group by. |
required |
scale_exp
|
bool
|
Min-max scale the means per feature into |
True
|
modality
|
ExprModality
|
|
'rna'
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
|
DataFrame
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If nothing matched or the grouping is entirely missing. |
Examples:
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 |
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 |
None
|
modality
|
ExprModality
|
|
'rna'
|
layer
|
Layer
|
|
'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:
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 |
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 |
None
|
modality
|
ExprModality
|
|
'rna'
|
layer
|
Layer
|
|
'norm'
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
|
DataFrame
|
order) and |
Examples:
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 |
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'
|
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.002
|
show_feature_labels
|
bool | None
|
Gene names on the right; |
None
|
palette
|
ContinuousPalette
|
The continuous palette; |
'diverging'
|
ax
|
Axes | None
|
Axes to draw on. |
None
|
Returns:
| Type | Description |
|---|---|
Axes
|
The axes. |
Raises:
| Type | Description |
|---|---|
ValueError
|
Without |
Examples:
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 |
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 |
None
|
modality
|
ExprModality
|
|
'rna'
|
layer
|
Layer
|
|
'norm'
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
|
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:
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 |
required |
feature_1
|
str | None
|
x feature, optionally |
None
|
feature_2
|
str | None
|
y feature, as |
None
|
geom
|
Literal['density', '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
|
palette
|
ContinuousPalette
|
The continuous palette. |
'viridis'
|
ax
|
Axes | None
|
Axes to draw on. |
None
|
Returns:
| Type | Description |
|---|---|
Axes
|
The axes. |
Examples:
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 |
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 |
None
|
modality
|
ExprModality
|
Default modality for a feature without a suffix. |
'rna'
|
layer
|
Layer
|
|
'norm'
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
|
DataFrame
|
cells both features cover. |
Examples:
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 |
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; |
None
|
show_outlier
|
bool
|
Colour the cells by outlier call; otherwise by group. |
True
|
raster
|
bool | None
|
Rasterise the cells; |
None
|
palette
|
Palette
|
Discrete palette for the groups without |
'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 |
Examples:
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 |
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); |
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 |
Examples:
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 |
required |
library_size
|
str | None
|
Library size column; |
None
|
nb_features
|
str | None
|
Genes per cell column; |
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; |
None
|
y_label
|
str | None
|
y-axis label; |
None
|
Returns:
| Type | Description |
|---|---|
Figure
|
The figure: the hexbin and the two marginal histograms. |
Examples:
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 |
required |
value
|
Literal['enrichment', '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:
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 |
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:
lsi_depth_plot
¶
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
|
|
required |
threshold
|
float
|
Dashed guides at |
0.75
|
ax
|
Axes | None
|
Axes to draw on. |
None
|
Returns:
| Type | Description |
|---|---|
Figure
|
The figure. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Examples:
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
¶
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 |
edges |
DataFrame
|
|
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 |
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
|
point_alpha
|
float
|
Cell alpha. |
0.4
|
raster
|
bool | None
|
Rasterise the cells; |
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
|
|
None
|
label_size
|
float
|
Label size in mm. |
3.0
|
label_color
|
str
|
Label colour. |
'black'
|
label_font
|
str
|
|
'bold'
|
ax
|
Axes | None
|
Axes to draw on. |
None
|
Returns:
| Type | Description |
|---|---|
Axes
|
The axes. |
Examples:
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 |
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 |
None
|
modality
|
Modality
|
Where the embedding lives. |
'rna'
|
Returns:
| Type | Description |
|---|---|
GraphPlotData
|
Nodes |
GraphPlotData
|
and optionally |
GraphPlotData
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
On a different |
Examples:
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 |
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'
|
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
|
point_alpha
|
float
|
Cell alpha. |
0.4
|
raster
|
bool | None
|
Rasterise the cells; |
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
|
|
None
|
ax
|
Axes | None
|
Axes to draw on. |
None
|
Returns:
| Type | Description |
|---|---|
Axes
|
The axes. |
Raises:
| Type | Description |
|---|---|
ValueError
|
On |
Examples:
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 |
required |
embedding
|
str
|
The embedding to place the nodes in. |
'umap'
|
alpha
|
float
|
SpatialFDR threshold for |
0.1
|
overlap
|
int
|
Minimum shared cells for an edge. |
1
|
modality
|
Modality
|
Where the embedding lives. |
'rna'
|
Returns:
| Type | Description |
|---|---|
GraphPlotData
|
Nodes |
GraphPlotData
|
test and |
Raises:
| Type | Description |
|---|---|
ValueError
|
If untested, or the cell count moved since. |
Examples:
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
¶
The bixverse palettes.
Palettes shorter than n are ramped up (in RGB).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
palette
|
Palette
|
|
'main'
|
n
|
int
|
Number of colours. |
20
|
reverse
|
bool
|
Reverse the order. |
False
|
Returns:
| Type | Description |
|---|---|
list[str]
|
Hex colours. |
Examples: