grassp.pp.calculate_replicate_cv

grassp.pp.calculate_replicate_cv#

calculate_replicate_cv(data, grouping_columns, is_log, layer=None, ignore_zeros=True, inplace=True)[source]#

Calculate the coefficient of variation for each protein across replicates.

Parameters:
data AnnData

The annotated data matrix with proteins as observations (rows).

grouping_columns Union[str, List[str]]

Column name(s) in data.obs to group samples into replicates.

is_log bool

Whether the data is log-transformed, this determines the CV formula used.

layer str | None (default: None)

Layer to use for calculation, if None, the .X object is used.

ignore_zeros bool (default: True)

Whether to ignore zero values.

inplace bool (default: True)

Whether to modify data in place or return the result. If False, returns a DataFrame with the CVs.

Return type:

DataFrame | None

Returns:

  • If inplace=True, modifies the input AnnData object and returns None. The following fields are added to the AnnData object: - .obs["mean_replicate_cv"]: Mean CV across replicates. - .obsm["replicate_cv"]: Replicate CVs per group. - .uns["obsm_replicate_cv_headers"]: Headers for the replicate CVs matrix.

  • If inplace=False, returns a DataFrame with the CVs per group.