spared.layer_operations.get_deltas

spared.layer_operations.get_deltas(adata: AnnData, from_layer: str, to_layer: str) AnnData[source]

Get expression deltas from the mean.

Compute the deviations from the mean expression of each gene in adata.layers[from_layer] and save them in adata.layers[to_layer]. Also add the mean expression of each gene to adata.var[f'{from_layer}_avg_exp']. Average expression is computed using only train data determined by the adata.obs['split'] column. However, deltas are computed for all observations.

Parameters:
  • adata (ad.AnnData) – The AnnData object to update. Must have expression values in adata.layers[from_layer]. Must also have the adata.obs['split'] column with 'train' values.

  • from_layer (str) – The layer to take the data from.

  • to_layer (str) – The layer to store the results of the transformation.

Returns:

The updated AnnData object with the deltas (adata.layers[to_layer]) and mean expression (adata.var[f'{from_layer}_avg_exp']) information.

Return type:

ad.AnnData