visualize: Visualize a Network

View source: R/Visualize.R

visualizeR Documentation

Visualize a Network

Description

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

Usage

visualize(x, layout = NULL, openExternal = FALSE)

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

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

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.

Value

NULL

See Also

rcxToJson, readCX, writeCX

Examples

## prepare RCX
rcx = createRCX(
  createNodes(name = c("a","b","c")), 
  createEdges(
    source=c(0,0,1), 
    target=c(1,2,2)
  )
)


## 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 = TRUE
 )


frankkramer-lab/RCX documentation built on Feb. 4, 2023, 5:12 p.m.