Skip to content

Commit

Permalink
rename fileOuput and getMolList functions
Browse files Browse the repository at this point in the history
  • Loading branch information
kovidhv committed Feb 17, 2021
1 parent c18d270 commit e80375c
Show file tree
Hide file tree
Showing 18 changed files with 83 additions and 143 deletions.
4 changes: 2 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ export(SBGNview)
export(changeDataId)
export(changeIds)
export(downloadSbgnFile)
export(fileOutput)
export(findPathways)
export(getMolList)
export(highlightArcs)
export(highlightNodes)
export(highlightPath)
export(loadMappingTable)
export(outputFile)
export(renderSbgn)
export(sbgn.gsets)
export(sbgnNodes)
import(KEGGREST)
import(Rdpack)
Expand Down
3 changes: 1 addition & 2 deletions R/SBGNview.R
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ SBGNview <- function(gene.data = NULL, cpd.data = NULL, simulate.data = FALSE, i
### this function is for internal use only
# SBGNview S3 class
#
# This S3 class of objects contains information generated by the SBGNview function. A demo is available by running 'data(SBGNview.obj)'.
# This S3 class of objects contains information generated by the SBGNview function.
# The SBGNview object can be modified by using the "+" binary operator in conjunction with the \code{\link{highlightArcs}}, \code{\link{highlightNodes}}, and \code{\link{highlightPath}} functions.
# This mechanism to allow layer-by-layer graph modification is similar to that of ggplot2, a widely used R package for data visualization.
# Defining this class as a formal (S4) class will produce an S4 SBGNview object which doesn't work with the binary operator and doesn't allow for layer-by-layer graph modification.
Expand All @@ -249,7 +249,6 @@ SBGNview <- function(gene.data = NULL, cpd.data = NULL, simulate.data = FALSE, i
# 3. output.formats:
# A character vector specifying the formats of output image files. The vector should be a subset of c('pdf' , 'ps', 'png'). By default the function will always output a svg file.
# @examples
# data(SBGNview.obj)

createSBGNviewObject <- function(data, output.file, output.formats){
structure(list(data = data, output.file = output.file,
Expand Down
7 changes: 3 additions & 4 deletions R/SBGNview.obj.fun.R
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,15 @@ merge.entity.specific.parameters.list <- function(obj) {
#########################################################################################################
#' Retrieve output file information from a SBGNview object
#'
#' @param obj An SBGNview class object.
#' @param obj A SBGNview class object.
#' @details This function prints the output file path recorded in a SBGNview object.
#' @return A string. The output file information.
#' @examples
#' \dontrun{
#' fileOutput(SBGNview.obj)
#' outputFile(SBGNview.obj)
#' }
#' @export

fileOutput <- function(obj) {
outputFile <- function(obj) {
obj$output.file
}

Expand Down
23 changes: 0 additions & 23 deletions R/data.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,6 @@
#' @usage data(pathways.stats)
"pathways.stats"

#########################################################################################################
#' Demo SBGNview object
#' @details An example SBGNview object for demo purposes.
#' This S3 class of objects contains information generated by the SBGNview function.
#' The SBGNview object can be modified by using the "+" binary operator in conjunction with the \code{\link{highlightArcs}}, \code{\link{highlightNodes}}, and \code{\link{highlightPath}} functions.
#' This mechanism to allow layer-by-layer graph modification is similar to that of ggplot2, a widely used R package for data visualization.
#' Defining this class as a formal (S4) class will produce an S4 SBGNview object which doesn't work with the binary operator and doesn't allow for layer-by-layer graph modification.
#' Therefore, we decided to go with the S3 implementation of the SBGNview class since it works well with the binary operator making this
#' functionality more intuitive and user friendly.
#'
#' @format A list containing three elements:
#'
#' 1. data:
#' A list contains information for all input SBGN pathways. Each element is a list (e.g. 'P00001') holding information of a single SBGN pathway. The information include parsed information of glyphs, arcs and SBGNview parameters passed to SBGNview function
#'
#' 2. output.file:
#' A string of the path to the output file. It is the string set by parameter 'output.file' in function SBGNview.
#'
#' 3. output.formats:
#' A character vector specifying the formats of output image files. The vector should be a subset of c('pdf' , 'ps', 'png'). By default the function will always output a svg file.
#' @usage data(SBGNview.obj)
"SBGNview.obj"

#########################################################################################################
#' Mapping tables available in SBGNhub
#' @details A collection of ID mapping table files available in SBGNhub.
Expand Down
19 changes: 10 additions & 9 deletions R/download.utilities.R
Original file line number Diff line number Diff line change
Expand Up @@ -705,27 +705,28 @@ load.all.ids.mapping <- function(database, all.pairs.id.mapping.list, species, o
#########################################################################################################
#' Retrieve gene list or compound list from collected databases
#'
#' @param database A character string. Default: "pathwayCommons". The database where gene list will be extracted. Acceptable values: 'MetaCyc', 'pathwayCommons', 'MetaCrop'. The value is case in-sensitive.
#' @param id.type A character string. Default: "ENTREZID". The ID type of output gene list. One of the supported types in \code{data('mapped.ids')}
#' @param org A character string. Default: "hsa". The three letter species code used by KEGG. E.g. 'hsa','mmu'
#' @param mol.type A character string. Default: "gene". One of 'gene' or 'cpd'
#' @param species A character string. Default: "hsa". The three letter species code used by KEGG. E.g. 'hsa','mmu'
#' @param database A character string. Default: "pathwayCommons". The database where gene list will be extracted. Acceptable values: 'MetaCyc', 'pathwayCommons', 'MetaCrop'. The value is case in-sensitive.
#' @param output.pathway.name Logical. Default: T. If set to 'TRUE', the names of returned list are in the format: 'pathway.id::pathway.name'. If set to 'FALSE', the format is 'pahtway.id'
#' @param combine.duplicated.set Logical. Default: T. Some pathways have the same geneset. If this parameter is set to 'TRUE', the output list will combine pathways that have the same gene set. The name in the list will be pathway names concatinated with '||'
#' @param truncate.name.length Integer. Default: 50. The pathway names will be truncated to at most that length.
#' @param SBGNview.data.folder A character string. Default: "./SBGNview.tmp.data". The path to a folder that will hold downloaded ID mapping files and pathway information data files.
#' @return A list. Each element is a genelist of a pathway.
#' @examples
#' data(pathways.info)
#' mol.list <- getMolList(database = 'pathwayCommons',
#' id.type = 'ENTREZID',
#' org = 'hsa')
#' mol.list <- sbgn.gsets(id.type = 'ENTREZID',
#' species = 'hsa',
#' database = 'pathwayCommons')
#'
#' @export

getMolList <- function(database = "pathwayCommons", id.type = "ENTREZID", org = "hsa",
mol.type = "gene", output.pathway.name = TRUE, combine.duplicated.set = TRUE,
sbgn.gsets <- function(id.type = "ENTREZID", mol.type = "gene", species = "hsa", database = "pathwayCommons",
output.pathway.name = TRUE, combine.duplicated.set = TRUE,
truncate.name.length = 50, SBGNview.data.folder = "./SBGNview.tmp.data") {

if(id.type %in% c("ENTREZID", "eg", "entrez", "entrezid")) id.type <- "ENTREZID"
if (tolower(database) == "metacrop") {
if (mol.type == "gene") {
id.in.pathway <- "ENZYME"
Expand All @@ -745,7 +746,7 @@ getMolList <- function(database = "pathwayCommons", id.type = "ENTREZID", org =
}
# metacrop initial list is using enzyme
ref.to.pathway <- loadMappingTable(input.type = id.in.pathway, output.type = "pathway.id",
mol.type = mol.type, species = org, SBGNview.data.folder = SBGNview.data.folder)
mol.type = mol.type, species = species, SBGNview.data.folder = SBGNview.data.folder)

if (id.type == id.in.pathway) {
out.id.to.pathway <- ref.to.pathway
Expand All @@ -755,7 +756,7 @@ getMolList <- function(database = "pathwayCommons", id.type = "ENTREZID", org =

out.id.type.to.ref <- loadMappingTable(input.type = id.in.pathway, output.type = id.type,
mol.type = mol.type, limit.to.ids = ref.to.pathway[, id.in.pathway],
species = org, SBGNview.data.folder = SBGNview.data.folder)
species = species, SBGNview.data.folder = SBGNview.data.folder)

out.id.type.to.ref <- out.id.type.to.ref
# merge KO to pathway and KO to output id
Expand Down
6 changes: 3 additions & 3 deletions R/highlight.utilities.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ highlight.edges <- function(node.set, arcs = NULL, node.set.id.type = NULL, arc.
#########################################################################################################
#' Highlight input nodes
#'
#' Change node properties such as border color and width to highlight a list of input nodes. This function should be used as the second argument to function \code{\link{+.SBGNview}}.
#' Change node properties such as border color and width to highlight a list of input nodes. This function should be used as the second argument to function. Run \code{help("+.SBGNview")} for more information.
#'
#' @param node.set A vector of character strings. Default: "all". Input molecule IDs whose nodes are to be highlighted. It can be any ID types supported by SBGNview.
#' @param node.set.id.type A character string. Default: "CompoundName". ID type of input nodes.
Expand Down Expand Up @@ -190,7 +190,7 @@ highlight.nodes.each.sbgn <- function(node.set = "all", select.glyph.class = c()
#########################################################################################################
#' Highlight shortest path between two nodes
#'
#' Given two nodes, find the shortest path between them and highlight the path. Other molecules/nodes and edges involved in reactions in the path are also highlighted.
#' Given two nodes, find the shortest path between them and highlight the path. Other molecules/nodes and edges involved in reactions in the path are also highlighted. This function should be used as the second argument to function. Run \code{help("+.SBGNview")} for more information.
#'
#' @param from.node A character string. The molecule ID of source node.
#' @param to.node A character string. The molecule ID of target node.
Expand Down Expand Up @@ -349,7 +349,7 @@ highlight.path.each.sbgn <- function(from.node, to.node, glyphs = NULL, arcs = N
#########################################################################################################
#' Highlight arcs by arc class
#'
#' This function can modify a SBGNview object's arc. Normally we use it as an argument to \code{\link{+.SBGNview}} and modify a SBGNview object
#' This function can modify a SBGNview object's arc. Normally we use it as an argument to \code{+.SBGNview} and modify a SBGNview object. Run \code{help("+.SBGNview")} for more information.
#'
#' @param class A character string. Default: "arc". The arc class to modify.
#' @param color A character string. Default: "black". The color of arcs with selected 'class'.
Expand Down
Binary file removed data/SBGNview.obj.RData
Binary file not shown.
34 changes: 0 additions & 34 deletions man/SBGNview.obj.Rd

This file was deleted.

2 changes: 1 addition & 1 deletion man/highlightArcs.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/highlightNodes.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/highlightPath.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions man/fileOutput.Rd → man/outputFile.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 12 additions & 12 deletions man/getMolList.Rd → man/sbgn.gsets.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions tests/testthat/test-user.level.functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ test_that("downloadSbgn", {
})

###################################################
test_that("getMolList", {
test_that("sbgn.gsets", {

mol.list <- getMolList(database = "metacrop",
mol.list <- sbgn.gsets(database = "metacrop",
id.type = "ENZYME",
org = "ath",
species = "ath",
output.pathway.name = FALSE,
truncate.name.length = 50)
expect_gte(length(mol.list), 0)
Expand Down
Loading

0 comments on commit e80375c

Please sign in to comment.