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.

Recent Major Updates

DiNetxify v0.3.0: More reliable data processing and analysis

Following a comprehensive review of the data-processing and analysis workflow, DiNetxify v0.3.0 introduces important corrections to Phecode exclusion, longitudinal EHR processing, PheWAS eligibility and thresholding, comorbidity-strength estimation, RPCN fitting, and time-aware adjustment for disease covariates in trajectory analyses. Together, these updates improve methodological reliability and consistency across analysis stages. See the Changelog in https://hzcohort.github.io/DiNetxify/ and commit history for the complete list of corrections.

DiNetxify v0.2.0: Interactive visualization websites

DiNetxify v0.2.0 introduces Plot.interactive_website(), which converts analysis result tables into a self-contained, multi-page visualization website. The generated site can be opened locally without a web server or internet connection. See the interactive example, which presents results from our previous depression study.

from DiNetxify.visualization import Plot

plot = Plot(
    phewas_result=phewas_result,
    comorbidity_result=com_network_result,
    trajectory_result=trajectory_result,
    exposure_name="MDD diagnosis",
)
plot.interactive_website("results/interactive_website")

The PheWAS section is always generated. Supplying comorbidity_result adds the interactive comorbidity network, while supplying both comorbidity_result and trajectory_result also adds the disease-trajectory and 3D network sections. The website includes filtering, search, tooltips, zoom controls, and figure export where applicable.

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 results

The Plot class can generate individual figures or a complete interactive website. phewas_result is required; comorbidity_result and trajectory_result add the corresponding network views.

Create individual plots

from pathlib import Path

from DiNetxify.visualization import Plot

results_dir = Path("results")
trajectory_dir = results_dir / "trajectory_plots"
trajectory_dir.mkdir(parents=True, exist_ok=True)

plot = 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(str(results_dir / "phewas_plot.png"))
plot.comorbidity_network_plot(str(results_dir / "comorbidity_network.html"))
plot.trajectory_plot(str(trajectory_dir))
plot.three_dimension_plot(str(results_dir / "three_dimension_network.html"))

When both network result tables are supplied, module assignments are shared across the comorbidity, trajectory, and 3D plots.

Build an interactive website

plot.interactive_website("results/interactive_website")

The generated sections depend on the result tables supplied when constructing Plot:

Supplied results Generated website sections
phewas_result PheWAS scatter and, when effect estimates are available, forest plots
phewas_result + comorbidity_result PheWAS and comorbidity network
phewas_result + comorbidity_result + trajectory_result PheWAS, comorbidity network, disease trajectories, and 3D network

The PheWAS pages provide system-ordered scatter and selectable forest plots. The network pages provide module and system filters, condition search, labels, tooltips, zoom controls, and figure export. Comorbidity node sizes reflect the configured PheWAS count column, and edge widths reflect the retained association strength, capped at an effect ratio of 10 for display. The site also writes cleaned data payloads and an automatically positioned data/comorbidity.gexf file.

Open the generated index.html in a modern browser. The website bundles its required assets and does not require a web server or internet connection.

To customize disease-system colors, pass SYSTEM=[...] and the corresponding COLOR=[...] list when constructing Plot. Every disease system present in phewas_result must be included in SYSTEM.

For exposed-only cohorts, omit exposure_name, exposure_location, and exposure_size.

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.3.3

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.3.3
File Size Uploaded
dinetxify-0.3.3.tar.gz 2.0 MB Details

Built distribution (wheel)

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

Total release size: 4.0 MB

Release files / dinetxify-0.3.3.tar.gz

Download URL dinetxify-0.3.3.tar.gz
Size 2.0 MB
Tags Source
SHA-256 checksum
How to use checksums
14617116e9ae91415270482e4565949ed5938af1ed696a1e215e1349490a9280
BLAKE2b-256 checksum
How to use checksums
0a83c6587070301cc5ce2270de9c115b8f87a4ddffd737b41ca49e0c379c40b8
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 Sep 22, 2026.

Transparency log

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

Download URL dinetxify-0.3.3-py3-none-any.whl
Size 2.0 MB
Tags Python 3
SHA-256 checksum
How to use checksums
2f95a7e9529a1fd05b62a5d66c96063d8003a4bb686d53e7d3833379922546f1
BLAKE2b-256 checksum
How to use checksums
ba0c30e0e80dc685b0ea6a9a1c8b8f05d34623abd19ea5993f488aac9b55b836
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 Sep 22, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.3.3 This release

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

0.1.16

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