visualize: Visualize a Network

Description Usage Arguments Details See Also Examples

View source: R/Visualize.R

Description

Visualize RCX and CX networks in RStudio or in an external browser.

Usage

1
2
3
4
5
6
7
visualize(x, layout = NULL, openExternal = F)

## S3 method for class 'RCX'
visualize(x, layout = NULL, openExternal = F)

## S3 method for class 'CX'
visualize(x, layout = NULL, openExternal = F)

Arguments

x

network; RCX or CX object

layout

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

openExternal

logical; whether to open in an external browser instead of the RStudio viewer

Details

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

By default the visualization is opened in RStudio in the Viewer panel. If this function is not executed in RStudio, the visualization is opened in the standard web-browser. This also can be forced from within RStudio using openExternal.

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.

The visualization can also be saved as HTML file using the writeHTML function instead of this one.

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

## Not run: 
## visualize the network
 visualize(rcx)

## force a different layout
 visualize(rcx, c(name="cose"))

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

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

## open the visualization in an external browser
 visualize(
   rcx, 
   layout = c(name="cose"),
   openExternal = T
 )

## End(Not run)

frankkramer-lab/RCX documentation built on July 14, 2021, 6:33 p.m.