diff --git a/DESCRIPTION b/DESCRIPTION index 0748244d58bd16fc5e3bf080f0e63ec66e373f85..dbb17b0fe90fbb7a8792091335515bc0e7c5a3db 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: ViSEAGO -Version: 1.3.6 +Version: 1.3.7 Title: ViSEAGO: a Bioconductor package for clustering biological functions using Gene Ontology and semantic similarity Author: Aurelien Brionne [aut, cre], Amelie Juanchich [aut], diff --git a/NEWS b/NEWS index 4f5f07d374895eac98ab9c5de6a8c5e00ad5c951..c13d218427eed8a98f631ddf3ef79539ff12342f 100644 --- a/NEWS +++ b/NEWS @@ -72,4 +72,5 @@ CHANGES IN VERSION 1.3 o show_heatmap() upgrade o upset print update o merge_enrich_terms upgrade pvalue cutoff + o merge_enrich_terms globale upgrade diff --git a/R/merge_enrich_terms.R b/R/merge_enrich_terms.R index 27e29f6eccd7ee19800e774aea9838f377d79ebb..0c06c275d9e43c382d0acb77e42a37a9b4b15f6c 100644 --- a/R/merge_enrich_terms.R +++ b/R/merge_enrich_terms.R @@ -151,7 +151,7 @@ setMethod( unlist( lapply(seq_along(Input),function(x){ - # extract quering objects names + # extract quering objects names x=Input[[x]] # check existence @@ -160,7 +160,7 @@ setMethod( # check if available available<-x%in%values - # stop if not + # stop if not found if(!all(available)){ stop(paste("objects not found:",paste(x[!available],collapse=", "),sep="\n")) } @@ -193,7 +193,7 @@ setMethod( # check ontology if(length(check.onto)>1){ - # stop if more than one godata by list + # stop if more than one topGOdata by list stop("Only one ontology supported") } @@ -312,34 +312,25 @@ setMethod( } # objects type - if(sum(obj.type%in%"topGOresult")<1){ + if(sum(obj.type%in%"topGOresult")>1){ # stop if more than one godata by list - stop("At least one topGOresult object needed by list") + stop("Only one topGOresult object is supported by list") } ## find and extract pvalues - # load GOdata + # find topGOresult pos=which(obj.type=="topGOresult") - # tested algorithm - algorithms<-Data[pos] - - # extract significant pvalues results - unlist( - lapply(algorithms,function(y){ - - # extract scores - pvalues<-topGO::score(y) - - # extract names of enrich terms - as.vector( - names( - pvalues[pvalues<as.numeric(sub("^.+[[:space:]]","",slot(y,"testName")))] - ) - ) - }) + # extract scores + pvalues<-topGO::score(Data[[pos]]) + + # extract names of enrich terms + as.vector( + names( + pvalues[pvalues<as.numeric(sub("^.+[[:space:]]","",slot(Data[[pos]],"testName")))] + ) ) }) @@ -400,7 +391,7 @@ setMethod( GOdata=Data[[pos]] # tested algorithm - algorithms<-Data[-pos] + algorithm<-Data[-pos] ## extract some statistics from initial GOdata object (before enrichment test) @@ -680,47 +671,21 @@ setMethod( ## extract pvalue according the algorithm results - # extract pvalues results - pvalues<-lapply(seq_along(algorithms),function(y){ - - # extract all pvalues from topGOresult - pvalue<-topGO::score(algorithms[[y]]) - - # select pvalues from topGOresult - pvalue<-pvalue[GOs] - - # extract pvalue in data.table - pvalue<-data.table( - GO.ID=names(pvalue), - pvalue=as.numeric(format(pvalue,scientific = T)), - round(-log10(pvalue),digits=2) - ) - - # ordering pvalue by go term - names(pvalue)[ncol(pvalue)]="-log10_pvalue" - - if(y>1){ - - # remove GO.ID - pvalue[,"GO.ID":=NULL] - } - - # return - pvalue - }) - - # convert to data.table - pvalues=data.table(do.call("cbind",pvalues)) - - # algoritms - algo=vapply(algorithms,function(x){slot(x,"algorithm")},"") - - # if use of different algorithms - if(length(algo)>1){ + # extract all pvalues from topGOresult + pvalue<-topGO::score(algorithm[[1]]) + + # select pvalues from topGOresult + pvalue<-pvalue[GOs] + + # extract pvalue in data.table + pvalues<-data.table( + GO.ID=names(pvalue), + pvalue=as.numeric(format(pvalue,scientific = T)), + `-log10_pvalue`=round(-log10(pvalue),digits=2) + ) - # add names - names(pvalues)[-1]<-paste(rep(algo,each=2),names(pvalues)[-1],sep=".") - } + # algorithm + algo=slot(algorithm[[1]],"algorithm") # return input params assign( @@ -756,29 +721,19 @@ setMethod( Results<-Results[!is.na(Results$GO.ID)] # extract pvalue threshold - p<-unique(vapply(algorithms,function(x){ as.numeric(sub("^.+[[:space:]]","",slot(x,"testName")))},0)) - - # stop if more than one pvalue threshold among comparison - if(length(p)>1){stop("Only one pvalue theshold is allowed by list element.")} + 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)] if(!is.null(names(Input))){ - # add GOdata name - if(x==1){ - - # add GOdata name in the header - names(Results)[-1]<-paste(names(Input)[x], - names(Results)[-1],sep=".") - - }else{ - - # add GOdata name in the header - names(Results)[-1]<-paste(names(Input)[x], - names(Results)[-1],sep=".") - } + # add GOdata name in the header + names(Results)[-1]<-paste( + names(Input)[x], + names(Results)[-1], + sep="." + ) } # return Results diff --git a/README.md b/README.md index 5c35505414b87a0a434c7c79c08461f472fbe181..6c2ce311424e9ef4dda85af7aad1e074d5b7c8c7 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.6.tar.gz", repos = NULL, type = "source") + install.packages("ViSEAGO_1.3.7.tar.gz", repos = NULL, type = "source") ``` ## Citation diff --git a/vignettes/mouse_bionconductor.Rmd b/vignettes/mouse_bionconductor.Rmd index c9ff44ecc3a010b45ae8d33ad6f989b722e449c1..f72292131fe6614183adde2e2c9b34de3d35afde 100644 --- a/vignettes/mouse_bionconductor.Rmd +++ b/vignettes/mouse_bionconductor.Rmd @@ -174,7 +174,7 @@ BP_VirginvsPregnant<-ViSEAGO::create_topGOdata( ) ``` -Now, we perform the GO enrichment tests for BP category with Fisher's exact test and *elim* algorithm using `topGO::runTest` method. +Now, we perform the GO enrichment tests for BP category with Fisher's exact test and *elim* algorithm using `topGO::runTest` method. <u>NB</u>: p-values of enriched GO terms are not adjusted and considered significant if below 0.01. @@ -209,8 +209,7 @@ The printed table contains for each enriched GO terms, additional columns includ ```{r Enrichment_merge} # merge topGO results -ViSEAGO:: -BP_sResults<-merge_enrich_terms( +BP_sResults<-ViSEAGO::merge_enrich_terms( Input=list( PregnantvsLactate=c( "BP_PregnantvsLactate",