muon.MuData#
- class muon.MuData(data: AnnData | Mapping[str, AnnData] | MuData | None = None, feature_types_names: Mapping[str, str] | None = mappingproxy({'Gene Expression': 'rna', 'Peaks': 'atac', 'Antibody Capture': 'prot'}), as_view: bool = False, index: tuple[slice | int, slice | int] | slice | int | None = None, **kwargs)#
Multimodal data object
MuData represents modalities as collections of AnnData objects as well as includes multimodal annotations such as embeddings and neighbours graphs learned jointly on multiple modalities and generalised sample and feature metadata tables.
- Parameters:
data – AnnData object or dictionary with AnnData objects as values. If a dictionary is passed, the keys will be used as modality names. If None, creates an empty MuData object.
feature_types_names – Dictionary to map feature types encoded in data.var[“feature_types”] to modality names. Only relevant when data is an AnnData object. Default: {“Gene Expression”: “rna”, “Peaks”: “atac”, “Antibody Capture”: “prot”}
as_view – Create a view of the MuData object.
index – Index to slice the MuData object when creating the view.
**kwargs – Additional arguments to create a MuData object.
- __init__(data: AnnData | Mapping[str, AnnData] | MuData | None = None, feature_types_names: Mapping[str, str] | None = mappingproxy({'Gene Expression': 'rna', 'Peaks': 'atac', 'Antibody Capture': 'prot'}), as_view: bool = False, index: tuple[slice | int, slice | int] | slice | int | None = None, **kwargs)#
Methods
__init__([data, feature_types_names, ...])copy([filename])Make a copy.
obs_keys()List keys of observation annotation
obs.obs_names_make_unique()Call
AnnData.obs_names_make_uniqueon each modality.obs_vector(key[, layer])Return an array of values for the requested key of length n_obs.
obsm_keys()List keys of observation annotation
obsm.pull_obs([columns, mods, common, ...])Copy data from the
obsof the modalities to the globalobspull_var([columns, mods, common, ...])Copy data from the
varof the modalities to the globalvarpush_obs([columns, mods, common, prefixed, ...])Copy the data from
obsto theobsof the modalities.push_var([columns, mods, common, prefixed, ...])Copy the data from
varto thevarof the modalities.strings_to_categoricals([df])Transform string annotations to categoricals.
to_anndata(**kwargs)Convert the object to
AnnData.uns_keys()List keys of unstructured annotation.
update()Update both
obsandvarindices of the object with the data from all the modalities.update_obs()Update
obsindices of the object with the data from all the modalities.update_var()Update
varindices of the object with the data from all the modalities.var_keys()List keys of variable annotation
var.var_names_make_unique()Call
AnnData.var_names_make_uniqueon each modality.var_vector(key[, layer])Return an array of values for the requested key of length n_var.
varm_keys()List keys of variable annotation
varm.write([filename])Write the object to an HDF5 file.
write_h5mu([filename])Write the object to an HDF5 file.
write_zarr(store, **kwargs)Write the object to a Zarr store.
Attributes
axisMuData axis.
filenameChange the backing mode by setting the filename to a .h5mu file.
is_viewWhether the object is a view of another
MuDataobject.isbackedWhether the object is backed on disk.
modDictionary of modalities.
mod_namesNames of modalities (alias for list(mdata.mod.keys()))
n_modNumber of modalities.
n_obsTotal number of observations
n_varTotal number of variables.
n_varsTotal number of variables.
obsAnnotation of observation
obs_namesNames of variables (alias for .obs.index).
obsmMulti-dimensional annotation of observations.
obsmapMapping of observation indices in the object to indices in individual modalities.
obspPairwise annotatation of observations.
shapeShape of data, all variables and observations combined (
n_obs,n_vars).unsUnstructured annotation (ordered dictionary).
varAnnotation of variables.
var_namesNames of variables (alias for .var.index)
varmMulti-dimensional annotation of variables.
varmapMapping of feature indices in the object to indices in individual modalities.
varpPairwise annotatation of variables.