mantispy.pl.density#
- mantispy.pl.density(adata, feature, groupby='Metadata_Perturbation', key='Metadata_LocalDensity', max_groups=6, ax=None)#
Local cell density against a feature, per group.
Crowding alone changes morphology. Use this plot to check whether density explains a phenotype before regressing it out with
regress_out(). A group whose points fall on the same line as the controls differs from them only in density.- Parameters:
adata (
AnnData) – Single-cell object carrying the density column and the feature.feature (
str) – Feature to plot against density.groupby (
str(default:'Metadata_Perturbation')) – Column defining the groups drawn.key (
str(default:'Metadata_LocalDensity')) –obscolumn holding the local density.max_groups (
int(default:6)) – Number of groups drawn, largest first.
- Return type:
- Returns:
The axes drawn on, with a scatter and a fitted line per group and each group’s Pearson correlation between density and the feature in the legend. A group with fewer than three usable points is left out.
- Raises:
KeyError –
obshas nokeycolumn, orfeatureis not one ofvar_names.