pegasus.violin¶
-
pegasus.
violin
(data, attrs, groupby, hue=None, matkey=None, stripplot=False, scale='width', panel_size=(8, 0.5), left=0.15, bottom=0.15, wspace=0.1, ylabel=None, return_fig=False, dpi=300.0, **kwargs)[source]¶ Generate a stacked violin plot.
- Parameters
data (
AnnData
orMultimodalData
orUnimodalData
object) – Single-cell expression data.attrs (
str
orList[str]
) – Cell attributes or features to plot. Cell attributes must exist indata.obs
and must be numeric. Features must exist indata.var
.groupby (
str
) – A categorical variable in data.obs that is used to categorize the cells, e.g. Clusters.hue (
str
, optional, default: None) – ‘hue’ should be a categorical variable in data.obs that has only two levels. Set ‘hue’ will show us split violin plots.matkey (
str
, optional, default:None
) – If matkey is set, select matrix with matkey as keyword in the current modality. Only works for MultimodalData or UnimodalData objects.stripplot (
bool
, optional, default:False
) – Attach a stripplot to the violinplot or not. This option will be automatically turn off if ‘hue’ is set.scale (
str
, optional, default:width
) –- The method used to scale the width of each violin:
If
width
, each violin will have the same width.If
area
, each violin will have the same area.If
count
, the width of the violins will be scaled by the number of observations in that bin.
jitter (
float
orbool
, optional, default:False
) – Amount of jitter (only along the categorical axis) to apply to stripplot. This is used only whenstripplot
is set toTrue
. This can be useful when you have many points and they overlap, so that it is easier to see the distribution. You can specify the amount of jitter (half the width of the uniform random variable support), or just useTrue
for a good default.panel_size (
Tuple[float, float]
, optional, default:(8, 0.5)
) – The size (width, height) in inches of each violin panel.left (
float
, optional, default:0.15
) – This parameter sets the figure’s left margin as a fraction of panel’s width (left * panel_size[0]).bottom (
float
, optional, default:0.15
) – This parameter sets the figure’s bottom margin as a fraction of panel’s height (bottom * panel_size[1]).wspace (
float
, optional, default:0.1
) – This parameter sets the width between panels and also the figure’s right margin as a fraction of panel’s width (wspace * panel_size[0]).ylabel (
str
, optional, default:None
) – Y-axis label. No label to show ifNone
.return_fig (
bool
, optional, default:False
) – Return aFigure
object ifTrue
; returnNone
otherwise.dpi (
float
, optional, default:300.0
) – The resolution in dots per inch.kwargs – Are passed to
seaborn.violinplot
.
- Returns
A
matplotlib.figure.Figure
object containing the dot plot ifshow == False
- Return type
Figure
object
Examples
>>> pg.violin(data, attrs=['CD14', 'TRAC', 'CD34'], groupby='louvain_labels')