scparadise.scnoah.clust_diff

Contents

scparadise.scnoah.clust_diff#

scparadise.scnoah.clust_diff(adata, groupby=None, group1=None, group2=None, score1=None, score2=None, plot=True, thresh=0.02, fill=True, alpha=0.5, grid_size=500, **kwargs)[source]#

Calculates metrics to Integral of absolute density difference and Mutual Information between two clusterings. Each metric follows the principle that the higher the value, the better the clusters separate the selected scores.

adata: AnnData or MuData

Annotated data or Multimodal data.

groupby: str

The key of the grouping in AnnData.obs or MuData.obs.

group1: str

Cluster in groupby.

group2: str

Cluster in groupby.

score1: str

Score 1 in AnnData.obs or MuData.obs calculated using scanpy.tl.score_genes.

score2: str

Score 2 in AnnData.obs or MuData.obs calculated using scanpy.tl.score_genes.

plot: bool, (default: True)

Show kernel density estimate plot or not.

thresh: float in [0, 1], (default: 0.02)

Lowest iso-proportion level at which to draw a contour line.

fill: bool or None, (default: True)

If True, fill in the area under univariate density curves or between bivariate contours.

alpha: float or None, (default: 0.5)

Transparency of the rectangle and connector lines.

grid_size: int (default: 500)

Number of equally spaced grid points generated along each score axis for two-dimensional kernel density estimation (KDE) and numerical integration of the absolute density difference between groups.

The KDE is evaluated on a grid of shape (grid_size, grid_size), containing grid_size ** 2 points. Higher values provide a smoother and more precise numerical approximation of the integral of the absolute difference between the two KDE surfaces, but increase memory use and computation time approximately quadratically.

Must be at least 2. Values around 100–250 are usually sufficient for exploratory analysis; 300–500 provide a more stable estimate for final reporting; values above 500 are rarely necessary unless score ranges are very broad or the KDE contains fine local structure.

kwargs

Other keyword arguments are passed to seaborn.kdeplot.

Returns a plot and Integral of absolute density difference and Mutual Information between two clusterings.