Skip to content

msmu.dt.map

Map source columns onto a target table in place, returning the same MuData.

Table paths are obs, var, <modality>.obs/var, <modality>.decoy (the decoy table in .uns["decoy"]), or [<modality>.]obsm/varm.<key> (DataFrame objects only). Index arguments name matching columns; None uses the table index without changing it. columns maps source column names to destination column names. Identical source key/value rows are collapsed; conflicting keys raise. Unmatched rows receive missing values. Existing destination columns are overwritten. Matching follows pandas, including matching missing keys. Provenance records these instructions, not the mapped column contents.

Parameters:

Name Type Description Default
mdata MuData

MuData to modify.

required
source str

Source table path: obs, var, <modality>.obs, <modality>.var, <modality>.decoy, or [<modality>.]obsm/varm.<key> containing a DataFrame.

required
target str

Destination table path using the same syntax.

required
columns dict[str, str]

Nonempty mapping from source column names to unique destination column names.

required
source_index str | None

Source matching column; None uses its index.

None
target_index str | None

Destination matching column; None uses its index.

None

Returns:

Type Description
MuData

The same MuData; destination columns are written in place.

Examples:

import msmu as mm
mm.dt.map(mdata, source="obs", target="protein.obs", columns={"condition": "condition"})