updateNodes: Update nodes

Description Usage Arguments Details Value Examples

View source: R/RCX-NodesAndEdges.R

Description

This functions add nodes in the form of a Nodes object to an other Nodes or an RCX-object.

Usage

1
2
3
4
5
6
7
updateNodes(x, nodes, stopOnDuplicates = F, keepOldIds = T)

## S3 method for class 'NodesAspect'
updateNodes(x, nodes, stopOnDuplicates = F, keepOldIds = T)

## S3 method for class 'RCX'
updateNodes(x, nodes, stopOnDuplicates = F, keepOldIds = T)

Arguments

x

RCX-object or Nodes object; (to which the new Nodes will be added)

nodes

Nodes object; (the Nodes, that will be added)

stopOnDuplicates

logical (optional); whether to stop, if duplicates in id column are found, or re-assign ids instead.

keepOldIds

logical (optional); if ids are re-assigned, the original ids are kept in the column oldId

Details

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.

Value

Nodes or RCX object with added nodes

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
## 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!

frankkramer-lab/RCX documentation built on Oct. 26, 2021, 1:33 a.m.