#'Created on Jun 4, 2018 #'Updated on May 4, 2020 #'Script example to generate disGeNET networks data in Cytoscape from R. #'Before executing the script, you must have Cytoscape running and the disGeNET-App installed #'(you don't need to start disGeNET app). #'Requires the httr library. library(httr) #' Creates a valid REST url for the REST call to the disGeNET automation module. #' @param netType A string containing the type of the network to be created. #' @param host The host of the url, by default 127.0.0.1 (localhost). To change the host do it manually. #' @param port The listening port, by default 1234. To change the port do it manually. #' @param version The version of the automation module, by default v7. #' @return url A string in url format, with the given parameters. #' @author jsauch disgenetRestUrl<-function(netType,host="127.0.0.1",port=1234,version="v7"){ if(is.null(netType)){ print("Network type not specified.") }else{ url<-sprintf("http://%s:%i/disgenet/%s/%s",host,port,version,netType) } return (url) } #'Executes a REST call to the disGeNET automation module in Cytoscape and retrieves the operation result. #'This function builds the url for the rest call automatically with the default values. #'@param netType A string containing the type of the network to be created. #'@param params A list with the params for the network. Check the possible params in the Swagger UI of cytoscape. #'@return result A list with the results of the operation. #'@author jsauch disgenetRestCall<-function(netType,netParams){ url<-disgenetRestUrl(netType) restCall<-POST(url, body = netParams, encode = "json") result<-content(restCall,"parsed") return(result) } #Example of params for the gene-disease network. geneDisParams <- list( source = "UNIPROT", assocType = "Genetic Variation", diseaseClass = "Neoplasms", diseaseSearch = " ", geneSearch = " ", initialScoreValue = "0.0", finalScoreValue = "1.0" ) #Example of params for the variant-disase network. variantDisParams <- list( source= "UNIPROT", assocType= "Genetic Variation", diseaseClass= "Neoplasms", diseaseSearch= " ", geneSearch= " ", variantSearch= " ", initialScoreValue= "0.0", finalScoreValue = "1.0", showGenes= "true" ) #Generate the gene-disease network, and show the resuland show the results.ts. geneDisResult <- disgenetRestCall("gene-disease-net",geneDisParams) #Generate the variant-disease network, and show the results. variantDisResult <- disgenetRestCall("variant-disease-net",variantDisParams) variantDisResult