opendvp.plotting.upset

Contents

opendvp.plotting.upset#

opendvp.plotting.upset(adata, groupby, threshold=0.0, min_presence_fraction=0.0, sort_by='cardinality', show=True)#

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

Presence is defined as non-NaN and above a specified threshold. Variables that are completely NaN across all samples are excluded. The final UpSet plot shows presence/absence of variables across the specified groups.

Return type:

Figure

Parameters#

adataAnnData

Annotated data matrix with observations (samples) as rows and variables as columns.

groupbystr

Column name in adata.obs used to group samples before computing presence.

thresholdfloat, optional

Minimum value to consider a variable “present” in a sample. Default is 0.0.

min_presence_fractionfloat, 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.0.

sort_bystr, optional

Sorter for UpSet plot: cardinality, degree, -cardinality, -degree

figsizetuple, optional

Size of the UpSet plot figure. Default is (10, 6).

showbool, optional

Whether to call plt.show(). Default is True.

Returns:#

matplotlib.figure.Figure

The matplotlib Figure object containing the UpSet plot.

Example:#

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