updateCartesianLayout: Update Cartesian Layouts

View source: R/RCX-CartesianLayout.R

updateCartesianLayoutR Documentation

Update Cartesian Layouts

Description

This functions add a cartesian layout in the form of a CartesianLayout object to an other CartesianLayout or an RCX object.

Usage

updateCartesianLayout(
  x,
  cartesianLayout,
  replace = TRUE,
  stopOnDuplicates = FALSE,
  ...
)

## S3 method for class 'CartesianLayoutAspect'
updateCartesianLayout(
  x,
  cartesianLayout,
  replace = TRUE,
  stopOnDuplicates = FALSE,
  ...
)

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

Arguments

x

RCX or CartesianLayout object; (to which the new layout will be added)

cartesianLayout

CartesianLayout object; (the layout, that will be added)

replace

logical; if existing values are updated (or ignored)

stopOnDuplicates

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

...

additional parameters

checkReferences

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

Details

Networks, or more precisely its nodes may have a cartesian layout, that is represented as CartesianLayout object. CartesianLayout objects can be added to an RCX or an other CartesianLayout object.

In the case, that a CartesianLayout object is added to an other, or the RCX object already contains a CartesianLayout object, some attributes 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 properties are added and the existing properties 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.

Value

CartesianLayoutAspect or RCX object with added layout

Examples

## For CartesianLayoutAspects: 
## prepare some aspects:
cartesianLayout = createCartesianLayout(
  node=c(0, 1),
  x=c(5.5, 110.1), 
  y=c(200.3, 210.2),
  z=c(-1, 3.1),
)

## node 0 is updated, new view is added 
cartesianLayout2 = createCartesianLayout(
  node=c(0, 0),
  x=c(5.7, 7.2), 
  y=c(98, 13.9),
  view=c(NA, 1476)
)

## Simply update with new values
cartesianLayout3 = updateCartesianLayout(cartesianLayout, cartesianLayout2)

## Ignore already present keys
cartesianLayout3 = updateCartesianLayout(cartesianLayout, cartesianLayout2, 
                                         replace=FALSE)

## Raise an error if duplicate keys are present
try(updateCartesianLayout(cartesianLayout, cartesianLayout2, 
                          stopOnDuplicates=TRUE))
## =>ERROR: 
## Provided IDs (node, view) countain duplicates!

## For RCX:
## prepare RCX object:
nodes = createNodes(name = c("a","b"))
edges = createEdges(source = 0, target = 1)
cySubNetworks = createCySubNetworks(
  id = 1476,
  nodes = "all",
  edges = "all"                    
)
rcx = createRCX(nodes,
                edges = edges,
                cySubNetworks=cySubNetworks)

## add the network attributes
rcx = updateCartesianLayout(rcx, cartesianLayout)

## add additional network attributes and update existing
rcx = updateCartesianLayout(rcx, cartesianLayout2)

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