updateCySubNetworks: Update Cytoscape subnetworks

Description Usage Arguments Details Value See Also Examples

View source: R/RCX-Cytoscape-SubNetworks.R

Description

This functions add subnetworks in the form of a CySubNetworks object to an other CySubNetworks or an RCX object.

Usage

 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
updateCySubNetworks(
  x,
  cySubNetworks,
  stopOnDuplicates = F,
  keepOldIds = T,
  ...
)

## S3 method for class 'CySubNetworksAspect'
updateCySubNetworks(
  x,
  cySubNetworks,
  stopOnDuplicates = F,
  keepOldIds = T,
  ...
)

## S3 method for class 'RCX'
updateCySubNetworks(
  x,
  cySubNetworks,
  stopOnDuplicates = F,
  keepOldIds = T,
  checkReferences = T,
  ...
)

Arguments

x

RCX or CySubNetworks object; (to which the new subnetworks will be added)

cySubNetworks

CySubNetworks object; (the subnetwork, that will be added)

stopOnDuplicates

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

keepOldIds

logical; 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

Cytoscape subnetworks allow to group a set of nodes and corresponding edges together. CySubNetworks objects can be added to an RCX or an other CySubNetworks object. The nodes and edges parameters reference the node or edge IDs that belong to a subnetwork. When adding an CySubNetworks object to an RCX object, those IDs must be present in the Nodes or Edges aspect respectively, otherwise an error is raised. Unlike other aspects referring those IDs, the Cytoscape subnetwork aspect allows to refer to all nodes and edges using the keyword all.

When subnetworks should be added to a CySubNetworks or a RCX 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 subnetworks are re-assinged continuing with the next available ID (i.e. maxId(cySubNetworks) + 1 and maxId(rcx$cySubNetworks) + 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

CySubNetworks or RCX object with added subnetworks

See Also

CyNetworkRelations;

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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
## For CySubNetworksAspects: 
## prepare some aspects:
cySubNetworks1 = createCySubNetworks(
  id = c(0,1),
  nodes = list("all",
               c(1,2,3)),
  edges = list("all",
               c(0,2))                    
)

cySubNetworks2 = createCySubNetworks(
  nodes = c(0,3),
  edges = c(1)
)

## subnetwork ids will be kept
cySubNetworks3 = updateCySubNetworks(cySubNetworks1, cySubNetworks2)

## old subnetwork ids will be omitted
cySubNetworks3 = updateCySubNetworks(cySubNetworks1, cySubNetworks2,
                                     keepOldIds=FALSE)

## Raise an error if duplicate keys are present
try(updateCySubNetworks(cySubNetworks1, cySubNetworks2,
                        stopOnDuplicates=TRUE))
## =>ERROR: 
## Elements of "id" (in updateCySubNetworks) must not contain duplicates!

## For RCX
## prepare RCX object:
nodes = createNodes(name = c("a","b","c","d","e","f"))
edges = createEdges(source=c(1,2,0,0,0,2), 
                    target=c(2,3,1,2,5,4))
rcx = createRCX(nodes, edges)

## add the subnetwork
rcx = updateCySubNetworks(rcx, cySubNetworks1)

## add additional subnetwork
rcx = updateCySubNetworks(rcx, cySubNetworks2)

## create a subnetwork with a not existing node...
cySubNetworks3 = createCySubNetworks(
  nodes = list(9)
)

## ...and try to add them
try(updateCySubNetworks(rcx, cySubNetworks3))
## =>ERROR: 
## Provided IDs of "additionalSubNetworks$nodes" (in addCySubNetworks) 
## don't exist in "rcx$nodes$id"

## create a group with a not existing edge...
cySubNetworks4 = createCySubNetworks(
  nodes = c(0,1),
  edges = 9
)

## ...and try to add them
try(updateCySubNetworks(rcx, cySubNetworks4))
## =>ERROR: 
## Provided IDs of "additionalSubNetworks$edges" (in addCySubNetworks) 
## don't exist in "rcx$edges$id"

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