## ----lib, echo=FALSE---------------------------------------------------------- library(ReactomeGraph4R) ## ----setup, eval=FALSE-------------------------------------------------------- # library(ReactomeGraph4R) # login() ## ----getData, echo=FALSE------------------------------------------------------ load("data/vignette.Rdata") ## ----basic-id, eval=FALSE----------------------------------------------------- # # Retrieve the object of PER2 gene # # NOTE: if you're unsure which database to specify, you have to leave it as NULL # matchObject(id = "PER2", databaseName = NULL) ## ----basic-id-data, echo=FALSE------------------------------------------------ per2 ## ----basic-id-2, eval=FALSE--------------------------------------------------- # matchObject(id = 'R-HSA-400219') ## ----basic-id-2-data, echo=FALSE---------------------------------------------- HSA_400219 ## ----multi-ids, eval=FALSE---------------------------------------------------- # # retrieve multiple objects # ids <- c('R-HSA-74158', 'R-HSA-1566977', 'R-HSA-3000157', 'R-HSA-3000178', 'R-HSA-216083') # multiObjects(ids) ## ----multi-ids-data, echo=FALSE----------------------------------------------- multiObj ## ----basic-name, eval=FALSE--------------------------------------------------- # matchObject(displayName = "SUMO1:TOP1 [nucleoplasm]", species = "C. elegans") ## ----basic-name-data, echo=FALSE---------------------------------------------- sumo ## ----basic-class, eval=FALSE-------------------------------------------------- # # Get 5 instance in Class EntitySet and return displayName & stId # entity.set <- matchObject(schemaClass = "EntitySet", species = "human", # returnedAttributes = c("displayName", "stId"), limit = 5) # entity.set[["databaseObject"]] # show as dataframe ## ----basic-class-data, echo=FALSE--------------------------------------------- entity.set[["databaseObject"]] ## ----basic-property, eval=FALSE----------------------------------------------- # # Get instances with conditions of properties that are stored in a list # matchObject(property = list(isChimeric = TRUE, isInDisease = TRUE), limit = 10)[["databaseObject"]] ## ----basic-property-data, echo=FALSE------------------------------------------ property ## ----basic-rel, eval=FALSE---------------------------------------------------- # # Get nodes connected with 'hasComponent' # matchObject(relationship = "hasComponent", limit = 3) ## ----basic-rel-data, echo=FALSE----------------------------------------------- rleObj ## ----hierarchy, eval=FALSE---------------------------------------------------- # # Get hierarchy data of R-HSA-500358 # pou5f1.hierarchy <- matchHierarchy(id = "R-HSA-500358", type = "row") # str(pou5f1.hierarchy, max.level = 1) ## ----hierarchy-data, echo=FALSE----------------------------------------------- str(pou5f1.hierarchy, max.level = 1) ## ----hierarchy-2-------------------------------------------------------------- # select essential columns to show pou5f1.hierarchy$relationships[,c(2,4,5,7,8)] ## ----r-in-p, eval=FALSE------------------------------------------------------- # # Find Reactions connected with R-HSA-8983688 # rle <- matchReactionsInPathway(event.id = "R-HSA-8983688", type = "row") ## ----r-in-p-data-------------------------------------------------------------- str(rle, max.level = 1) # The one in reactionLikeEvent is what we search for rle$reactionLikeEvent # Take a look at the connected Pathway rle$pathway ## ----r-in-p-2----------------------------------------------------------------- # Show displayNames of other RLEs rle$otherReactionLikeEvent[["displayName"]] ## ----export-img--------------------------------------------------------------- library(ReactomeContentService4R) # Export pathway diagram of "OAS antiviral response" exportImage(id = "R-HSA-8983711", output = "diagram", sel = "R-HSA-8983688", format = "png", quality = 8) ## ----p-f-event, eval=FALSE---------------------------------------------------- # # Retrieve RLE context with depth = 2 # rle.context <- matchPrecedingAndFollowingEvents(event.id = "R-HSA-8983688", depth = 2, type = "row") # str(rle.context, max.level = 1) ## ----p-f-event-data, echo=FALSE----------------------------------------------- str(rle.context, max.level = 1) ## ----referral, eval=FALSE----------------------------------------------------- # # Find referrals of the given Regulation # matchReferrals(id = 6810147, type = "row") ## ----referral-data, echo=FALSE------------------------------------------------ referral ## ----interactor, eval=FALSE--------------------------------------------------- # # Retrieve interaction data of the given PE # interactors <- matchInteractors(pe.id = "R-HSA-419535") ## ----interactor-2------------------------------------------------------------- str(interactors, max.level = 1) interactors$interaction ## ----PEroles, eval=FALSE------------------------------------------------------ # # Find possible roles of the given PE # roles <- matchPEroles(pe.displayName = "HSBP1 oligomer [cytosol]") ## ----PEroles-data------------------------------------------------------------- str(roles, max.level = 1) # get the roles (relationships type) unique(roles$relationships$type) ## ----disease, eval=FALSE------------------------------------------------------ # # Fetch Reactome instances associated with 'neuropathy' in human # matchDiseases(displayName = "neuropathy", species = "human", type = "row") ## ----disease-data, echo=FALSE------------------------------------------------- disease ## ----paper, eval=FALSE-------------------------------------------------------- # # fetch objects by paper title # matchPaperObjects(displayName = "Aggresomes: a cellular response to misfolded proteins", type = "row") ## ----paper-data, echo=FALSE--------------------------------------------------- papers ## ----vis-loading-------------------------------------------------------------- # install packages list.pkg <- c("stringr", "visNetwork", "networkD3", "wesanderson") new.pkg <- list.pkg[!(list.pkg %in% installed.packages()[ ,"Package"])] if (length(new.pkg)) { install.packages(new.pkg, repos = "https://cloud.r-project.org/") } # load invisible(suppressPackageStartupMessages(lapply(list.pkg, library, character.only = TRUE))) ## ----vis-1, eval=FALSE-------------------------------------------------------- # # Get graph output data # graph <- matchHierarchy(displayName = "UniProt:P33992 MCM5", databaseName = "UniProt", type = "graph") ## ----vis-1-data--------------------------------------------------------------- relationships <- graph[["relationships"]] nodes <- graph[["nodes"]] nodes <- unnestListCol(df = nodes, column = "properties") # unnest the 'properties' column of lists head(nodes); head(relationships) # Transform into visNetwork format for nodes & edges vis.nodes <- data.frame(id = nodes$id, label = str_trunc(nodes$displayName, 20), # truncate the long names group = nodes$schemaClass, title = paste0("
", nodes$schemaClass, "
",
"dbId: ", nodes$dbId, "
", nodes$displayName, "