updateCyVisualProperties: Update Cytoscape Visual Properties (aspect)

Description Usage Arguments Details Value See Also Examples

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

Description

This function is used to add Cytoscape visual properties aspects to each other or to an RCX object. In a CyVisualProperties aspect, CyVisualProperty objects define networks, nodes, edges, and default nodes and edges.

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
updateCyVisualProperties(
  x,
  cyVisualProperties,
  replace = T,
  stopOnDuplicates = F,
  ...
)

## S3 method for class 'CyVisualPropertiesAspect'
updateCyVisualProperties(
  x,
  cyVisualProperties,
  replace = T,
  stopOnDuplicates = F,
  ...
)

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

Arguments

x

RCX or CyVisualProperties object; (to which it will be added)

cyVisualProperties

CyVisualProperties object; (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

Structure of Cytoscape Visual Property

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
CyVisualProperty
|---properties = CyVisualPropertyProperties
|   |--name
|   |--value 
|---dependencies = CyVisualPropertyDependencies
|   |--name
|   |--value 
|---mappings = CyVisualPropertyMappings
|   |--name
|   |--type
|   |--definition 
|---appliesTo = <reference to subnetwork id>
|---view = <reference to subnetwork id>

CyVisualProperties aspects consist of CyVisualProperty objects for each entry: networks, nodes, edges, and default nodes and edges. Two CyVisualProperties aspects are merged by adding its entries individually.

CyVisualProperty objects differ in the sub-networks and views (CySubNetworks) they apply to, subsequently properties, dependencies and mappings are merged based on the uniqueness in those two.

Properties, dependencies and mappings (i.e. CyVisualPropertyProperties, CyVisualPropertyDependencies and CyVisualPropertyMappings objects) are unique in name. By default, the duplicate 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

CyVisualProperties or RCX object with added Cytoscape visual properties

See Also

updateCyVisualProperty, getCyVisualProperty

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
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
## Prepare used properties
## Visual property: Properties
vpPropertyP1 = createCyVisualPropertyProperties(c(NODE_BORDER_STROKE="SOLID"))
vpPropertyP2 = createCyVisualPropertyProperties(c(NODE_BORDER_WIDTH="1.5"))
vpPropertyP3 = createCyVisualPropertyProperties(c(NODE_BORDER_WIDTH="999"))

## Visual property: Dependencies
vpPropertyD1 = createCyVisualPropertyDependencies(c(nodeSizeLocked="false"))
vpPropertyD2 = createCyVisualPropertyDependencies(c(arrowColorMatchesEdge="true"))
vpPropertyD3 = createCyVisualPropertyDependencies(c(arrowColorMatchesEdge="false"))

## Visual property: Mappings
vpPropertyM1 = createCyVisualPropertyMappings(c(NODE_FILL_COLOR="CONTINUOUS"), 
                                              "COL=directed,T=boolean,K=0=true,V=0=ARROW")
vpPropertyM2 = createCyVisualPropertyMappings(c(EDGE_TARGET_ARROW_SHAPE="DISCRETE"), 
                                              "TRIANGLE")
vpPropertyM3 = createCyVisualPropertyMappings(c(EDGE_TARGET_ARROW_SHAPE="DISCRETE"), 
                                              "NONE")

## Create visual property object 
vpProperty1 = createCyVisualProperty(properties=list(vpPropertyP1,
                                                     vpPropertyP1), 
                                     dependencies=list(vpPropertyD1,
                                                       NA), 
                                     mappings=list(vpPropertyM1,
                                                   NA),
                                     appliesTo = c(NA,
                                                   1),
                                     view = c(NA,
                                              1))
vpProperty2 = createCyVisualProperty(properties=vpPropertyP2, 
                                     dependencies=vpPropertyD2, 
                                     mappings=vpPropertyM2)
vpProperty3 = createCyVisualProperty(properties=vpPropertyP3, 
                                     dependencies=vpPropertyD3, 
                                     mappings=vpPropertyM3)

## Create a visual properties aspect
## (using the same visual property object for simplicity)
visProp1 = createCyVisualProperties(network=vpProperty1, 
                                    nodes=vpProperty1, 
                                    edges=vpProperty1, 
                                    defaultNodes=vpProperty1, 
                                    defaultEdges=vpProperty1)

visProp2 = createCyVisualProperties(network=vpProperty2, 
                                    nodes=vpProperty2, 
                                    edges=vpProperty2, 
                                    defaultNodes=vpProperty2, 
                                    defaultEdges=vpProperty2)

visProp3 = createCyVisualProperties(network=vpProperty3, 
                                    nodes=vpProperty3, 
                                    edges=vpProperty3, 
                                    defaultNodes=vpProperty3, 
                                    defaultEdges=vpProperty3)

## Adding a different visual property (Properties, Dependencies, Mappings)
## (e.g. "NODE_BORDER_WIDTH", which is not present before)
visProp4 = updateCyVisualProperties(visProp1, visProp2)

## Update a existing visual property
visProp5 = updateCyVisualProperties(visProp4, visProp3)

## Raise an error if duplicate keys are present
try(updateCyVisualProperties(visProp4, visProp3,
                             stopOnDuplicates=TRUE))
## =>ERROR:
##   Elements of name (in VisualProperties$network$properties<appliesTo=NA,view=NA>) 
##   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)

## Adding visual properties to an RCX object
rcx = updateCyVisualProperties(rcx, visProp1)

## Adding a different visual property (Properties, Dependencies, Mappings)
## (e.g. "NODE_BORDER_WIDTH", which is not present before)
rcx = updateCyVisualProperties(rcx, visProp2)

## Update a existing visual property
rcx = updateCyVisualProperties(rcx, visProp3)

## Raise an error if duplicate keys are present
try(updateCyVisualProperties(rcx, visProp3,
                             stopOnDuplicates=TRUE))
## =>ERROR:
## Elements of "name" (in VisualProperties$network$properties<appliesTo=NA,view=NA>) 
## must not contain duplicates! 

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