updateEdges: Update edges

View source: R/RCX-NodesAndEdges.R

updateEdgesR Documentation

Update edges

Description

This functions add edges in the form of a Edges object to an other Edges or an RCX object.

Usage

updateEdges(x, edges, stopOnDuplicates = FALSE, keepOldIds = TRUE, ...)

## S3 method for class 'EdgesAspect'
updateEdges(x, edges, stopOnDuplicates = FALSE, keepOldIds = TRUE, ...)

## S3 method for class 'RCX'
updateEdges(
  x,
  edges,
  stopOnDuplicates = FALSE,
  keepOldIds = TRUE,
  checkReferences = TRUE,
  ...
)

Arguments

x

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

edges

Edges object; (the Edges, 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

...

additional parameters

checkReferences

logical; whether to check if references to other aspects are present in the RCX object

Details

When edges should be added to a Edges 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 edges are re-assinged continuing with the next available ID (i.e. maxId(edgesAspect) + 1 and maxId(rcx$edges) + 1, respectively).

To keep track of the changes, it is possible to keep the old IDs of the newly added edges 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

Edges or RCX with added edges

Examples

## create some edges
edges1 = createEdges(source=c(1,1,0), target=c(2,0,1))
edges2 = createEdges(id=c(3,2,4),
                     source=c(0,0,1), 
                     target=c(1,2,2),
                     interaction=c("activates","inhibits", NA))

## simply add the edges and keep old ids
edges3 = updateEdges(edges1, edges2)

## add the edges
edges4 = updateEdges(edges1, edges2, keepOldIds=FALSE)

## force an error because of duplicated ids
try(updateEdges(edges1, edges2, stopOnDuplicates=TRUE))
## =>Error:
## Elements of "id" (in updateEdges) must not contain duplicates!

## Prepare an RCX object
rcx = createRCX(createNodes(name = c("EGFR","AKT1","WNT")))

## add edges to the RCX object
rcx = updateEdges(rcx, edges1)

## add new edges and don't keep old ids
rcx = updateEdges(rcx, edges2, keepOldIds=FALSE)

## force an error because of duplicated ids
try(updateEdges(rcx, edges2, stopOnDuplicates=TRUE))
## =>Error:
## Elements of "id" (in updateEdges) must not contain duplicates!

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