smftools.preprocessing.clean_NaN#
- smftools.preprocessing.clean_NaN(adata, layer=None, uns_flag='clean_NaN_performed', bypass=False, force_redo=True, layers_to_build=None, on_layer=None, keep_in_adata=True)#
Append layers to
adatathat contain NaN-cleaning strategies.Uses numpy float32 operations throughout to avoid the memory overhead of converting to a float64 pandas DataFrame.
- Parameters:
adata (
AnnData) -- AnnData object.layer (
str|None(default:None)) -- Layer to fill NaN values in. IfNone, usesadata.X.uns_flag (
str(default:'clean_NaN_performed')) -- Flag inadata.unsindicating prior completion.bypass (
bool(default:False)) -- Whether to skip processing.force_redo (
bool(default:True)) -- Whether to rerun even ifuns_flagis set.layers_to_build (
Optional[List[str]] (default:None)) -- Which NaN-fill strategy layers to create. Valid values:fill_nans_closest,nan0_0minus1,nan1_12,nan_minus_1,nan_half. Defaults to["nan0_0minus1", "nan_half"].on_layer (
Optional[Callable[[str,ndarray],None]] (default:None)) -- Optional callback invoked ason_layer(name, array)immediately after each variant is computed -- lets a caller write (and free) it right away instead of waiting for every variant to accumulate inadata.layersfirst. Each variant derives independently from the same source (layerorX), so this is safe regardless of call order.keep_in_adata (
bool(default:True)) -- WhenFalse, a variant is not also assigned intoadata.layersafteron_layerfires -- avoids holding both the callback's copy and anadata.layerscopy at once. Ignored (a variant is always assigned) whenon_layerisNone, since that's the only place the array would otherwise end up.
- Return type: