readCX: Read CX from file, parse the JSON and convert it to an RCX...

Description Usage Arguments Details Functions See Also Examples

View source: R/Json-fromJson.R

Description

The readCX function combines three sub-task:

Usage

1
2
3
4
5
6
7
readCX(file, verbose = F, aspectClasses = NULL)

readJSON(file, verbose = F)

parseJSON(json, verbose = F)

processCX(aspectList, verbose = F, aspectClasses = NULL)

Arguments

file

character; the name of the file which the data are to be read from

verbose

logical; whether to print what is happening

aspectClasses

named character; accession names and aspect classes aspectClasses

json

character; raw JSON data

aspectList

list; list containing the aspect data (parsed JSON)

Details

If any errors occur during this process, the single steps can be performed individually. This also allows to skip certain steps, for example if the JSON data is already availabe as text, there is no need to save it as file and read it again.

Read the JSON from file

The readJSON function only read the content of a text file and returns it as a simple character vector.

Parse the JSON

The parseJSON function uses the jsonlite package, to parse JSON text:

jsonlite::fromJSON(cx, simplifyVector = F)

The result is a list containing the aspect data as elements. If, for some reason, the JSON is not valid, the jsonlite package raises an error.

Process the contained aspects to create an RCX object

With the processCX function, the single elements from the previous list will be processed with the jsonToRCX functions, which creating objects for the single aspects. The standard CX aspects are processed by generic functions named by the aspect names of the CX data structure, e.g. jsonToRCX.nodeAttributes for the samely named CX aspect the corresponding NodeAttributesAspect in RCX (see also vignette("02. The RCX and CX Data Model") or NDEx documentation: https://home.ndexbio.org/data-model/).

The CX network may contain additional aspects besides the officially defined ones. This includes self defined or deprecated aspects, that sill can be found in the networks at the NDEx platform. By default, those aspects are simply omitted. In those cases, the setting verbose to TRUE is a good idea to see, which aspects cannot be processed this package.

Those not processable aspects can be handled individually, but it is advisable to extend the jsonToRCX functions by implementing own versions for those aspects. Additionally, the update functions have to be implemented to add the newly generated aspect objects to RCX object (see e.g. updateNodes or updateEdges). Therefore, the function also have to be named "update<aspect-name>, where aspect-name is the capitalized version of the name used in the CX. (see also vignette("03. Extending the RCX Data Model")

Functions

See Also

jsonToRCX, writeCX

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
cxFile = system.file(
  "extdata", 
  "Imatinib-Inhibition-of-BCR-ABL-66a902f5-2022-11e9-bb6a-0ac135e8bacf.cx", 
  package = "RCX"
)

rcx = readCX(cxFile)

## OR:

json = readJSON(cxFile)
aspectList = parseJSON(json)
rcx = processCX(aspectList)

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