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.
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.
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_resultcom_strength_resultcom_network_resultbinomial_resulttrajectory_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_dirmust already exist.- When using multiprocessing, keep the call inside
if __name__ == "__main__":. - For standalone multiprocessing calls on Linux servers,
phewas(),comorbidity_network(), anddisease_trajectory()supportmultiprocessing_start_method="forkserver"or another available start method. methodcan be'RPCN','PCN_PCA', or'CN'.- For standalone PheWAS,
phewas(method="bfgs", maxiter=300)controls thestatsmodelsCox optimizer. This is separate from the pipelinemethod, 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:
- DiNetxify: a python package for three-dimensional disease network analysis based on electronic health record data (PMID: 41579291)
- Disease clusters and their genetic determinants following a diagnosis of depression: analyses based on a novel three-dimensional disease network approach (PMID: 40681841)
Contact
- Can Hou: houcan@wchscu.cn
- Haowen Liu: haowenliu81@gmail.com
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)
| File | Size | Uploaded | |
|---|---|---|---|
| dinetxify-0.1.16.tar.gz | 2.4 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| 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 logRelease 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