Consider the following:
- Read the ID column into the R script as a string, especially for the ID values from the Proteins table. (As shown in earlier, the ID columns exported from any table in Proteome Discoverer are exported with quotes around them.) If the columns are in a numeric value, it can lead to inaccurately importing them to the script. Inaccurately importing columns into the script has downstream consequences when to importing results back into the application.
- Use the rjsonio library to import the JSON files into the script. The two other JSON libraries available at the time of software release, jsonlite and rjson, either modify the structure of the JSON object or add extraneous characters. These libraries produce node_response.json files that cannot be recognized by the application without custom modification,
When using the rjsonio library, make sure that the format of the node_response.json file matches that of the node_args.json file. When using this library, the following code snippet reads the node_args.json file and writes out the JSON structure to node_response.json:
library(RJSONIO)
fileConn <- file(inputFile) # inputFile is the full path of the node_args.json file
nodeArgs <- readLines(fileConn)
nodeArgs <-paste(nodeArgs, collapse = "\n")
nodeArgs <- gsub("\u00A0", "", nodeArgs)
close(fileConn)
PD_json_in <- fromJSON(nodeArgs, simplify=F)
responseJSON <- toJSON(PD_json_out, indent=3)
jsonfileconn <- file(jsonOutFile) # jsonOutFile is the full path of the node_response.json file. This needs to be in the same folder as node_args.json
writeLines(responseJSON, jsonfileconn)
close (jsonfileconn)
For a suitable example template script, which follows these and other suggested guidelines, refer to the ProteinStartsWith.R script in the application media.