Skip to main content
DiNetxify Logo

About DiNetxify

DiNetxify is an open-source Python package for three-dimensional (3D) disease network analysis of large-scale electronic health record (EHR) data. It integrates data harmonization, analysis, and visualization in a single workflow for studying multimorbidity patterns and disease progression pathways. The package supports cohort, matched cohort, and exposed-only cohort designs, and is released under the GPL-3.0 license.

analytical framework

DiNetxify provides:

  • Integrated workflow: from cohort data and diagnosis records to analysis outputs and plots.
  • Flexible study designs: support for standard cohorts, matched cohorts, and exposed-only cohorts.
  • Modular analysis: use the one-step pipeline or run PheWAS, comorbidity, and trajectory analyses separately.
  • Built-in visualization: generate static and interactive figures directly from the result tables.

architecture

Installation

DiNetxify requires Python 3.10+.

pip install dinetxify

Core dependencies include numpy, pandas, matplotlib, plotly, python_louvain, networkx, scikit_learn, scipy, statsmodels>=0.14.4, lifelines>=0.27.0, and tqdm.

Quick Start

1. Load phenotype data and medical records

You can try the package with the dummy data under tests/data.

import DiNetxify as dnt

col_dict = {
    "Participant ID": "ID",
    "Exposure": "exposure",
    "Sex": "sex",
    "Index date": "date_start",
    "End date": "date_end",
}

covariates = ["age", "BMI"]

data = dnt.DiseaseNetworkData(
    study_design="cohort",
    phecode_level=1,
    date_fmt="%Y-%m-%d",
)

data.phenotype_data(
    phenotype_data_path="tests/data/dummy_phenotype.csv",
    column_names=col_dict,
    covariates=covariates,
)

data.merge_medical_records(
    medical_records_data_path="tests/data/dummy_EHR_ICD9.csv",
    diagnosis_code="ICD-9-WHO",
    column_names={
        "Participant ID": "ID",
        "Diagnosis code": "diag_icd9",
        "Date of diagnosis": "dia_date",
    },
)

data.merge_medical_records(
    medical_records_data_path="tests/data/dummy_EHR_ICD10.csv",
    diagnosis_code="ICD-10-WHO",
    column_names={
        "Participant ID": "ID",
        "Diagnosis code": "diag_icd10",
        "Date of diagnosis": "dia_date",
    },
)

2. Run the one-step analysis pipeline

disease_network_pipeline() returns five result tables:

  • phewas_result
  • com_strength_result
  • com_network_result
  • binomial_result
  • trajectory_result

Example:

from DiNetxify import disease_network_pipeline

if __name__ == "__main__":
    (
        phewas_result,
        com_strength_result,
        com_network_result,
        binomial_result,
        trajectory_result,
    ) = disease_network_pipeline(
        data=data,
        n_process=4,
        n_threshold_phewas=100,
        n_threshold_comorbidity=100,
        output_dir="./results",
        project_prefix="my_analysis",
        keep_positive_associations=True,
        method="RPCN",
        covariates=["age", "BMI"],
        matching_var_dict={"sex": "exact"},
        matching_n=2,
        correction="bonferroni",
        cutoff=0.05,
    )

Notes:

  • output_dir must already exist.
  • When using multiprocessing, keep the call inside if __name__ == "__main__":.
  • For standalone multiprocessing calls on Linux servers, phewas(), comorbidity_network(), and disease_trajectory() support multiprocessing_start_method="forkserver" or another available start method.
  • method can be 'RPCN', 'PCN_PCA', or 'CN'.

3. Visualize the results

from DiNetxify.visualization import Plot

plot = Plot(
    phewas_result=phewas_result,
)

plot_with_comorbidity = Plot(
    phewas_result=phewas_result,
    comorbidity_result=com_network_result,
)

plot_with_all_results = Plot(
    phewas_result=phewas_result,
    comorbidity_result=com_network_result,
    trajectory_result=trajectory_result,
    exposure_name="Exposure",
    exposure_location=(0, 0, 0),
    exposure_size=15,
)

plot.phewas_plot("results/phewas_plot.png")
plot_with_comorbidity.comorbidity_network_plot("results/comorbidity_network.html")
plot_with_all_results.three_dimension_plot("results/three_dimension_network.html")

Only phewas_result is always required. Add comorbidity_result for the comorbidity network plot, and add both comorbidity_result and trajectory_result for the 3D network and trajectory plots. When both network result tables are supplied, module assignment is shared across the comorbidity, trajectory, and 3D plots.

For exposed-only cohorts, set exposure_name=None, exposure_location=None, and exposure_size=None when creating the full network plot.

Documentation

Full documentation is available at:

https://hzcohort.github.io/DiNetxify/

It includes guides for:

  • data preparation and harmonization
  • one-step and step-by-step 3D analysis
  • visualization
  • table generation
  • API reference

Citation

If you use this software in your research, please cite:

  1. DiNetxify: a python package for three-dimensional disease network analysis based on electronic health record data (PMID: 41579291)
  2. Disease clusters and their genetic determinants following a diagnosis of depression: analyses based on a novel three-dimensional disease network approach (PMID: 40681841)

Contact

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dinetxify-0.1.15.tar.gz (2.4 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dinetxify-0.1.15-py3-none-any.whl (2.4 MB view details)

Uploaded Python 3

File details

Details for the file dinetxify-0.1.15.tar.gz.

File metadata

  • Download URL: dinetxify-0.1.15.tar.gz
  • Upload date:
  • Size: 2.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for dinetxify-0.1.15.tar.gz
Algorithm Hash digest
SHA256 c7ca760065f30c57722c3a39bc024dd8bc1b74af56e4e5773fcefbc5629126fa
MD5 8bf2c131e514c929b436e5a365fd731a
BLAKE2b-256 8ca3a620a581346332c6f3c120fc16d46a7f1744299796ecca472b7d37bb2e61

See more details on using hashes here.

Provenance

The following attestation bundles were made for dinetxify-0.1.15.tar.gz:

Publisher: python-publish.yml on HZcohort/DiNetxify

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dinetxify-0.1.15-py3-none-any.whl.

File metadata

  • Download URL: dinetxify-0.1.15-py3-none-any.whl
  • Upload date:
  • Size: 2.4 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for dinetxify-0.1.15-py3-none-any.whl
Algorithm Hash digest
SHA256 f585e831065d28d2570c8c1c05d4e03400ba8b5d9f6375b9de76ae2848d7bd91
MD5 9559a175e1516fc4d9fba1b6b8223e0f
BLAKE2b-256 f8e48bc733306de489373d157f33539ed7118f22ab2032fd18d07605a9e6efe0

See more details on using hashes here.

Provenance

The following attestation bundles were made for dinetxify-0.1.15-py3-none-any.whl:

Publisher: python-publish.yml on HZcohort/DiNetxify

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.1.15 This release

2 files

0.1.14

2 files

0.1.13

2 files

0.1.12

2 files

0.1.11

2 files

0.1.10

2 files

0.1.9

2 files

0.1.8

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page