scmorph.pp.aggregate_mahalanobis#
- scmorph.pp.aggregate_mahalanobis(adata, treatment_key, control='DMSO', group_key=None, per_treatment=False, cov_include_treatment=False, cov_from_single_cell=False, progress=False)[source]#
Measure distance between groups using mahalanobis distance
- Parameters:
- adata
AnnData Annotated data matrix
- treatment_key
str Name of column in metadata used to define treatments
- control
str(default:'DMSO') Name of control treatment. Must be valid value in
treatment_key.- group_key
str|None(default:None) Name of column in metadata used to define groups, such as wells. This is needed to define the covariance matrix for Mahalanobis distance.
- per_treatment
bool(default:False) Whether to compute PCA and Mahalanobis distance for each treatment separately.
- cov_include_treatment
bool(default:False) Whether to compute covariance matrix from control alone (False) or control and treatment together (True). If True, covariance matrices are combined through a weighted sum, where weights represent the number of replicates for this drug.
- cov_from_single_cell
bool(default:False) Whether to compute covariance matrix from single cells. This computes distances directly on features with no prior PCA. As a result, cov_include_treatment and per_treatment will be ignored (both False).
- progress
bool(default:False) Whether to show a progress bar
- adata
- Return type:
- Returns:
Mahalanobis distances between treatments