writeHTML: Save network visualization as HTML file

Description Usage Arguments Details See Also Examples

View source: R/Visualize.R

Description

Save an interactive single page visualization of RCX and CX networks as an HTML file containing all necessary Java Script.

Usage

1
2
3
4
5
6
7
writeHTML(x, file, layout = NULL, verbose = F)

## S3 method for class 'RCX'
writeHTML(x, file, layout = NULL, verbose = F)

## S3 method for class 'CX'
writeHTML(x, file, layout = NULL, verbose = F)

Arguments

x

network; RCX or CX object

file

character; path, where the html file should be saved

layout

named character or list; e.g. c(name="random")

verbose

logical; whether to print what is happening

Details

This function uses the Java Script library used by the NDEx platform (https://ndexbio.org/) to visualize the RCX or CX network. The RCX is therefore converted to CX (JSON) using toCX.

If the network contains the necessary Cytoscape styles (see http://manual.cytoscape.org/en/stable/Styles.html) the network is visualized as seen on the NDEx platform.

To define the layout of the network the coordinate from CartesianLayout are used to determine the location of the nodes. If this aspect is missing, or the the coordinates should be ignored, the layout parameter can be used to set a different layout.

layout follows therefore the definition of Cytoscape.js (see https://js.cytoscape.org/#layouts). A simple definition can be setting only the name of the desired layout, e.g. random. Additional options can be passed as named list, where the values are passed without quoting. This allows for even passing Java Script functions to Cytoscape.js.

To visualize the network in RStudio the visualize function can be used instead.

See Also

rcxToJson, readCX, writeCX

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
34
35
36
## prepare RCX
rcx = createRCX(
  createNodes(name = c("a","b","c")), 
  createEdges(
    source=c(0,0,1), 
    target=c(1,2,2)
  )
)

cx = toCX(rcx)

## Not run: 
## save the html
 writeHTML(rcx, "network.html")

## or
 writeHTML(cx, "network.html")

## force a different layout
 writeHTML(rcx, "network.html", c(name="cose"))

## force a different layout with Java Script parameters
 writeHTML(rcx, "network.html", layout = c(name="random",animate="true"))

## even pass a Java Script function
 writeHTML(
   rcx, 
   "network.html", 
   layout = c(
     name="random",
     animate="true",
     animateFilter="function ( node, i ){ return true; }"
   )
 )

## End(Not run)

frankkramer-lab/RCX documentation built on Oct. 26, 2021, 1:33 a.m.