muon.MuData

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_unique on 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 obs of the modalities to the global obs

pull_var([columns, mods, common, ...])

Copy data from the var of the modalities to the global var

push_obs([columns, mods, common, prefixed, ...])

Copy the data from obs to the obs of the modalities.

push_var([columns, mods, common, prefixed, ...])

Copy the data from var to the var of 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 obs and var indices of the object with the data from all the modalities.

update_obs()

Update obs indices of the object with the data from all the modalities.

update_var()

Update var indices 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_unique on 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

axis

MuData axis.

filename

Change the backing mode by setting the filename to a .h5mu file.

is_view

Whether the object is a view of another MuData object.

isbacked

Whether the object is backed on disk.

mod

Dictionary of modalities.

mod_names

Names of modalities (alias for list(mdata.mod.keys()))

n_mod

Number of modalities.

n_obs

Total number of observations

n_var

Total number of variables.

n_vars

Total number of variables.

obs

Annotation of observation

obs_names

Names of variables (alias for .obs.index).

obsm

Multi-dimensional annotation of observations.

obsmap

Mapping of observation indices in the object to indices in individual modalities.

obsp

Pairwise annotatation of observations.

shape

Shape of data, all variables and observations combined (n_obs, n_vars).

uns

Unstructured annotation (ordered dictionary).

var

Annotation of variables.

var_names

Names of variables (alias for .var.index)

varm

Multi-dimensional annotation of variables.

varmap

Mapping of feature indices in the object to indices in individual modalities.

varp

Pairwise annotatation of variables.