matrixplot#
- matrixplot(data: AnnData, keys: Sequence[str] | Mapping[str, Sequence[str]], group_by: str, *, mapping: FeatureSpec | None = None, geom: Literal['raster', 'tile'] = 'raster', scale_axis: Literal[0, 1] | None = None, dendrogram: bool = False, group_lines: bool = True, group_lines_color: str = 'black', group_lines_size: float = 1.0, dendrogram_color: str = 'black', dendrogram_size: float = 0.5, group_lines_kwargs: dict | None = None, dendrogram_kwargs: dict | None = None, key_labels: bool = True, value_column: str = 'value', variable_column: str = 'variable', color_low: str = '#0000ff', color_mid: str = '#ffffff', color_high: str = '#ff0000', mid_point: Literal['mean', 'median', 'mid'] | float = 'mid', axis: Literal[0, 1] | None = 0, observations_name: str = 'Barcode', variables_name: str = 'Variable', include_dimensions: bool | int = False, interactive: bool = False, **geom_kwargs) PlotSpec#
Matrix plot.
Basically a heatmap with fixed
aggregate=Trueargument.- Parameters:
data (
AnnData) – The AnnData object of the single cell data.keys (
Sequence[str] | Mapping[str,Sequence[str]]) – Variable keys to include. When a mapping is provided, each entry maps a group label to the keys belonging to that group; the keys are placed on the x-axis in mapping order. The same key cannot appear in more than one group.group_by (
str) – The key to group the data by.mapping (
FeatureSpec | None, defaultNone) – Aesthetic mappings for the plot, the result of aes().geom (
{'raster', 'tile'}, default'raster') – The geom to use. Use ‘raster’ for performance. Use ‘tile’ to enable tooltips.scale_axis (
{0, 1}| None, defaultNone) – Whether to standardize a dimension between 0 and 1. Subtracts the minimum and divides by the maximum. If 0, standardize each variable (column). If 1, standardize each group (row).dendrogram (
bool, defaultFalse) – Whether to add a dendrogram for thegroup_byaxis. Usesscanpy.tl.dendrogramif not already computed.group_lines (
bool, defaultTrue) – Whether to draw horizontal lines within the plot separating groups.group_lines_color (
str, default'black') – Color of the group separator lines.group_lines_size (
float, default1.0) – Size (thickness) of the group separator lines.dendrogram_color (
str, default'black') – Color of the dendrogram segments.dendrogram_size (
float, default0.5) – Size (thickness) of the dendrogram segments.group_lines_kwargs (
dict | None, defaultNone) – Additional parameters to pass to the group separator lines geom_segment.dendrogram_kwargs (
dict | None, defaultNone) – Additional parameters to pass to the dendrogram geom_segment.key_labels (
bool, defaultTrue) – Whether to draw bracket labels above the plot whenkeysis a mapping.value_column (
str, default'value') – Name for the value column after unpivoting.variable_column (
str, default'variable') – Name for the variable column after unpivoting.color_low (
str, default'#0000ff') – Color for low values in the gradient.color_mid (
str, default'#ffffff') – Color for mid values in the gradient.color_high (
str, default'#ff0000') – Color for high values in the gradient.mid_point (
{'mean', 'median', 'mid'}| float, default'mid') – Midpoint for the color gradient.axis (
{0,1}| None, default0) – Axis of the data, 0 for observations and 1 for variables.observations_name (
str, default'Barcode') – The name of the observations column.variables_name (
str, default'Variable') – Name for the variables index column.include_dimensions (
bool | int, defaultFalse) – Whether to include dimensions in the DataFrame. Providing an integer will limit the number of dimensions to given number.interactive (
bool, defaultFalse) – Whether to make the plot interactive.**geom_kwargs – Additional parameters for the heatmap geom layer.
- Returns:
PlotSpec– Matrix plot.
Examples
Matrix plot of marker expression aggregated per cell type.
import scanpy as sc from lets_plot import * import cellestial as cl data = sc.read("data/pbmc3k_pped.h5ad") markers = ["C1QA", "PSAP", "CD79A", "CD79B", "CST3", "LYZ"] cl.matrixplot( data, group_by="cell_type_lvl1", keys=markers, dendrogram=True, )
Standardize per-variable so each marker spans 0-1 across groups.
cl.matrixplot( data, group_by="cell_type_lvl1", keys=markers, scale_axis=0, )