updateCyTableColumn: Update Cytoscape table column properties

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

updateCyTableColumnR Documentation

Update Cytoscape table column properties

Description

This functions add hidden attributes in the form of a CyTableColumn object to an other CyTableColumn or an RCX object.

Usage

updateCyTableColumn(
  x,
  cyTableColumns,
  replace = TRUE,
  stopOnDuplicates = FALSE,
  ...
)

## S3 method for class 'CyTableColumnAspect'
updateCyTableColumn(
  x,
  cyTableColumns,
  replace = TRUE,
  stopOnDuplicates = FALSE,
  ...
)

## S3 method for class 'RCX'
updateCyTableColumn(
  x,
  cyTableColumns,
  replace = TRUE,
  stopOnDuplicates = FALSE,
  checkReferences = TRUE,
  ...
)

Arguments

x

RCX or CyTableColumn object; (to which the new table column properties will be added)

cyTableColumns

CyTableColumn 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 appliesTo and 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

In the case, that a CyTableColumn object is added to an other, or the RCX object already contains a CyTableColumn object, some properties might be present in both. By default, the properties 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 properties 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 properties are present.

Cytoscape does not currently support table columns for the root network, but this is option is included here for consistency.

Value

CyTableColumn or RCX object with added hidden attributes

See Also

CySubNetworks

Examples

## For CyTableColumnssAspects: 
## prepare some aspects:
tableColumn1 = createCyTableColumn(
  appliesTo=c("nodes","edges","networks"),
  name=c("weight","weight","collapsed"),
  dataType=c("numeric","double","logical"),
  isList=c(FALSE,FALSE,TRUE),
  subnetworkId=c(NA,NA,1)
)

## nodes is updated, networks is new
tableColumn2 = createCyTableColumn(
  appliesTo=c("nodes","networks"),
  name=c("weight","collapsed"),
  dataType=c("double","character")
)

## Simply update with new values
tableColumn3 = updateCyTableColumn(tableColumn1, tableColumn2)

## Ignore already present keys
tableColumn3 = updateCyTableColumn(tableColumn1, tableColumn2, 
                                replace=FALSE)

## Raise an error if duplicate keys are present
try(updateCyTableColumn(tableColumn1, tableColumn2, 
                     stopOnDuplicates=TRUE))
## =>ERROR: 
## Elements of "appliesTo", "name" and "subnetworkId" (in updateCyTableColumn) 
## 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)

## add a table column property
rcx = updateCyTableColumn(rcx, tableColumn1)

## add an additional property (update with new values)
rcx = updateCyTableColumn(rcx, tableColumn2)

## create a prpperty with a not existing subnetwork...
tableColumn3 = createCyTableColumn(
  appliesTo="nodes",
  name="weight",
  subnetworkId=9
)

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

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