spared.gene_features.get_exp_frac

spared.gene_features.get_exp_frac(adata: AnnData) AnnData[source]

Compute the expression fraction for all genes.

The expression fraction of a gene in a slide is defined as the proportion of spots where that gene is expressed. It is a number between 0.0 and 1.0 where 0.0 means that the gene is not expressed in any spot and 1.0 means that the gene is expressed in all the spots.

To compute an aggregation of expression fractions in a complete dataset, this function gets the expression fraction for each slide and then takes the minimum across all the slides. Hence the final number is a lower bound that ensures that the gene is expressed in at least that fraction of the spots in each one of the slides.

Parameters:

adata (ad.AnnData) – A slide collection where non-expressed genes have a value of 0 in the adata.X matrix.

Returns:

The updated slide collection with the added information into the adata.var['exp_frac'] column.

Return type:

ad.AnnData