diff --git a/NAMESPACE b/NAMESPACE index 691642f..448ebb2 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -5,6 +5,7 @@ export(getSubnetworkFromIndra) export(visualizeNetworks) importFrom(RCy3,createNetworkFromDataFrames) importFrom(RCy3,createVisualStyle) +importFrom(RCy3,layoutNetwork) importFrom(RCy3,mapVisualProperty) importFrom(RCy3,setVisualStyle) importFrom(httr,POST) diff --git a/R/annotateProteinInfoFromIndra.R b/R/annotateProteinInfoFromIndra.R index a03c204..5d39135 100644 --- a/R/annotateProteinInfoFromIndra.R +++ b/R/annotateProteinInfoFromIndra.R @@ -2,7 +2,7 @@ #' #' This function annotates a data frame with protein information from Indra. #' -#' @param input output of \code{\link[MSstats]{groupComparison}} function's +#' @param df output of \code{\link[MSstats]{groupComparison}} function's #' comparisonResult table, which contains a list of proteins and their #' corresponding p-values, logFCs, along with additional HGNC ID and HGNC #' name columns diff --git a/R/getSubnetworkFromIndra.R b/R/getSubnetworkFromIndra.R index 7c20dda..40b2d33 100644 --- a/R/getSubnetworkFromIndra.R +++ b/R/getSubnetworkFromIndra.R @@ -25,6 +25,7 @@ #' getSubnetworkFromIndra <- function(input, pvalueCutoff = NULL) { input <- .filterGetSubnetworkFromIndraInput(input, pvalueCutoff) + .validateGetSubnetworkFromIndraInput(input) res <- .callIndraCogexApi(input$HgncId) nodes <- .constructNodesDataFrame(input) edges <- .constructEdgesDataFrame(res, input) diff --git a/R/utils_getSubnetworkFromIndra.R b/R/utils_getSubnetworkFromIndra.R index 4743734..4e92aaf 100644 --- a/R/utils_getSubnetworkFromIndra.R +++ b/R/utils_getSubnetworkFromIndra.R @@ -1,3 +1,13 @@ +#' Validate input for MSstatsBioNet getSubnetworkFromIndra +#' @param input dataframe from MSstats groupComparison output +#' @keywords internal +#' @noRd +.validateGetSubnetworkFromIndraInput <- function(input) { + if (nrow(input) >= 400) { + stop("Invalid Input Error: INDRA query must contain less than 400 proteins. Consider adding a p-value cutoff") + } +} + #' Call INDRA Cogex API and return response #' @param hgncIds list of hgnc ids #' @return list of INDRA statements diff --git a/R/visualizeNetworks.R b/R/visualizeNetworks.R index b146986..a74c76b 100644 --- a/R/visualizeNetworks.R +++ b/R/visualizeNetworks.R @@ -14,7 +14,7 @@ #' @param logfcCutoff log fold change cutoff for coloring significant #' proteins. Default is 0.5 #' @importFrom RCy3 createNetworkFromDataFrames mapVisualProperty -#' createVisualStyle setVisualStyle +#' createVisualStyle setVisualStyle layoutNetwork #' #' @export #' @@ -56,7 +56,7 @@ visualizeNetworks <- function(nodes, edges, mapVisualProperty( "Node Fill Color", "logFC_color", "c", c(-logfcCutoff, 0.0, logfcCutoff), - c("#5588DD", "#5588DD", "#D3D3D3", "#DD8855", "#DD8855") + c("#ADD8E6", "#ADD8E6", "#D3D3D3", "#FFA590", "#FFA590") ) ) createVisualStyle( diff --git a/man/annotateProteinInfoFromIndra.Rd b/man/annotateProteinInfoFromIndra.Rd index 2cb5e64..35d2767 100644 --- a/man/annotateProteinInfoFromIndra.Rd +++ b/man/annotateProteinInfoFromIndra.Rd @@ -7,7 +7,10 @@ annotateProteinInfoFromIndra(df, proteinIdType) } \arguments{ -\item{df}{A data frame containing protein information.} +\item{df}{output of \code{\link[MSstats]{groupComparison}} function's +comparisonResult table, which contains a list of proteins and their +corresponding p-values, logFCs, along with additional HGNC ID and HGNC +name columns} \item{proteinIdType}{A character string specifying the type of protein ID. It can be either "Uniprot" or "Uniprot_Mnemonic".} diff --git a/man/dot-populateHgncIdsInDataFrame.Rd b/man/dot-populateHgncIdsInDataFrame.Rd new file mode 100644 index 0000000..886c686 --- /dev/null +++ b/man/dot-populateHgncIdsInDataFrame.Rd @@ -0,0 +1,17 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/annotateProteinInfoFromIndra.R +\name{.populateHgncIdsInDataFrame} +\alias{.populateHgncIdsInDataFrame} +\title{Populate HGNC IDs in Data Frame} +\usage{ +.populateHgncIdsInDataFrame(df) +} +\arguments{ +\item{df}{A data frame containing protein information.} +} +\value{ +A data frame with populated HGNC IDs. +} +\description{ +This function populates the HGNC IDs in the data frame based on the Uniprot IDs. +} diff --git a/man/dot-populateHgncNamesInDataFrame.Rd b/man/dot-populateHgncNamesInDataFrame.Rd new file mode 100644 index 0000000..23d91d8 --- /dev/null +++ b/man/dot-populateHgncNamesInDataFrame.Rd @@ -0,0 +1,17 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/annotateProteinInfoFromIndra.R +\name{.populateHgncNamesInDataFrame} +\alias{.populateHgncNamesInDataFrame} +\title{Populate HGNC Names in Data Frame} +\usage{ +.populateHgncNamesInDataFrame(df) +} +\arguments{ +\item{df}{A data frame containing protein information.} +} +\value{ +A data frame with populated HGNC names. +} +\description{ +This function populates the HGNC names in the data frame based on the HGNC IDs. +} diff --git a/man/dot-populateKinaseInfoInDataFrame.Rd b/man/dot-populateKinaseInfoInDataFrame.Rd new file mode 100644 index 0000000..aa8dddd --- /dev/null +++ b/man/dot-populateKinaseInfoInDataFrame.Rd @@ -0,0 +1,17 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/annotateProteinInfoFromIndra.R +\name{.populateKinaseInfoInDataFrame} +\alias{.populateKinaseInfoInDataFrame} +\title{Populate Kinase Info in Data Frame} +\usage{ +.populateKinaseInfoInDataFrame(df) +} +\arguments{ +\item{df}{A data frame containing protein information.} +} +\value{ +A data frame with populated kinase information. +} +\description{ +This function populates the kinase information in the data frame based on the HGNC names. +} diff --git a/man/dot-populatePhophataseInfoInDataFrame.Rd b/man/dot-populatePhophataseInfoInDataFrame.Rd new file mode 100644 index 0000000..e0cd5b5 --- /dev/null +++ b/man/dot-populatePhophataseInfoInDataFrame.Rd @@ -0,0 +1,17 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/annotateProteinInfoFromIndra.R +\name{.populatePhophataseInfoInDataFrame} +\alias{.populatePhophataseInfoInDataFrame} +\title{Populate Phosphatase Info in Data Frame} +\usage{ +.populatePhophataseInfoInDataFrame(df) +} +\arguments{ +\item{df}{A data frame containing protein information.} +} +\value{ +A data frame with populated phosphatase information. +} +\description{ +This function populates the phosphatase information in the data frame based on the HGNC names. +} diff --git a/man/dot-populateTranscriptionFactorInfoInDataFrame.Rd b/man/dot-populateTranscriptionFactorInfoInDataFrame.Rd new file mode 100644 index 0000000..e54c6f3 --- /dev/null +++ b/man/dot-populateTranscriptionFactorInfoInDataFrame.Rd @@ -0,0 +1,17 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/annotateProteinInfoFromIndra.R +\name{.populateTranscriptionFactorInfoInDataFrame} +\alias{.populateTranscriptionFactorInfoInDataFrame} +\title{Populate Transcription Factor Info in Data Frame} +\usage{ +.populateTranscriptionFactorInfoInDataFrame(df) +} +\arguments{ +\item{df}{A data frame containing protein information.} +} +\value{ +A data frame with populated transcription factor information. +} +\description{ +This function populates the transcription factor information in the data frame based on the HGNC names. +} diff --git a/man/dot-populateUniprotIdsInDataFrame.Rd b/man/dot-populateUniprotIdsInDataFrame.Rd new file mode 100644 index 0000000..43bee6e --- /dev/null +++ b/man/dot-populateUniprotIdsInDataFrame.Rd @@ -0,0 +1,20 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/annotateProteinInfoFromIndra.R +\name{.populateUniprotIdsInDataFrame} +\alias{.populateUniprotIdsInDataFrame} +\title{Populate Uniprot IDs in Data Frame} +\usage{ +.populateUniprotIdsInDataFrame(df, proteinIdType) +} +\arguments{ +\item{df}{A data frame containing protein information.} + +\item{proteinIdType}{A character string specifying the type of protein ID. +It can be either "Uniprot" or "Uniprot_Mnemonic".} +} +\value{ +A data frame with populated Uniprot IDs. +} +\description{ +This function populates the Uniprot IDs in the data frame based on the protein ID type. +} diff --git a/man/dot-validateAnnotateProteinInfoFromIndraInput.Rd b/man/dot-validateAnnotateProteinInfoFromIndraInput.Rd new file mode 100644 index 0000000..e9f9e2a --- /dev/null +++ b/man/dot-validateAnnotateProteinInfoFromIndraInput.Rd @@ -0,0 +1,17 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/annotateProteinInfoFromIndra.R +\name{.validateAnnotateProteinInfoFromIndraInput} +\alias{.validateAnnotateProteinInfoFromIndraInput} +\title{Validate Annotate Protein Info Input} +\usage{ +.validateAnnotateProteinInfoFromIndraInput(df) +} +\arguments{ +\item{df}{A data frame containing protein information.} +} +\value{ +None. Throws an error if validation fails. +} +\description{ +This function validates the input data frame for the annotateProteinInfoFromIndra function. +} diff --git a/man/getSubnetworkFromIndra.Rd b/man/getSubnetworkFromIndra.Rd index d65ffcb..2f5ed5b 100644 --- a/man/getSubnetworkFromIndra.Rd +++ b/man/getSubnetworkFromIndra.Rd @@ -7,9 +7,10 @@ getSubnetworkFromIndra(input, pvalueCutoff = NULL) } \arguments{ -\item{input}{output of groupComparison function's comparisionResult table, -which contains a list of proteins and their corresponding p-values, logFCs, -along with additional HGNC ID and HGNC name columns} +\item{input}{output of \code{\link[MSstats]{groupComparison}} function's +comparisionResult table, which contains a list of proteins and their +corresponding p-values, logFCs, along with additional HGNC ID and HGNC +name columns} \item{pvalueCutoff}{p-value cutoff for filtering. Default is NULL, i.e. no filtering} diff --git a/tests/testthat/test-getSubnetworkFromIndra.R b/tests/testthat/test-getSubnetworkFromIndra.R index b41f297..0c75979 100644 --- a/tests/testthat/test-getSubnetworkFromIndra.R +++ b/tests/testthat/test-getSubnetworkFromIndra.R @@ -23,3 +23,15 @@ test_that("getSubnetworkFromIndra with pvalue filter works correctly", { expect_equal(nrow(subnetwork$nodes), 6) expect_equal(nrow(subnetwork$edges), 1) }) + +test_that("Exception is thrown for 400+ proteins in dataframe", { + input_400 <- data.frame( + Protein = paste0("Protein", 1:400), + issue = NA, + adj.pvalue = 0.05 + ) + expect_error( + getSubnetworkFromIndra(input_400), + "Invalid Input Error: INDRA query must contain less than 400 proteins. Consider adding a p-value cutoff" + ) +})