### R code from vignette source 'RGraph2js.Rnw' ################################################### ### code chunk number 1: style-Sweave ################################################### BiocStyle::latex() ################################################### ### code chunk number 2: adjmatExample ################################################### v <- c(0, 4, 1, 1, 0, 0, -1, 0, 0, 0, -2, 0, 0, 1, 0) a35 <- matrix(v, 3, 5) colnames(a35) <- LETTERS[1:5] rownames(a35) <- LETTERS[1:3] ################################################### ### code chunk number 3: tab1 ################################################### library(xtable) print( xtable( a35, caption="3x5 Signed Weighted Adjacency Matrix", label="tab:one", display=c("d", "d", "d", "d", "d", "d") ), caption.placement="bottom" ) ################################################### ### code chunk number 4: simpleExample ################################################### library(RGraph2js) v <- c(1,1,1,0,0,0,0,0,0,0,0,0,0,0,0, 1,1,0,1,1,1,0,0,0,0,0,0,0,0,0, 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,1,0,1,1,0,0,0,0,0,1,0,0,0,0, 0,1,0,1,1,0,0,0,1,0,0,0,0,0,0, 0,1,0,0,0,0,1,1,0,0,0,0,0,0,0, 0,0,0,0,0,1,1,0,0,0,0,0,0,0,0, 0,0,0,0,0,1,0,0,0,0,0,0,0,0,0, 0,0,0,0,1,0,0,0,1,1,0,0,0,0,0, 0,0,0,0,0,0,0,0,1,0,0,0,0,0,0, 0,0,0,1,0,0,0,0,0,0,0,1,1,1,0, 0,0,0,0,0,0,0,0,0,0,1,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,1,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,1,0,0,0,1, 0,0,0,0,0,0,0,0,0,0,0,0,0,1,1 ) a1515 <- matrix(v, 15, 15) colnames(a1515) <- LETTERS[1:15] rownames(a1515) <- LETTERS[1:15] ################################################### ### code chunk number 5: tab2 ################################################### library(xtable) print( xtable( a1515, caption="15x15 Adjacency matrix", label="tab:two", display=c("d", "d", "d", "d", "d", "d", "d", "d", "d", "d", "d", "d", "d", "d", "d", "d") ), caption.placement="bottom" ) ################################################### ### code chunk number 6: ", "Header 1Header 2", "Header 3Text 1,1", "Text 1,2Text 1,3", "Text 2,1Text 2,2Text 2,3", ""), "This is another content", "Yet another one", paste0("", "
Header 1Header 2", "Header 3
Text 1,1", "Text 1,2Text 1,3
", "Text 2,1Text 2,2Text 2,3", "
"), "

Header 1

Header 2

") n.prop <- data.frame(tooltip=someHtmlContent) rownames(n.prop) <- LETTERS[1:5] ################################################### ### code chunk number 27: tooltipContent3 ################################################### userCssStyles <- " " ################################################### ### code chunk number 28: tooltipContent4 ################################################### outputDir <- file.path(tempdir(), "RGraph2js_tooltipContent") g <- graph2js(a35, opts=opts, nodesProp=n.prop, userCssStyles=userCssStyles, outputDir=outputDir) ################################################### ### code chunk number 29: dot1 (eval = FALSE) ################################################### ## library(sna) ## ## extdata.path <- file.path(path.package(package="RGraph2js"), "extdata") ## dot.file.path <- file.path(extdata.path, "nohosts.dot") ## adj.mat <- read.dot(dot.file.path) ################################################### ### code chunk number 30: dot2 (eval = FALSE) ################################################### ## opts <- getDefaultOptions() ## opts$displayNetworkEveryNLayoutIterations <- 100 ## opts$displayNodeLabels <- FALSE ## opts$layout_forceCharge <- -2400 ## nodesGlobal <- list(color="#5544ff") ## outputDir <- file.path(tempdir(), "RGraph2js_dot") ## g <- graph2js(A=adj.mat, ## nodesGlobal=nodesGlobal, ## opts=opts, ## outputDir=outputDir) ################################################### ### code chunk number 31: graphNELExample ################################################### library(graph) nodes <- c("A", "B", "C", "D", "E") edges <- list( A=list(edges=c("A", "B"), weights=c(2, 2)), B=list(edges=c("A", "E"), weights=c(0.25, 0.25)), C=list(edges=c("A", "D"), weights=c(4, 4)), D=list(edges=c("E"), weights=c(6)), E=list(edges=c("A", "B"), weights=c(1, 1)) ) gnel <- new("graphNEL", nodes=nodes, edgeL=edges, edgemode="directed") ################################################### ### code chunk number 32: graphNELExampleRgraphviz (eval = FALSE) ################################################### ## ew <- as.character(unlist(edgeWeights(gnel))) ## ew <- ew[setdiff(seq(along = ew), removedEdges(gnel))] ## names(ew) <- edgeNames(gnel) ## eAttrs <- list() ## eAttrs$label <- ew ## plot(gnel, ## attrs=list( ## edge=list(arrowsize=0.5) ## ), ## edgeAttrs=eAttrs) ################################################### ### code chunk number 33: graphNELExampleRGraph2js ################################################### outputDir <- file.path(tempdir(), "RGraph2js_graphNELExample") g <- graph2js(A=gnel, outputDir=outputDir)