opendvp.tl.stats_average_samples#
- opendvp.tl.stats_average_samples(adata, categories)#
Average samples based on specified categories in adata.obs.
This function groups cells by unique combinations of the provided
categories
and computes the mean expression for each feature within each group. The result is a new, smaller AnnData object where each observation corresponds to a unique category combination.The original, pre-averaged AnnData object is stored in the
.uns
attribute of the returned object under the key ‘pre_averaged_adata’.- Return type:
Parameters#
- adataAnnData
The annotated data matrix to be averaged.
- categorieslist of str
A list of column names in
adata.obs
to group by for averaging.
Returns:#
- AnnData
A new AnnData object where observations are the unique category combinations and variables are the averaged features.
Raises:#
- ValueError
If any of the specified categories are not in
adata.obs.columns
.