View source: R/RCX-NodesAndEdges.R
updateNodes | R Documentation |
This functions add nodes in the form of a Nodes
object to an other Nodes
or an RCX-object
.
updateNodes(x, nodes, stopOnDuplicates = FALSE, keepOldIds = TRUE) ## S3 method for class 'NodesAspect' updateNodes(x, nodes, stopOnDuplicates = FALSE, keepOldIds = TRUE) ## S3 method for class 'RCX' updateNodes(x, nodes, stopOnDuplicates = FALSE, keepOldIds = TRUE)
x |
|
nodes |
|
stopOnDuplicates |
logical (optional); whether to stop, if duplicates in |
keepOldIds |
logical (optional); if ids are re-assigned, the original ids are kept in the column |
When nodes should be added to a Nodes
or a RCX-object
object some conflicts may rise, since the aspects might use
the same IDs. If the aspects do not share any IDs, the two aspects are simply combined. Otherwise, the IDs of the new nodes are re-assinged
continuing with the next available ID (i.e. maxId
(nodesAspect) + 1 and maxId
(rcx$nodes) + 1, respectively).
To keep track of the changes, it is possible to keep the old IDs of the newly added nodes in the automatically added column oldId.
This can be omitted by setting keepOldIds to FALSE
.
Otherwise, if a re-assignment of the IDs is not desired, this can be prevented by setting stopOnDuplicates to TRUE
.
This forces the function to stop and raise an error, if duplicated IDs are present.
Nodes
or RCX object with added nodes
## create some nodes nodes1 = createNodes(name = c("EGFR","AKT1","WNT")) nodes2 = createNodes(name=c("CDK1", "CDK2", "CDK3"), represents=c("HGNC:CDK1", "Uniprot:P24941", "Ensembl:ENSG00000250506")) ## simply add the nodes and keep old ids nodes3 = updateNodes(nodes1, nodes2) ## add the nodes nodes4 = updateNodes(nodes1, nodes2, keepOldIds=FALSE) ## force an error because of duplicated ids try(updateNodes(nodes1, nodes2, stopOnDuplicates=TRUE)) ## =>Error: ## Elements of "id" (in updateNodes) must not contain duplicates! ## create an RCX object with nodes rcx = createRCX(nodes1) ## add additional nodes rcx = updateNodes(rcx, nodes2, keepOldIds=FALSE) ## force an error becauses of duplicated ids try(updateNodes(rcx, nodes2, stopOnDuplicates=TRUE)) ## =>Error: ## Elements of "id" (in updateNodes) must not contain duplicates!
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.