Skip to main content

dansk-register-platform

A platform for epidemiological studies on the Danish national registers, and the study pipelines built on it.

The package contains no data. It is the code that reads a register delivery inside a secure research environment, builds cohorts and outcomes from it, and estimates and reports the results.

What is in it

Package Role
dansk_register The reusable platform: register catalog and I/O, the staged-pipeline runner, matching, estimation, disclosure control, figure styling
parental_income Study I: parental income after severe chronic disease in childhood
societal_costs Study II: societal costs of severe chronic disease in childhood
edu_labour_trajectories Study III: educational and labour-market trajectories from age 18
register_studies register-studies, the command that runs the studies in one job, stages their results for transfer and unpacks them after download

The dependency direction is one way and enforced by a test: the platform never imports a study, and studies never import each other. Code that turns out to be general is lifted into dansk_register rather than shared sideways.

The register runner and the estimators are Rust, compiled into the wheel as one extension module. The methods crates it builds on, cohort matching, semicontinuous models, staggered difference-in-differences and the chronic disease phenotype, are published separately and consumed by version.

Install

pip install dansk-register-platform                 # everything, all three studies
pip install "dansk-register-platform[study2]"       # names a study; installs the same files
pip install "dansk-register-platform[all]"          # all three, explicitly

Before 0.7.0 the distribution was published as dansk-register. The import packages did not change; only the name on pip install did. The old name still resolves, to a distribution that stopped being updated at the rename.

The estimators are written in polars and validated against R, so the pipeline carries no numeric stack of its own. matplotlib is a base dependency because numpy arrived on every real run anyway; what keeps the boundary real is that its imports live under a figures package and a contract test fails the build if one escapes into an estimator. Without a renderer every result is still produced and the figure stage records that it could not draw.

repair is the only optional dependency: pyarrow, for register-repair-utf8 alone. Install it with pip install 'dansk-register-platform[repair]'. The same kind of contract test keeps pyarrow out of everything else.

Commands

To run the studies on the analysis server, read docs/run_on_server.md in the source repository. What changed in each release is in CHANGELOG.md there, and the other documents are indexed in docs/README.md. This file is also the package's page on PyPI, where those files are not published, so they are named rather than linked.

register-studies --dry-run --output-dir RUN --raw-root PATH         # the plan, no data read
register-studies --output-dir RUN --raw-root PATH --only 2,3         # Studies II and III in one job
register-studies --output-dir RUN --raw-root PATH --only 1 --resume  # carry on where it stopped
register-studies unpack DOWNLOADED OUT                               # after download, on the laptop

edu-labour --list-profiles                          # what each profile runs
edu-labour-preflight --raw-root PATH                # what a delivery contains
edu-labour --output-dir RUN --profile production \
    --raw-root PATH --allow-expensive-stages --resume
edu-labour-figures --bundle RUN/outputs/export --out figures

societal-costs --capability PATH                     # what this study needs vs. what a delivery has
societal-costs --output-dir RUN --profile production \
    --raw-root PATH --allow-expensive-stages --diagnostics
societal-costs --output-dir RUN --raw-root PATH --stages secondary_sensitivity   # the arm no profile runs

register-repair-utf8 PATH --report utf8_scan.csv    # find invalid UTF-8 in converted Parquet
register-repair-utf8 PATH --fix --report utf8_fix.csv

edu-labour and societal-costs need --allow-expensive-stages for production: matching scans the whole delivery, and without the flag the runner refuses rather than silently starting a multi-hour match. register-studies gives the flag to every study under --profile production, which is its default. societal-costs --profile production runs 21 stages and edu-labour --profile production 38. secondary_sensitivity, the analyse-only sensitivity and subgroup arm of Study II, is not among them. It reads a completed run and writes into a subdirectory of it. --list-profiles on each command gives the current counts.

register-repair-utf8 needs the repair extra and says so if it is missing.

Add --dry-run to any edu-labour invocation to resolve the plan and settings without touching data.

Design notes

Stages talk through files. Every stage writes named artifacts into a run directory and reads its inputs from there, so any stage can be re-run alone against a previous run's outputs, and --resume can skip what is already done.

Estimators are written against polars. Aalen-Johansen, Fine-Gray, Cox and the multi-state occupancy are implemented directly rather than taken from a modelling library, and each is validated against reference values from R with those values checked into the tests. That keeps the numbers checkable line by line and avoids a dependency that may not install in an offline environment.

Disclosure control is part of the pipeline. Results leave the secure environment as a bundle of CSV tables with small cells suppressed and the estimates resting on them blanked. Figures are rendered from that bundle rather than from the raw artifacts, so a figure cannot show what the table beside it was not cleared to show.

What this covers, and what it does not

Secure-environment research is usually described with the Five Safes, and it is worth saying plainly which of the five a piece of software can touch at all.

Safe projects Your approval. Nothing here.
Safe people Your institution's authorisation. Nothing here.
Safe settings The host's environment, Statistics Denmark or the Danish Health Data Authority. Nothing here.
Safe data Partly here. Person identifiers are pseudonymised by Statistics Denmark before delivery, and an export is refused outright if a CPR-shaped value reaches it.
Safe outputs Partly here. Small cells are suppressed, dependent estimates blanked, file types and sizes checked against the transfer rules, and every bundle carries a manifest saying what was done and what was not.

"Partly" is the operative word in both rows. The output checks are cell-by-cell and cannot see a small number recovered by differencing across tables; each bundle's MANIFEST.txt says so in its own text. Running this framework is not a substitute for your host's output review, and it does not make an unapproved analysis approved.

Status

Research code, developed alongside the studies it implements. The public API is not stable.

Licence

MIT. See LICENSE.

Metadata

Release files for dansk-register-platform 0.28.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for dansk-register-platform 0.28.6
File Interpreter ABI Platform Actions
dansk_register_platform-0.28.6-cp312-abi3-win_amd64.whl CPython 3.12 abi3 Windows x86-64 Details for dansk_register_platform-0.28.6-cp312-abi3-win_amd64.whl

Release files / dansk_register_platform-0.28.6-cp312-abi3-win_amd64.whl

Download URL dansk_register_platform-0.28.6-cp312-abi3-win_amd64.whl
Size 9.5 MB
Tags CPython 3.12 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
39b36db3518cab80c46d4e1727bffffc1e23cf91cb0d999202e24c2ee59cc4d2
BLAKE2b-256 checksum
How to use checksums
4c682b29be28fcd92d65845b6b39672316a4830c1479f4c2166ce2c2c3488888
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.10

Security for dansk-register-platform 0.28.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.28.6 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page