Package 'PDN'

Title: Personalized Disease Network
Description: Building patient level networks for prediction of medical outcomes and draw the cluster of network. This package is based on paper Personalized disease networks for understanding and predicting cardiovascular diseases and other complex processes (See Cabrera et al. <http://circ.ahajournals.org/content/134/Suppl_1/A14957>).
Authors: Javier Cabrera <[email protected]>, Fei Wang <[email protected]>
Maintainer: Zhenbang Wang <[email protected]>
License: GPL-2
Version: 0.1.0
Built: 2024-11-20 04:05:30 UTC
Source: https://github.com/cran/PDN

Help Index


Personized Disease Network

Description

Building patient level networks for prediction of medical outcomes and draw the cluster of network. This pakcage is based on paper Personalized disease networks (PDN) for understanding and predicting cardiovascular diseases and other complex processes.

Details

Package: PDN
Type: Package
Version: 1.0
Date: 2017-08-14
License: GPL-2

Author(s)

Javier Cabrera and Fei Wang
Maintainer: Zhenbang Wang <[email protected]>

References

Cabrera, Javier and Kostis, John B and Wang, Fei and Kostis, William J. (2016) Personalized Disease Networks in Predicting Cardiovascular Outcomes


Generating Network Matrix

Description

This function use data set with cut off information to create network matrix

Usage

buildnetworks(x, k1, del = 0)

Arguments

x

comorbidity data matrix with column correspond to ICD9 codes and row correspond to each patient

k1

the cut off point between Diagnosis/Procedure A to another Diagnosis/Procedure B, it can be fix number, NULL and datecut

del

number of character deleted for each name of the input

Value

Network Matrix

Examples

# Select a subset of data for toy example
comorbidity_data = comorbidity_data[c(1:10),]
survival_data = survival_data[c(1:10),]
k1 = datecut(comorbidity_data,survival_data[,1],survival_data[,2])
a = buildnetworks(comorbidity_data,k1)

Sampele comorbidity data set

Description

This is the sample data set for Package PDN

Usage

comorbidity_data

Format

100 rows and 10 column matrix


Generating Optimal cuts for the Data

Description

Performs Cox proportional hazards regression model on patients survival days based on different cutoffs

Usage

datecut(x, surdays, event)

Arguments

x

comorbidity data matrix with column correspond to ICD9 codes and row correspond to each patient

surdays

survival days for each patient

event

indictor variable 1 represent patient died 0 represent patient survive

Details

Building and draw personized disease network

Value

a vector of cutoff points that maximize the Z statistics for cox model between each Diagnosis/Procedure A to another Diagnosis/Procedure B

Examples

comorbidity_data
survival_data
#Select a subset of data for toy example
comorbidity_data = comorbidity_data[c(1:10),]
survival_data = survival_data[c(1:10),]
k1 = datecut(comorbidity_data,survival_data[,1],survival_data[,2])

Sampele demographic data set

Description

This is one of the sample data set. It contains the demographic information of each patients It has five variables which are sex, race, hispan, dshyr and prime

Usage

demographic_data

Format

100 rows and 5 column matrix


Draw Personalized Disease Network for one patient with network and ggplot2

Description

Draw Personalized Disease Network based on newtwork matrix

Usage

draw.PDN(tt, labels)

Arguments

tt

one row of network matrix generated from comorbidity data matrix using buildnetworks

labels

names of each node in the network matrix

Examples

#Select a subset of data for toy example
comorbidity_data = comorbidity_data[c(1:10),]
survival_data = survival_data[c(1:10),]
#  Getting the names
k1 = datecut(comorbidity_data,survival_data[,1],survival_data[,2])
a = buildnetworks(comorbidity_data,k1)
#Plot PDN for patient 7
nn = names(comorbidity_data)
draw.PDN(a[7,],nn)

Draw Personalized Disease Network for one patient

Description

Draw Personalized Disease Network based on newtwork matrix

Usage

draw.PDN.circle(a0, dak)

Arguments

a0

one row of network matrix generated from comorbidity data matrix using buildnetworks

dak

one row of Ranks matrix for corresponding comorbidity data matrix

Examples

#Select a subset of data for toy example
comorbidity_data = comorbidity_data[c(1:10),]
survival_data = survival_data[c(1:10),]
#  Find date cuts
k1 = datecut(comorbidity_data,survival_data[,1],survival_data[,2])
#  Build networks
a = buildnetworks(comorbidity_data,k1)

#  Graph individual patients
datark = t(apply(comorbidity_data,1,rank))
dak = sort(datark[1,])
#  draw PDN for the first patient
draw.PDN.circle(a[1,],dak)
#  draw PDN for the whole comorbidity data set
par(mfrow=c(2,5))
for(i in 1 : nrow(a)){
 dak = apply(datark,2,sort)
 draw.PDN.circle(a[i,],dak[i,])
 title(main=paste("Patient",i))
}

Draw Personalized Disease Network for cluster of patients

Description

Draw Personalized Disease Network based on cluster information

Usage

draw.PDN.cluster(a0, dak)

Arguments

a0

network matrix get from buildnetworks

dak

ranks data for comorbidity data matrix

Examples

#Select a subset of data for toy example
comorbidity_data = comorbidity_data[c(1:10),]
survival_data = survival_data[c(1:10),]
##Clustering Example
k1 = datecut(comorbidity_data,survival_data[,1],survival_data[,2])
a = buildnetworks(comorbidity_data,k1)
datark = t(apply(comorbidity_data,1,rank))
require(survival)
zsq = NULL
for(i in 1:ncol(a)){
  a1 = (summary(coxph(Surv(as.numeric(survival_data[,1]),survival_data[,2]) ~ a[,i],
  data=as.data.frame(a)))$coefficient[,4])^2
  zsq = cbind(zsq,a1)
}
zsq = as.numeric(zsq)
wi=zsq/sum(zsq,na.rm=TRUE)
wi[wi<10^ -3]=10^ -3
wi[is.na(wi)]=10^ -3
#weighted matrix
wa = NULL
for(i in 1:ncol(a)){
 wa = cbind(wa,a[,i]*wi[i])
}
#PCA
pr.out=prcomp(wa)
x.svd=svd(wa)
x.score1 <- wa %*% x.svd$v
x.score2 <- x.svd$u %*% diag(x.svd$d)
##HC cluster using the first 8 PCA scores
dp<-dist(x.score2[,1:8])
hcp<-hclust(dp, method="ward.D")
##Plot Network
s1=rev(sort(apply(a[cutree(hcp,3)==2,],2,mean)))[1:50]
dak = sort(apply(datark[cutree(hcp,3)==2,],2,mean,na.rm=TRUE))
names(dak) = unlist(strsplit(names(dak),"DAT"))
draw.PDN.cluster(s1,dak)

Sampele Survival data set

Description

This is the sample data set for function datecut. The first column is the time difference between the patient admission date and death date The second column is the indictor variable with 1 corresponding to patient death, 0 corresponding to patient alive

Usage

survival_data

Format

100 rows and 2 column matrix