Description Usage Arguments Details Value References Examples
View source: R/graphic_function.R
Dynamic plot of a graphNEL object with the possibility to emphasize the strength of relations between nodes, represented by either a pairwise correlation or a partial correlation coefficient.
The interactive graph is an implementation of the javascript D3.js package (force-layout) for undirected and directed graphNEL objects (see references).
1 2 3 4 5 6 7 8 9 |
graph |
A graphNEL object. |
type |
Character string specifying which matrix is to be used. Either cor for correlation matrix, or pcor for partial correlation matrix. |
S1, S2 |
Sample covariance matrix. If |
colLim |
Numeric vector of length two specifying the lower and upper bound of the color range (see Details). |
legendColor |
ogical value indicating whether the color legend should be added to the plot. |
colNode |
A character string specifying the colour of the nodes. The colour node is common for all nodes. |
Admissible values for colLim
are contained in the interval [-1,1]
when S2=NULL
, otherwise the admissible interval is [-2,2]
. When an element is outside of the colLim interval, it is colored gray and represented as a dashed link.
Dynamic plot of a graphNEL object.
https://d3js.org (Micheal Bostock).
http://www.htmlwidgets.org (Ramnath Vaidyanathan, Kenton Russell, and RStudio).
https://christophergandrud.github.io/networkD3/ (Christopher Gandrud, JJ Allaire, & Kent Russell)
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 | if(require(gRbase) & require(graph)){
graph <- gRbase::ug(~a:b, ~a:c, ~c:d, ~b:d, ~b:c)
# Plot a graphNEL
plotGraphNELD3(graph)
# Plot a graphNEL coloring edges in correspondance with pairwise correlation coefficients
S <- matrix(c(2, 0.8,0.5,-0.3,
0.8,1.5,0.6,-0.7,
0.5,0.6,1, 0.7,
-0.3,-0.7,0.7,3), ncol=4,nrow=4)
colnames(S) <- rownames(S) <- graph::nodes(graph)
plotGraphNELD3(graph, S1=S)
# Plot a graphNEL coloring edges in correspondance with partial correlation coefficients
plotGraphNELD3(graph, S1=S, type="pcor")
# Change the color range
plotGraphNELD3(graph, S1=S, type="cor", colLim=c(-0.7,0.8))
# Change nodes color
plotGraphNELD3(graph, S1=S, type="cor", colNode = "pink")
# Plot the difference between two graphical models
S2 <- S
S2[1,3] <- S2[3,1]<- -0.1
plotGraphNELD3(graph,S1=S, S2=S2)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.