Igraph | R Documentation |
Convert an RCX object to an igraph object
toIgraph(rcx, directed = FALSE) fromIgraph( ig, nodeId = "id", nodeName = "nodeName", nodeIgnore = c("name"), edgeId = "id", edgeInteraction = "edgeInteraction", edgeIgnore = c(), suppressWarning = FALSE )
rcx |
RCX object |
directed |
logical; whether the graph is directed |
ig |
igraph 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 |
In the igraph object the attributes are not separated from the graph like in RCX. Therefore, for converting an RCX object to an igraph 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 igraph for naming the vertices.
To avoid collisions in the conversion, the nodes name is saved in igraph 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 igraph 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 igraph object.
To make those igraph 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 igraph 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]"
igraph or RCX object
graphNEL
## 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) ## convert the network to igraph ig = toIgraph(rcx) ## convert it back rcxFromIg = fromIgraph(ig)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.