mantispy.tl.subpopulation_hits#
- mantispy.tl.subpopulation_hits(adata, cluster_key='leiden', groupby='Metadata_Perturbation', reference='negcon', use_rep=None, min_cells=3, key_added='subpopulation_hits', copy=False)[source]#
Test each perturbation against the controls within each cluster.
An effect confined to one cell state is diluted by the other states in a well median. Comparing cells within a cluster avoids that.
- Parameters:
adata (
AnnData) – Clustered single-cell object.cluster_key (
str(default:'leiden')) –obscolumn holding the cluster label.groupby (
str(default:'Metadata_Perturbation')) –obscolumn holding the perturbation.reference (
str|None(default:'negcon')) – Which rows are the controls,"negcon"or the name of a booleanobscolumn.use_rep (
str|None(default:None)) – Measure inobsm[use_rep]instead ofX.min_cells (
int(default:3)) – Skip a (cluster, group) pair with fewer cells than this on either side.key_added (
str(default:'subpopulation_hits')) – Name for the output table.copy (
bool(default:False)) – Return a modified copy instead of mutating in place.
- Return type:
- Returns:
None, or the modified copy. Writesuns["mantispy"][key_added]withcluster,group,n_cells,statistic(KS),pvalueandqvalue.
Notes
Each cell is reduced to its Euclidean distance from the control centroid of its own cluster, and a KS test compares the treated cells’ distances with the controls’. This is close to
hit_calling(method="ks"), restricted to comparable cells. A distance is used rather than a single feature so that the test means the same on every dataset.