diff --git a/DESCRIPTION b/DESCRIPTION index dbb17b0fe90fbb7a8792091335515bc0e7c5a3db..9c57a6efb1f14649c47830183634721135b0ae1d 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: ViSEAGO -Version: 1.3.7 +Version: 1.3.8 Title: ViSEAGO: a Bioconductor package for clustering biological functions using Gene Ontology and semantic similarity Author: Aurelien Brionne [aut, cre], Amelie Juanchich [aut], @@ -51,7 +51,7 @@ URL: https://www.bioconductor.org/packages/release/bioc/html/ViSEAGO.html, https://forgemia.inra.fr/UMR-BOA/ViSEAGO BugReports: https://forgemia.inra.fr/UMR-BOA/ViSEAGO/issues biocViews: Software, Annotation, GO, GeneSetEnrichment, MultipleComparison, Clustering, Visualization -RoxygenNote: 7.1.0 +RoxygenNote: 7.1.1 Collate: 'genomic_ressource.R' 'Bioconductor2GO.R' diff --git a/R/enrich_GO_terms.R b/R/enrich_GO_terms.R index 8fa5d88426127c4480ebf0f8ac5a4f7f882dada7..97c97c506b54e36ed1b81a6ad36124a76282d4b1 100644 --- a/R/enrich_GO_terms.R +++ b/R/enrich_GO_terms.R @@ -14,6 +14,7 @@ setClass( same_genes_background="logical", input="list", ont="character", + cutoff="list", topGO="list", data="data.table" ) @@ -33,20 +34,7 @@ setMethod( Data<-Data[,grep("\\.pvalue",names(Data)),with=FALSE] # pvalues threshlod according condition - p<-vapply(slot(object,"topGO"),function(x){ - - # unlist - x=unlist(x) - - # extract pvalue threshold - as.numeric( - sub( - "^.+<", - "", - x[grep("test_name",names(x))] - ) - ) - },0) + p<-unlist(slot(object,"cutoff")) # count significant pvalues by condition Data<-lapply(seq_len(ncol(Data)),function(x){ diff --git a/R/merge_enrich_terms.R b/R/merge_enrich_terms.R index 0c06c275d9e43c382d0acb77e42a37a9b4b15f6c..17c482bcdd82d9331a171362d73436f692442362 100644 --- a/R/merge_enrich_terms.R +++ b/R/merge_enrich_terms.R @@ -9,13 +9,14 @@ #' @family GO_terms #' @param Input a list containing named elements. Each element must contain the name of \code{\link[topGO]{topGOdata-class}} #' object created by \code{\link{create_topGOdata}} method and the associated \code{\link[topGO]{topGOresult-class}} object(s). +#' @param cutoff default pvalue cutoff (default to 0.01). Several cutoff can be use in the same order as list elements. #' @param envir objects environment (default to .GlobalEnv). #' @details This method extracts for each result of GO enrichment test (\code{\link[topGO]{topGOresult-class}} object) and #' corresponding GO annotations (\code{\link[topGO]{topGOdata-class}} object): #' informations about GO term (identifiant, name, and description), #' gene frequency (number of significant genes / Annotated genes), pvalue, -log10(pvalue), significant genes #' identifiants (GeneID, or Ensembl ID, or uniprot accession), and gene symbols. -#' At the last, this method builds a merged data.table of enriched GO terms (p<0.01) +#' At the last, this method builds a merged data.table of enriched GO terms #' at least once and provides all mentionned columns. #' @return an \code{\link{enrich_GO_terms-class}} object. #' @references @@ -129,6 +130,7 @@ setGeneric( name="merge_enrich_terms", def=function( Input, + cutoff=0.01, envir=.GlobalEnv ){ standardGeneric("merge_enrich_terms") @@ -142,7 +144,19 @@ setMethod( signature( Input="list" ), - definition=function(Input,envir){ + definition=function(Input,cutoff,envir){ + + ## cutoff + + # check cutoff length according Input + if(length(cutoff)>1 & length(cutoff)!=length(Input)){ + stop("cutoff must be a single value to repet for each list element, or the same length than list") + } + + # repet cutoff value according Input length + if(length(cutoff)==1){ + cutoff<-rep(cutoff,length(Input)) + } ## check ontology @@ -202,6 +216,9 @@ setMethod( # build topGO summary topGO_summary=lapply(seq_along(Input),function(x){ + # keep pos + pos=x + # extract quering objects names x=Input[[x]] @@ -266,7 +283,7 @@ setMethod( GO_scored=length(slot(x[[y]],"score")), # significant GOs according cutOff - GO_significant=table(slot(x[[y]],"score")<as.numeric(sub("^.+[[:space:]]","",slot(x[[y]],"testName"))))[2], + GO_significant=table(slot(x[[y]],"score")<cutoff[pos])[2], # feasibles genes feasible_genes=slot(x[[y]],"geneData")[1], @@ -329,7 +346,7 @@ setMethod( # extract names of enrich terms as.vector( names( - pvalues[pvalues<as.numeric(sub("^.+[[:space:]]","",slot(Data[[pos]],"testName")))] + pvalues[pvalues<cutoff[x]] ) ) }) @@ -595,12 +612,23 @@ setMethod( # if db match to Ensembl if(db[1]=="Ensembl"){ - # connect to Ensembl - mart<-useEnsembl( - "ensembl", - host=db[2], - version=db[6] - ) + if(db[3]!="http://grch37.ensembl.org"){ + + # connect to Ensembl + mart<-useEnsembl( + biomart="genes", + host=db[3], + version=db[6] + ) + + }else{ + # connect to Ensembl + mart<-useEnsembl( + biomart="genes", + GRCh =37, + version=db[6] + ) + } # connect to ensembl specified dataset myspecies<-useDataset( @@ -720,11 +748,8 @@ setMethod( # remove NA in GO.Id column Results<-Results[!is.na(Results$GO.ID)] - # extract pvalue threshold - p<-as.numeric(sub("^.+[[:space:]]","",slot(algorithm[[1]],"testName"))) - # Remove gene ID and symbol if GO term not significant - Results[Results$pvalue>=p,`:=`(Significant_genes=NA,Significant_genes_symbol=NA)] + Results[Results$pvalue>=cutoff[x],`:=`(Significant_genes=NA,Significant_genes_symbol=NA)] if(!is.null(names(Input))){ @@ -792,6 +817,7 @@ setMethod( input=input, ont=check.onto, topGO=topGO_summary, + cutoff=list(cutoff), data=allResults ) } diff --git a/README.md b/README.md index 6c2ce311424e9ef4dda85af7aad1e074d5b7c8c7..8ad7a84e0259b055e947b9e1367b014fc0aa5990 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ remotes::install_gitlab( devtools::build("ViSEAGO") # install package (from R console) - install.packages("ViSEAGO_1.3.7.tar.gz", repos = NULL, type = "source") + install.packages("ViSEAGO_1.3.8.tar.gz", repos = NULL, type = "source") ``` ## Citation diff --git a/man/merge_enrich_terms-methods.Rd b/man/merge_enrich_terms-methods.Rd index 8145dca8bfc1e32dec03f3df0669034db5766b90..5fab93c95e8830152beb87f02b8f73f5b9c8b0c4 100644 --- a/man/merge_enrich_terms-methods.Rd +++ b/man/merge_enrich_terms-methods.Rd @@ -5,14 +5,16 @@ \alias{merge_enrich_terms,list-method} \title{Merge enriched GO terms.} \usage{ -merge_enrich_terms(Input, envir = .GlobalEnv) +merge_enrich_terms(Input, cutoff = 0.01, envir = .GlobalEnv) -\S4method{merge_enrich_terms}{list}(Input, envir = .GlobalEnv) +\S4method{merge_enrich_terms}{list}(Input, cutoff = 0.01, envir = .GlobalEnv) } \arguments{ \item{Input}{a list containing named elements. Each element must contain the name of \code{\link[topGO]{topGOdata-class}} object created by \code{\link{create_topGOdata}} method and the associated \code{\link[topGO]{topGOresult-class}} object(s).} +\item{cutoff}{default pvalue cutoff (default to 0.01). Several cutoff can be use in the same order as list elements.} + \item{envir}{objects environment (default to .GlobalEnv).} } \value{ @@ -28,7 +30,7 @@ corresponding GO annotations (\code{\link[topGO]{topGOdata-class}} object): informations about GO term (identifiant, name, and description), gene frequency (number of significant genes / Annotated genes), pvalue, -log10(pvalue), significant genes identifiants (GeneID, or Ensembl ID, or uniprot accession), and gene symbols. -At the last, this method builds a merged data.table of enriched GO terms (p<0.01) +At the last, this method builds a merged data.table of enriched GO terms at least once and provides all mentionned columns. } \examples{ diff --git a/vignettes/mouse_bionconductor.Rmd b/vignettes/mouse_bionconductor.Rmd index f72292131fe6614183adde2e2c9b34de3d35afde..9201dadc9c9f1ff7f3bc8e1b88414160ba4ce99b 100644 --- a/vignettes/mouse_bionconductor.Rmd +++ b/vignettes/mouse_bionconductor.Rmd @@ -210,6 +210,7 @@ The printed table contains for each enriched GO terms, additional columns includ ```{r Enrichment_merge} # merge topGO results BP_sResults<-ViSEAGO::merge_enrich_terms( + cutoff=0.01, Input=list( PregnantvsLactate=c( "BP_PregnantvsLactate",