Skip to content

msmu.pp.apply_sdrf_to_obs

Project columns of the attached SDRF (uns["sdrf"]) onto each modality's obs.

The SDRF spans both axes, so it is reduced to the obs axis by the match key on and only columns that are a function of that key (one value per key group) are projected. Columns that vary within a key (e.g. comment[fraction identifier] under a channel key) cannot be represented on the obs axis; they are left untouched in uns["sdrf"] and skipped with a warning -- or, if named explicitly in columns, raise. obs never silently collapses SDRF data.

Parameters:

Name Type Description Default
mdata MuData

MuData with an SDRF attached via :func:attach_sdrf.

required
on str | Sequence[str] | None

SDRF column (or list of columns) matched against obs.index. Default None auto-picks: after split_tmt (which records its set_key in uns) it builds the composite [comment[label], set_key] matching the channel_set obs automatically; otherwise comment[label] for TMT and comment[data file] elsewhere. Pass a str or list to override (a list forces a "_"-joined composite key).

None
columns str | Sequence[str] | None

SDRF column(s) to project. Default None projects every projectable column; naming a non-projectable column raises instead of skipping it.

None
set_index str | None

After projection, replace obs.index with this SDRF column's values. Must be projectable and unique across obs. Default None keeps the index.

None

Returns:

Type Description
MuData

A copy of mdata with projected SDRF columns merged into each modality's obs;

MuData

uns["sdrf"] is left unchanged as the source of truth.