mantispy.pp.sphere

Contents

mantispy.pp.sphere#

mantispy.pp.sphere(adata, method='ZCA-cor', reference='negcon', epsilon=1e-06, by=None, key_added=None, copy=False)#

Whiten profiles with a transform fitted on the reference rows.

Parameters:
  • adata (AnnData) – Object to sphere. Usually well-level profiles.

  • method (str (default: 'ZCA-cor')) – "ZCA" and "ZCA-cor" rotate back into the original feature basis, so the output columns still correspond to features and var still describes them. "PCA" and "PCA-cor" return principal components, which var no longer describes, and warn about it unless key_added is set. The -cor variants whiten the correlation instead of the covariance, so high-variance features do not dominate.

  • reference (str | None (default: 'negcon')) – Rows to fit on: "negcon" for the controls, None for everything, or the name of a boolean obs column.

  • epsilon (float (default: 1e-06)) – Regularization added to the singular values.

  • by (str | None (default: None)) – Fit and apply separately within each group of this column, e.g. per batch.

  • key_added (str | None (default: None)) – Write to layers[key_added] instead of overwriting X.

  • copy (bool (default: False)) – Return a modified copy instead of mutating in place.

Return type:

AnnData | None

Returns:

None, or the modified copy. Writes X or layers[key_added].

Raises:

ValueError – If method is unknown, reference selects no rows, a group has fewer than two reference rows, the reference holds missing or infinite values, a -cor method meets a zero-variance feature, or the reference matrix is not full rank.