spared.denoising.median_cleaner
- spared.denoising.median_cleaner(collection: AnnData, from_layer: str, to_layer: str, n_hops: int, hex_geometry: bool) AnnData[source]
Remove noise with adaptive median filter.
Function that cleans noise (missing data) with the modified adaptive median initially proposed by SEPAL filter for each slide in an AnnData collection. Windows to compute the medians are defined by topological distances (hops) in the neighbors graph defined by the
hex_geometryparameter with a maximum window size ofn_hops. The adaptive median filter denoises each gene independently. In other words gene A has no influence on the denoising of gene B. The data will be taken fromadata.layers[from_layer]and the results will be stored inadata.layers[to_layer].- Parameters:
collection (ad.AnnData) – The AnnData collection to process.
from_layer (str) – The layer to compute the adaptive median filter from. Where to clean the noise from.
to_layer (str) – The layer to store the results of the adaptive median filter. Where to store the cleaned data.
n_hops (int) – The maximum number of concentric rings in the neighbors graph to take into account to compute the median. Analogous to the maximum window size.
hex_geometry (bool) –
Trueif the graph has hexagonal spatial geometry (Visium technology). IfFalse, then the graph is a grid.
- Returns:
New AnnData collection with the results of the adaptive median filter stored in
adata.layers[to_layer].- Return type:
ad.AnnData