msmu.pp.calculate_missingness
Count missing values per feature and record the counts in .var (and on the decoys).
Writes .var["n_missing"], the number of samples without a value for the feature, and
.var["missing_ratio"], that count divided by the number of samples. With group_obs, an
.obs column of the modality, .var["missing_ratio_<level>"] is added for every level present,
so a filter can be set within one group. Existing columns are overwritten: recompute after
removing samples, because apply_filter does not update them.
Decoys have identifications but no quantification, so a missingness filter has nothing to
judge them on. They receive the same columns with 0 / 0.0, which the usual
"missing at most" filters (le/lt) keep; a filter in the other direction (ge/gt
on missingness) would drop every decoy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mdata
|
MuData
|
|
required |
modality
|
str
|
Modality whose |
required |
group_obs
|
str | None
|
Optional |
None
|
Returns:
| Type | Description |
|---|---|
MuData
|
A copy of |
Examples:
import msmu as mm
mdata = mm.pp.calculate_missingness(mdata, modality="protein", group_obs="condition")
mdata = mm.pp.add_filter(mdata, modality="protein", column="missing_ratio", keep="lt", value=0.5)
mdata = mm.pp.apply_filter(mdata, modality="protein")