scrnatools.plotting.gene_violinplot
- scrnatools.plotting.gene_violinplot(adata: AnnData, gene_list: List[str], x_key: str, layer: str = 'X', x_values: List[str] = ['All'], hue_key: str | None = None, hue_values: List[str] = ['All'], ncols: int | None = None, nrows: int | None = None, save_path: str | None = None, dpi: int = 300, fig_size: Tuple[float] = (0.5, 2.5), *args, **kwargs)[source]
Plots violinplot subplots of expression of genes.
- Parameters:
adata (AnnData) – The dataset containing the gene expression and cell data.
gene_list (List[str]) – A list of genes to plot.
x_key (str) – The categorical grouping to display on the x axis of the violinplot.
layer (str, optional) – The layer containing expression data to use for the violinplot, can be a layer in ‘adata.layers’ or ‘X’ to use the data stored in adata.X. Defaults to “X”.
x_values (List[str], optional) – Values from x key group to display on violinplot. Defaults to [‘All’].
hue_key (str, optional) – The categorical grouping to color the grouped violin plots by. Values will appear in legend. If ‘hue_key’ is ‘None’ no hue splitting of x values will occur. Defaults to None.
hue_values (List[str], optional) – Values from hue_key to display on violinplot. Defaults to [‘All’].
ncols (int, optional) – Number of columns to display the violinplots. Defaults to None.
nrows (int, optional) – Number of rows to display the violinplots. Defaults to None.
save_path (str, optional) – The path to save the figure. Defaults to None.
dpi (int, optional) – The resolution of the saved image. Defaults to 300.
fig_size (Tuple[float], optional) – The scaling factors for the column and row size in the figure. Defaults to (0.5, 2.5).
- Raises:
ValueError – If a gene in ‘gene_list’ provided is not in provided AnnData layer.
ValueError – If the ‘x_values’ provided less than 2.
ValueError – If the ‘hue_values’ is provided but hue_key is not provided.
ValueError – If the ‘hue_values’ provided less than 2 if hue_key is also provided.
ValueError – If ncols * nrows is less than length of gene list provided.
ValueError – If a value in ‘x_values’ provided is not in AnnData layer x key.
ValueError – If a value in ‘hue_values’ provided is not in AnnData layer hue key given hue key is also provided.