Sample metadata#
Sample metadata (demographics, clinical data, lab values, …) to the NPX data, and see exactly which IDs have no match.
add_sample_info#
Add the columns of your sample metadata to the NPX data, and report every ID without a match.
Inputs
| Argument | Type | Default | Meaning |
|---|---|---|---|
npx |
DataFrame | — | table from read_npx |
samples |
DataFrame, or path to a .csv / .xlsx file |
— | your sample metadata, one row per sample |
on |
str | — | the column in your sample metadata holding the same IDs as the NPX data (e.g. "FIF ID") |
npx_on |
str | "SampleID" |
the ID column in the protein data |
verbose |
bool | True |
print the matching report |
Output. The protein table with:
- every column of your sample metadata added. NPX rows without a match are kept, with empty sample metadata;
- a column
samplewith the tidy ID used for matching: spaces at the ends removed, capitals, and spaces, underscores and hyphens treated the same, so"308 BIS","308_bis"and"308-BIS"all become"308_BIS". Leading zeros are kept ("058"stays"058").apply_qcand the bridging functions match IDs the same way; - the ending
_sampleliston sample-list columns whose name already exists in the protein data (e.g.PlateID_samplelist).
The matching report is stored in df.attrs["sample_report"]. It lists:
- how many samples matched, and how many only after tidying the IDs;
- which IDs are only in the protein data (marked WARNING);
- which IDs are only in your sample metadata.
Errors
KeyError:onis missing from your sample metadata, ornpx_onfrom the NPX data.ValueError: your sample metadata have the same ID twice (after tidying). Each sample may appear once.
Example