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'.
  • For standalone PheWAS, phewas(method="bfgs", maxiter=300) controls the statsmodels Cox optimizer. This is separate from the pipeline method, which selects the network-analysis method.

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

Metadata

Release files for DiNetxify 0.1.16

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

Source distribution (sdist)

Source distribution for DiNetxify 0.1.16
File Size Uploaded
dinetxify-0.1.16.tar.gz 2.4 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for DiNetxify 0.1.16
File Interpreter ABI Platform
dinetxify-0.1.16-py3-none-any.whl Python 3 none any Details

Total release size: 4.9 MB

Release files / dinetxify-0.1.16.tar.gz

Download URL dinetxify-0.1.16.tar.gz
Size 2.4 MB
Tags Source
SHA-256 checksum
How to use checksums
4176abd54fa115ce4029ae5c36e8e39afd796c74a63251f24b57b739d3cb749b
BLAKE2b-256 checksum
How to use checksums
11897b0e824dedbb53a55a23f859d6e17aba6f628514241b3c941d1f283ec31e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 26, 2026.

Transparency log

Release files / dinetxify-0.1.16-py3-none-any.whl

Download URL dinetxify-0.1.16-py3-none-any.whl
Size 2.4 MB
Tags Python 3
SHA-256 checksum
How to use checksums
9be36926bfcbd163f4c3d3a8dc1764f7cabd52396bf643678d11c2369906ac05
BLAKE2b-256 checksum
How to use checksums
e1e520fb32da1568387742091c5cc65ea7cf4dad5ae00120a404fe04a4da0804
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 26, 2026.

Transparency log

Release history Release notifications | RSS feed

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.17

2 release files

This release

0.1.16 This release

2 release files

0.1.15

2 release files

0.1.13

2 release files

0.1.12

2 release files

0.1.11

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

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