[BioC] draw path-diagram Rgraphvis

René Mayer mayer at psychologie.tu-dresden.de
Sat Jul 28 09:59:04 CEST 2012


Dear List,
how can I draw the following path diagram

A B C  D E F  # observed x
\ | /  \ | /
   G <--> H    # latent variables
  / \    / \
  I J    K L   # observed y

the problem I've got is that G and H need to be horizontally alingned
but the best I've done is diagonally or vertically alingned,
kind regards,
René

## Begin: R-code ####################################

#source("http://bioconductor.org/biocLite.R")
#biocLite("Rgraphviz")
library(Rgraphviz)
library("graph")

# observed x
ox=c('RParAsp',  'RIQ', 'RSES','FSES', 'FIQ', 'FParAsp')
# observed y
oy=c('ROccAsp', 'REdAsp', 'FOccAsp',  'FEdAsp')
# latent
l=c('FGenAsp','RGenAsp')

l1 <- new("graphNEL", nodes = c(ox,oy,l), edgemode = "directed")

l1 <- addEdge("RParAsp", "RGenAsp", l1)
l1 <- addEdge("RIQ", "RGenAsp", l1)
l1 <- addEdge("RSES", "RGenAsp", l1)

l1 <- addEdge("FParAsp", "FGenAsp", l1)
l1 <- addEdge("FIQ", "FGenAsp", l1)
l1 <- addEdge("FSES", "FGenAsp", l1)

l1 <- addEdge("FGenAsp", "FOccAsp", l1)
l1 <- addEdge("FGenAsp", "FEdAsp", l1)

l1 <- addEdge("RGenAsp", "ROccAsp", l1)
l1 <- addEdge("RGenAsp", "REdAsp", l1)

l1 <- addEdge("RGenAsp", "FGenAsp", l1)
l1 <- addEdge("FGenAsp", "RGenAsp", l1)

plot(l1, recipEdges="distinct")

sub1 <- subGraph(ox, l1)
sub2 <- subGraph(oy, l1)
sub3 <- subGraph(l, l1)

# try to set the rankdir locally, but it is not working
sublist <-
   list( list(  graph=sub1, cluster = T, attrs = c(rankdir = 'TB') ),
         list(  graph=sub2, cluster = T, attrs = c(rankdir = 'TB') ),
         list(  graph=sub3, cluster = T, attrs = c(rankdir = 'LR') )
  )

plot(l1, subGList = sublist)

## End: R-code ##################################



More information about the Bioconductor mailing list