DiNetxify
Project description
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__":. methodcan 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.
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dinetxify-0.1.13.tar.gz.
File metadata
- Download URL: dinetxify-0.1.13.tar.gz
- Upload date:
- Size: 2.4 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
42e7bc48796745af20c6fe936d133d64b8b92f810521ab12a535c64f5c57bcd3
|
|
| MD5 |
26047b93b6181b1dbc9d8cfff06ae53c
|
|
| BLAKE2b-256 |
5aa02a5a8f37a69c20e3b7bb23af7550d3ac3fbae8ec499815eb2ab157030fd3
|
Provenance
The following attestation bundles were made for dinetxify-0.1.13.tar.gz:
Publisher:
python-publish.yml on HZcohort/DiNetxify
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dinetxify-0.1.13.tar.gz -
Subject digest:
42e7bc48796745af20c6fe936d133d64b8b92f810521ab12a535c64f5c57bcd3 - Sigstore transparency entry: 1196979102
- Sigstore integration time:
-
Permalink:
HZcohort/DiNetxify@157ae76c2d68cbaeec48e23b30de294dd36c5af8 -
Branch / Tag:
refs/tags/v0.1.13 - Owner: https://github.com/HZcohort
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@157ae76c2d68cbaeec48e23b30de294dd36c5af8 -
Trigger Event:
release
-
Statement type:
File details
Details for the file dinetxify-0.1.13-py3-none-any.whl.
File metadata
- Download URL: dinetxify-0.1.13-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.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3758e3b44d97e9ac3dac4d17291f2ffcfeca3d624a7e1249eadfef2cde95d346
|
|
| MD5 |
559c6277fce3a50f55ca9eafc205f767
|
|
| BLAKE2b-256 |
60ee1c43843e18220acd882d9a8a057657aa82311e39be44dcbba3c41b340c89
|
Provenance
The following attestation bundles were made for dinetxify-0.1.13-py3-none-any.whl:
Publisher:
python-publish.yml on HZcohort/DiNetxify
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dinetxify-0.1.13-py3-none-any.whl -
Subject digest:
3758e3b44d97e9ac3dac4d17291f2ffcfeca3d624a7e1249eadfef2cde95d346 - Sigstore transparency entry: 1196979181
- Sigstore integration time:
-
Permalink:
HZcohort/DiNetxify@157ae76c2d68cbaeec48e23b30de294dd36c5af8 -
Branch / Tag:
refs/tags/v0.1.13 - Owner: https://github.com/HZcohort
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@157ae76c2d68cbaeec48e23b30de294dd36c5af8 -
Trigger Event:
release
-
Statement type: