anndata.experimental.AnnCollection.convert
- property AnnCollection.convert
On the fly converters for keys of attributes and data matrix.
A function or a Mapping of functions which will be applied to the values of attributes (
.X
) or to specific keys of these attributes (.obs
,.obsm
,.layers
) of subset objects. The converters are not applied to.obs
and.obsm
(if present) of this object, only to the attributes of subset objects. The keys of the the Mapping should correspond to the attributes or keys of the attributes (hierarchically) and the values should be functions used for conversion.Examples
{ 'X': lambda a: a.toarray() if issparse(a) else a, # densify .X 'obsm': lambda a: np.asarray(a, dtype='float32'), # change dtype for all keys of .obsm 'obs': dict(key1 = lambda c: c.astype(str)) # change type only for one key of .obs }