pathdiagram2: Two-level Nested Pathdiagram

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/pathdiagram2.R

Description

This function is used to create two-level nested pathdiagram to represent causal effects of risk factors on outcome and on the disease of study. The nested path is a child path, which is related to outcome and the outside path is parent path with respect to disease.

Usage

1
pathdiagram2(pathD, pathO, rangeD, rangeO, disease, R2D, R2O)

Arguments

pathD

R object that is disease path result data consisting of correlation matrix of causal variables to be identified in Mendelian randomization analysis and path coefficient vector of these variables directly causing the disease of study.

pathO

R object that is outcome path result data consisting of correlation matrix of causal variables and path coefficient vector of these variables directly contributing to outcome. This outcome variable may be or not be one of risk factors or causal variables in disease path data. These variables are the same with those in pathD.

rangeD

specifies column range for correlation coefficient matrix in pathD, for example, rangeD=c(2:4) means the correlation coefficient begins with column 2 and end at column 4.

rangeO

specifies column range for correlation coefficient matrix in pathO, see example in rangeD.

disease

a string that specifies disease name. If disease name is long or has multiple words, then we suggest an abbreviated name, for example, "coronary artery disease" can be shortened as CAD.

R2D

a required numeric parameter and its value is R-square obtained from path analysis of disease data.

R2O

a required numeric parameter and its value is R-square obtained from path analysis of outcome data.

Details

Two path datasets must contain correlation matrix of variables detected to be risk factor of disease and a vector of direct path coefficients obtained from path analysis of beta data of SNPs on causal variables and disease. Columns must have shortened variable names and path word (see examples). pathdiagram2 requires two path data have the same causal variable names and the same name order. The outcome in the outcome path data must be the last variable in the correlation matrix in disease path data (see examples). Otherwise, pathdiagram2 would give an error message.

Value

Null. Function pathdiagram2 creates a nested two-level path diagram labeled with color.

Author(s)

Yuan-De Tan [email protected]

See Also

pathdiagram, plotmat, plotweb

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
mypath<-matrix(NA,3,4)
mypath[1,]<-c(1.000000,-0.066678, 0.420036,0.764638)
mypath[2,]<-c(-0.066678,1.000000,-0.559718,0.496831)
mypath[3,]<-c(0.420036,-0.559718,1.000000,0.414346)
colnames(mypath)<-c("ldl","hdl","tg","path")
mypath<-DataFrame(mypath)
#mypath
#DataFrame with 3 rows and 4 columns
#        ldl       hdl        tg      path
#  <numeric> <numeric> <numeric> <numeric>
#1  1.000000 -0.066678  0.420036  0.764638
#2 -0.066678  1.000000 -0.559718  0.496831
#3  0.420036 -0.559718  1.000000  0.414346

#In this pathdiagram, the outcome is TC
pathD<-matrix(NA,4,5)
pathD[1,]<-c(1,	-0.070161,0.399038,0.907127,1.210474)
pathD[2,]<-c(-0.070161,	1,-0.552106,0.212201,0.147933)
pathD[3,]<-c(0.399038,-0.552106,1,0.44100,0.64229)
pathD[4,]<-c(0.907127	,0.212201,0.441007,1,-1.035677)
colnames(pathD)<-c("ldl","hdl","tg","tc","path")

#pathD
#        LDL       HDL        TG        TC      path
#1  1.000000 -0.070161  0.399038  0.907127  1.210474
#2 -0.070161  1.000000 -0.552106  0.212201  0.147933
#3  0.399038 -0.552106  1.000000  0.441000  0.642290
#4  0.907127  0.212201  0.441007  1.000000 -1.035677

pathD<-as.data.frame(pathD)
## tc is outcome in my path
pathdiagram2(pathD=pathD,pathO=mypath,rangeD=c(1:4),rangeO=c(1:3),disease="CAD",
R2D=0.536535,R2O=0.988243)

GMRP documentation built on Nov. 27, 2018, 6:01 p.m.