pegasus.violin

pegasus.violin(data, attrs, groupby, hue=None, matkey=None, stripplot=False, stripsize=1, inner=None, scale='width', panel_size=(8, 0.5), palette=None, 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 or MultimodalData or UnimodalData object) – Single-cell expression data.

  • attrs (str or List[str]) – Cell attributes or features to plot. Cell attributes must exist in data.obs and must be numeric. Features must exist in data.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.

  • inner (str, optional, default: None) –

    Representation of the datapoints in the violin interior:
    • If box, draw a miniature boxplot.

    • If quartiles, draw the quartiles of the distribution.

    • If point or stick, show each underlying datapoint.

    • If None, will draw unadorned violins.

  • 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.

  • panel_size (Tuple[float, float], optional, default: (8, 0.5)) – The size (width, height) in inches of each violin panel.

  • palette (List[str], optional (default: None)) – Used for setting colors for categories in groupby. Within the list, each string is the color for one category.

  • 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 if None.

  • return_fig (bool, optional, default: False) – Return a Figure object if True; return None 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 if show == False

Return type

Figure object

Examples

>>> pg.violin(data, attrs=['CD14', 'TRAC', 'CD34'], groupby='louvain_labels')