cellxgene_census.experimental.pp.mean_variance

cellxgene_census.experimental.pp.mean_variance(query: ExperimentAxisQuery, layer: str = 'raw', axis: int = 0, calculate_mean: bool = False, calculate_variance: bool = False, ddof: int = 1, nnz_only: bool = False) DataFrame

Calculate mean and/or variance along the obs axis from query results. Calculations are done in an accumulative chunked fashion. For the mean and variance calculations, the total number of elements (N) is, by default, the corresponding dimension size: for column-wise calculations (axis = 0) N is number of rows, for row-wise calculations (axis = 1) N is number of columns. For metrics calculated only on nnz (explicitly stored)values of the sparse matrix, specify nnz_only=True.

Parameters:
  • query – A SOMA query, specifying the obs/var selection over which mean and variance are calculated.

  • layer – X layer used, e.g., raw

  • axis – Axis or axes along which the statistics are computed

  • calculate_mean – If True it calculates mean, otherwise skips calculation

  • calculate_variance – If True it calculates variance, otherwise skips calculation

  • ddof – “Delta Degrees of Freedom”: the divisor used in the calculation for variance is N - ddof, where N represents the number of elements.

  • nnz_only – If True mean and variance will only be calculated over explicitly stored values in the sparse matrix. Defaults to False.

Returns:

Pandas DataFrame indexed by the soma_joinid and with columns mean (if calculate_mean = True), and variance (if calculate_variance = True)

Lifecycle

experimental