Aggregate-only profiles of LinkML-mapped data, and synthetic data drawn from them.
Participant-level data often cannot leave the environment it is held in, but the
people building on it still need data of the same shape. linkml-synth splits
that into two steps:
- Profile the real mapped output where it lives. The profile is a single JSON document describing each class: which concepts it carries, how many participants have them, how often each slot is filled and how its values are distributed. It holds no records and applies small-cell suppression.
- Emit synthetic records from one or more profiles, anywhere. Each synthetic study has the concepts, gaps and granularity of its real counterpart.
A third command, compare, profiles nothing itself: it checks the profile of a synthetic study against the profile it was drawn from.
mapped output ──profile──▶ profile.json ──emit──▶ synthetic records
▲ │
└──────compare◀─profile─┘
pip install linkml-synth# Where the real data is held
linkml-synth profile --mapped-dir path/to/mapped-data --study MyStudy --output mystudy_profile.json
# Anywhere
linkml-synth emit --config corpus.yaml --out output/
# Check the result
linkml-synth profile --mapped-dir output/study_one/mapped-data --study study_one \
--prefix SYNTH --postfix=-data --output study_one_profile.json
linkml-synth compare mystudy_profile.json study_one_profile.json --config corpus.yaml --study study_oneprofile reads TSV, JSONL, YAML or JSON files named for the class they hold
(Condition.tsv), as linkml-map writes
them, and accepts several directories to pool. emit writes one JSONL file per
class. See examples/corpus.yaml for the configuration:
how many studies and participants, and which classes, slots and concepts to
leave out.
Everything profile writes is aggregate, and these rules apply to all of it:
- No value is reported unless at least
--min-cell(default 10) distinct participants share it. Rarer values are folded into anothershare, which is never left small enough to subtract back out. - A concept, or a whole class, with fewer participants than that gets no statistics of its own.
- Counts are rounded to the nearest
--round-to(default 10). - Numeric slots report mean, standard deviation and quantiles, never a minimum or maximum, and a quantile only when enough participants sit beyond it.
- Identifiers and references report a fill rate and nothing else.
Small groups are not silently dropped. A rare concept or value is still named
when it is coded (a CURIE or an enum value), and rare concepts are described
together when their pooled size allows, so they can be represented in synthetic
data. Naming one discloses that between one and min-cell − 1 participants have
it, and nothing more. Free text is never named.
These rules reduce the risk of disclosure. They are not a formal guarantee, and a profile should still be reviewed under the release policy of the environment it was made in before it leaves.
It matches the profile: prevalence of each concept, slot fill rates, category shares, numeric distributions, which visits records fall on, and which nested objects occur together. A participant's repeated measures resemble each other.
It does not preserve what a profile does not record. Slots are drawn independently within a record, so a diagnosis does not shift the measurements it explains, and a participant's status for a condition can differ between visits. Rare concepts are given to a fixed small number of participants, which over-represents them in a small synthetic study.
The profiler is generic over classes and slots, but both commands currently
assume the conventions of the BioData Catalyst Harmonized Model:
records point at a participant with associated_participant and at a visit with
associated_visit, and are about the concept in observation_type,
condition_concept, procedure_concept or drug_concept.
See CONTRIBUTING.md and RELEASING.md.