graphNEL: Convert an RCX object from and to an graphNEL object

Description Usage Arguments Details Value See Also Examples

Description

Convert an RCX object to an graphNEL object

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
toGraphNEL(rcx, directed = FALSE)

fromGraphNEL(
  graphNEL,
  nodeId = "id",
  nodeName = "nodeName",
  nodeIgnore = c("name"),
  edgeId = "id",
  edgeInteraction = "edgeInteraction",
  edgeIgnore = c(),
  suppressWarning = FALSE
)

Arguments

rcx

RCX object

directed

logical; whether the graph is directed

graphNEL

graphNEL object

nodeId

character; igraph attribute name used for node ids

nodeName

character; igraph attribute name used for node names

nodeIgnore

character; igraph attribute names that should be ignored

edgeId

character; igraph attribute name used for edge ids

edgeInteraction

character; igraph attribute name used for edge interaction

edgeIgnore

character; igraph attribute names that should be ignored

suppressWarning

logical; whether to suppress a warning message, if the validation of the RCX object fails

Details

In the graphNEL object the attributes are not separated from the graph like in RCX. Therefore, for converting an RCX object to an graphNEL object, and back, some adjustments in the naming of the attributes have to be made.

For nodes the name can be present in the nodes aspect, as name in the nodeAttributes aspect. Also name is used in graphNEL for naming the vertices. To avoid collisions in the conversion, the nodes name is saved in graphNEL as nodeName, while the nodeAttributes property name is saved as "attribute...name". These names are also used for the conversion back to RCX, but here the name used in the nodes aspect can be changed by the nodeName parameter.

Similar to the node name, if "represents" is present as property in nodeAttributes its name is changed to "attribute...represents".

The conversion of edges works analogously: If "interaction" is present as property in edgeAttributes its name is changed to "attribute...interaction".

Nodes and edges must have IDs in the RCX, but not in the graphNEL object. To define an vertex or edge attribute to be used as ID, the parameters nodeId and edgeId can be used to define ether an attribute name (default:"id") or set it to NULL to generate ID automatically.

The attributes also may have a special data type assigned. The data type then is saved by adding "...dataType" to the attribute name.

The cartesian layout is also stored in the graphNEL object. To make those graph vertex attributes distinguishable from nodeAttributes they are named "cartesianLayout...x", "cartesianLayout...y" and "cartesianLayout...z".

In the RCX attributes it is also possible to define a subnetwork, to which an attribute applies. Those attributes are added with "...123" added to its name, where "123" is the subnetwork id. The subnetwork id itself are added as graph graph attributes, and are named subnetwork...123...nodes" and "subnetwork...123...edges", where "123" is the subnetwork id.

Altogether, the conventions look as follows: "[attribute...]<name>[...<subnetwork>][...dataType]"

Value

graphNEL or RCX object

See Also

Igraph, igraph::as_graphnel()

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
## Read from a CX file
## reading the provided example network of the package
cxFile <- system.file(
 "extdata", 
 "Imatinib-Inhibition-of-BCR-ABL-66a902f5-2022-11e9-bb6a-0ac135e8bacf.cx", 
 package = "RCX"
)

rcx = readCX(cxFile)

## graphNEL can handle multi-edges, but only if the graph is directed and the 
## source and target start and end not between the same nodes.
## Unfortunaltelly this is the case in our sample network.
## A quick fix is simply switching the direction of source and target 
## for the multi-edges:
dubEdges = duplicated(rcx$edges[c("source","target")])

s = rcx$edges$source
rcx$edges$source[dubEdges] = rcx$edges$target[dubEdges]
rcx$edges$target[dubEdges] = s[dubEdges]

## convert the network to graphNEL
gNel = toGraphNEL(rcx, directed = TRUE)

## convert it back
rcxFromGraphNel = fromGraphNEL(gNel)

frankkramer-lab/RCX documentation built on Nov. 6, 2021, 1:03 p.m.