updateCyHiddenAttributes: Update Cytoscape hidden attributes

Description Usage Arguments Details Value Examples

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

Description

This functions add hidden attributes in the form of a CyHiddenAttributes object to an other CyHiddenAttributes 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
updateCyHiddenAttributes(
  x,
  hiddenAttributes,
  replace = T,
  stopOnDuplicates = F,
  ...
)

## S3 method for class 'CyHiddenAttributesAspect'
updateCyHiddenAttributes(
  x,
  hiddenAttributes,
  replace = T,
  stopOnDuplicates = F,
  ...
)

## S3 method for class 'RCX'
updateCyHiddenAttributes(
  x,
  hiddenAttributes,
  replace = T,
  stopOnDuplicates = F,
  checkReferences = T,
  ...
)

Arguments

x

RCX or CyHiddenAttributes object; (to which the new hidden attributes will be added)

hiddenAttributes

CyHiddenAttributes object; (the new aspect, that will be added)

replace

logical; if existing values are updated (or ignored)

stopOnDuplicates

logical; whether to stop, if duplicates in name (and subnetworkId if present) column are found

...

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, and network relations define the relations between those networks. CyHiddenAttributes objects can be added to an RCX or an other CyHiddenAttributes object.

In the case, that a CyHiddenAttributes object is added to an other, or the RCX object already contains a CyHiddenAttributes object, some attributes might be present in both. By default, the attributes are updated with the values of the latest one. This can prevented by setting the replace parameter to FALSE, in that case only new attributes are added and the existing attributes remain untouched.

Furthermore, if duplicated attributes are considered as a preventable mistake, an error can be raised by setting stopOnDuplicates to TRUE. This forces the function to stop and raise an error, if duplicated attributes are present.

Value

CyHiddenAttributes or RCX object with added hidden attributes

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
64
65
66
67
68
## For CyHiddenAttributesAspects: 
## prepare some aspects:
hiddenAttributes1 = createCyHiddenAttributes(
  name=c("A","A","B","B"),
  value=list(c("a1","a2"),
             "a with subnetwork",
             "b",
             "b with subnetwork"),
  isList=c(TRUE,FALSE,TRUE,FALSE),
  subnetworkId=c(NA,1,NA,1)
)

## A is updated, C is new 
hiddenAttributes2 = createCyHiddenAttributes(
  name=c("A","A","C"),
  value=list("new a",
             "new a with subnetwork",
             c(1,2)),
  subnetworkId=c(NA,1,NA)
)

## Simply update with new values
hiddenAttributes3 = updateCyHiddenAttributes(hiddenAttributes1, 
                                             hiddenAttributes2)

## Ignore already present keys
hiddenAttributes3 = updateCyHiddenAttributes(hiddenAttributes1, 
                                             hiddenAttributes2, 
                                             replace=FALSE)

## Raise an error if duplicate keys are present
try(updateCyHiddenAttributes(hiddenAttributes1, hiddenAttributes2, 
                             stopOnDuplicates=TRUE))
## =>ERROR: 
## Elements of "name" and "subnetworkId" (in updateCyHiddenAttributes) 
## 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)
cySubNetworks = createCySubNetworks(
  id = c(1,2),
  nodes = list("all", c(1,2,3)),
  edges = list("all", c(0,2))                    
)
rcx = updateCySubNetworks(rcx, cySubNetworks)
#TODO: check when subnetwork works
## add a network relation
rcx = updateCyHiddenAttributes(rcx, hiddenAttributes1)

## add an additional relation (update with new values)
rcx = updateCyHiddenAttributes(rcx, hiddenAttributes2)

## create a relation with a not existing subnetwork...
hiddenAttributes3 = createCyHiddenAttributes(
  name="X",
  value="new x",
  subnetworkId=9
)

## ...and try to add them
try(updateCyHiddenAttributes(rcx, hiddenAttributes3))
## =>ERROR: 
## Provided IDs of "additionalAttributes$subnetworkId" (in updateCyHiddenAttributes) 
## don't exist in "rcx$cySubNetworks$id"

frankkramer-lab/RCX documentation built on July 14, 2021, 6:33 p.m.