opendvp.pl.upset

Contents

opendvp.pl.upset#

upset(adata, groupby, min_presence_fraction=0.7, sort_by='cardinality', return_fig=False, ax=None, **kwargs)#

Generate an UpSet plot from an AnnData object based on variable presence across groups.

Expected input is a non-imputed adata object.

Variables that are completely NaN across all samples are excluded. Variables that do not pass min_presence_fraction of the selected group are removed. e.g if 0.5, if only 40% of samples have a valid value that variable is not counted for that group. The final UpSet plot shows presence/absence of variables across the specified groups.

Parameters:
  • adata (anndata.AnnData) – Annotated data matrix with observations (samples) as rows and variables as columns.

  • groupby (str) – Column name in adata.obs used to group samples before computing presence.

  • min_presence_fraction (float, optional) – Minimum fraction of samples (within a group) where a variable must be present for that group to consider the variable as “present”. Value between 0.0 and 1.0. Default is 0.7.

  • sort_by (str, optional) – Sorter for UpSet plot: cardinality, degree, -cardinality, -degree. Default is “cardinality”.

  • return_fig (bool, optional) – Whether to return the matplotlib Figure object. Default is False.

  • **kwargs (Mapping[str, Any]) – Additional keyword arguments passed to UpSet.

Returns:

The matplotlib Figure object containing the UpSet plot, or None if not requested.

Return type:

matplotlib.figure.Figure or None

Examples

>>> upset(adata, groupby="condition", threshold=1000, min_presence_fraction=0.2)