spared.filtering.filter_by_moran
- spared.filtering.filter_by_moran(adata: AnnData, n_keep: int, from_layer: str) AnnData[source]
Filter prediction genes by Moran’s I.
This function filters the genes in
adata.varby the Moran’s I statistic. It keeps then_keepgenes with the highest Moran’s I. The Moran’s I values will be selected fromadata.var[f'{from_layer}_moran']which must be already present in theadata. Ifn_keep <= 0, it means the number of genes is no specified and we proceed to automatically compute it in the following way:If
adata.n_vars > 320thenn_keep = 128.else,
n_keep = 32.
- Parameters:
adata (ad.AnnData) – The AnnData object to update. Must have
adata.var[f'{from_layer}_moran']column.n_keep (int) – The number of genes to keep. If less than
0the number of genes to keep is computed automatically.from_layer (str) – Layer for which the Moran’s I was already computed (
adata.var[f'{from_layer}_moran']).
- Returns:
The updated AnnData object with the filtered genes.
- Return type:
ad.AnnData