mantispy.tl.neighbors_local_density#
- mantispy.tl.neighbors_local_density(adata, k=15, by='Metadata_ImageNumber', key_added='Metadata_LocalDensity', copy=False)#
Mean distance to the
knearest cells in the same field of view.Local crowding changes morphology independently of treatment. Consider regressing it out with
regress_out()before attributing a change to a perturbation.- Parameters:
adata (
AnnData) – Single-cell object carryingMetadata_Center_XandMetadata_Center_Y.k (
int(default:15)) – Number of neighbors averaged over.by (
str(default:'Metadata_ImageNumber')) –obscolumn identifying the field of view. Neighbors are searched within each field only, since coordinates from different images are not comparable.key_added (
str(default:'Metadata_LocalDensity')) –obscolumn written.copy (
bool(default:False)) – Return a modified copy instead of mutating in place.
- Return type:
- Returns:
None, or the modified copy. Writesobs[key_added], and a cell alone in its field getsNaN.- Raises:
KeyError –
obsis missingMetadata_Center_XorMetadata_Center_Y.