mantispy.tl.feature_signature

mantispy.tl.feature_signature#

mantispy.tl.feature_signature(adata, key='differential', by=('feature_group', 'channel', 'object'), statistic='t')[source]#

Collapse a differential table into a perturbation-by-feature-family matrix.

Parameters:
  • adata (AnnData) – Object carrying uns["mantispy"][key], as written by differential_features().

  • key (str (default: 'differential')) – Which table to collapse.

  • by (Sequence[str] (default: ('feature_group', 'channel', 'object'))) – var columns whose combination names a family. The default is the feature group, the channel it was measured in, and the compartment it was measured on.

  • statistic (str (default: 't')) – Column of the table to average within each family, such as "t" or "difference" (the raw contrast).

Return type:

AnnData

Returns:

A new AnnData of perturbations by families, with each family’s by columns and n_features in var, beside the schema’s remaining annotation columns, left empty because a family is not a measurement they describe. A by column carries the family’s own value, in the dtype var held it in; the "none" that names a family whose features had no value appears in the family’s name, not in the column. It is a perturbation-level profile object, so neighbors(), leiden() and nn_moa_classify() accept it.

Raises:
  • KeyError – uns["mantispy"][key] is missing, that table has no statistic column, or var is missing one of the by columns.

  • ValueError – by names the same column more than once, which would give one family two copies of a component; every by column is empty, so there is no family to name; or two different sets of values name the same family.

Notes

Signed statistics are averaged, so a family that decreased stays distinct from one that increased. On BBBC021, microtubule stabilizers score +2.2 on Intensity | CorrTub | Nuclei, while destabilizers score +1.4 on Intensity | CorrActin | Nuclei with no tubulin signal; as the microtubules come apart the cells round up, which is the largest remaining change.