expression#
- expression(data: AnnData, key: str, *, mapping: FeatureSpec | None = None, dimensions: Literal['umap', 'pca', 'tsne'] = 'umap', use_key: str | None = None, xy: tuple[int, int] | Sequence[int] = (1, 2), size: float | None = 0.8, variable_keys: Sequence[str] | str | None = None, tooltips: Literal['none'] | Sequence[str] | FeatureSpec | None = None, interactive: bool = False, observations_name: str = 'Barcode', color_low: str = '#e6e6e6', color_mid: str | None = None, color_high: str = '#377eb8', mid_point: Literal['mean', 'median', 'mid'] | float = 'median', axis_type: Literal['axis', 'arrow'] | None = 'axis', arrow_length: float = 0.25, arrow_size: float = 1, arrow_color: str = '#3f3f3f', arrow_angle: float = 10, legend_ondata: bool = False, ondata_size: float = 12, ondata_color: str = '#3f3f3f', ondata_fontface: str = 'bold', ondata_family: str = 'sans', ondata_alpha: float = 1, ondata_weighted: bool = True, **point_kwargs) PlotSpec#
Dimensionality reduction plot of expression data.
- Parameters:
data (
AnnData) – The AnnData object of the single cell data.key (
str) – The key (gene names) to color the points by.mapping (
FeatureSpec | None, defaultNone) – Additional aesthetic mappings for the plot, the result of aes().dimensions (
{'umap', 'pca', 'tsne'}, default'umap') – The dimensionality reduction method to use. e.g., ‘umap’ or ‘pca’ or ‘tsne’.use_key (
str, defaultNone) – The specific key to use for the desired dimensions. e.g., ‘X_umap_2d’ or ‘X_pca_2d’. Otherwise, the function will decide on the key based on the dimensions.xy (
tuple[int,int] | Sequence[int], default(1,2)) – The x and y axes to use for the plot. e.g., (1, 2) for UMAP1 and UMAP2.size (
float | None, default0.8) – The size of the points.variable_keys (
str | Sequence[str] | None, defaultNone) – Variable keys to add to the DataFrame. If None, no additional keys are added.tooltips (
{'none'}| Sequence[str] | FeatureSpec | None, defaultNone) – Tooltips to show when hovering over the geom. Accepts Sequence[str] or result of layer_tooltips() for more complex tooltips. Use ‘none’ to disable tooltips.interactive (
bool, defaultFalse) – Whether to make the plot interactive.observations_name (
str, default'Barcode') – The name to give to barcode (or index) column in the dataframe.color_low (
str, default'#e6e6e6') –The color to use for the low end of the color gradient.
Accepts:
hex code e.g. ‘#f1f1f1’
color name (https://lets-plot.org/python/pages/named_colors.html).
RGB/RGBA e.g. ‘rgb(0, 0, 255)’, ‘rgba(0, 0, 255, 0.5)’.
Applies to continuous (non-categorical) data.
color_mid (
str, defaultNone) –The color to use for the middle part of the color gradient.
Accepts:
hex code e.g. ‘#f1f1f1’
color name (https://lets-plot.org/python/pages/named_colors.html).
RGB/RGBA e.g. ‘rgb(0, 0, 255)’, ‘rgba(0, 0, 255, 0.5)’.
Applies to continuous (non-categorical) data.
color_high (
str, default'#377EB8') –The color to use for the high end of the color gradient.
Accepts:
hex code e.g. ‘#f1f1f1’
color name (https://lets-plot.org/python/pages/named_colors.html).
RGB/RGBA e.g. ‘rgb(0, 0, 255)’, ‘rgba(0, 0, 255, 0.5)’.
Applies to continuous (non-categorical) data.
mid_point (
{'mean', 'median', 'mid'}| float, default'median') – The midpoint (in data value) of the color gradient. Can be ‘mean’, ‘median’ and ‘mid’ or a number (float or int). - If ‘mean’, the midpoint is the mean of the data. - If ‘median’, the midpoint is the median of the data. - If ‘mid’, the midpoint is the mean of ‘min’ and ‘max’ of the data.axis_type (
{'axis', 'arrow'}| None) – Whether to use regular axis or arrows as the axis.arrow_length (
float, default0.25) – Length of the arrow head (px).arrow_size (
float, default1) – Size of the arrow.arrow_color (
str, default'#3f3f3f') –Color of the arrows.
Accepts:
hex code e.g. ‘#f1f1f1’
color name (https://lets-plot.org/python/pages/named_colors.html).
RGB/RGBA e.g. ‘rgb(0, 0, 255)’, ‘rgba(0, 0, 255, 0.5)’.
- arrow_anglefloat, default=10
Angle of the arrow head in degrees.
- legend_ondata: bool, default=False
whether to show legend on data
- ondata_size: float, default=12
size of the legend (text) on data.
- ondata_color: str, default=’#3f3f3f’
color of the legend (text) on data
- ondata_fontface: str, default=’bold’
fontface of the legend (text) on data. https://lets-plot.org/python/pages/aesthetics.html#font-face
- ondata_family: str, default=’sans’
family of the legend (text) on data. https://lets-plot.org/python/pages/aesthetics.html#font-family
- ondata_alpha: float, default=1
alpha (transparency) of the legend on data.
- ondata_weighted: bool, default=True
whether to use weighted mean for the legend on data. If True, the weighted mean of the group means is used. If False, the arithmetic mean of the group means is used.
- **point_kwargs
Additional parameters for the geom_point layer. For more information on geom_point parameters, see: https://lets-plot.org/python/pages/api/lets_plot.geom_point.html
- Returns:
PlotSpec– Dimensionality reduction plot.
Examples
Dimensionality reduction plot with continuous data.
import scanpy as sc from lets_plot import * import cellestial as cl data = sc.read_h5ad("data/pbmc3k_pped.h5ad") cl.expression(data,key="CD14",axis_type="arrow",color_high="red")