Browse code

Only add the ancestor GO terms that exist in current annotation, not all the ancestor GO terms.

Ge Tan authored on 22/04/2017 09:43:23
Showing 1 changed files

  • R/GO.R index c76db45..d4d8bc1 100644
... ...
@@ -138,9 +138,10 @@ addAncestorGO <- function(go){
138 138
   }
139 139
   goID2Ancestor <- c(as.list(GOBPANCESTOR), as.list(GOMFANCESTOR), 
140 140
                      as.list(GOCCANCESTOR))
141
-  newGo <- lapply(relist(lapply(mapply(append, unlist(go), 
142
-                                       goID2Ancestor[unlist(go)]), 
143
-                                function(x){x[x!="all"]}), go), unlist)
141
+  allGo <- unlist(go)
142
+  goID2Ancestor <- lapply(goID2Ancestor, function(x){x[x%in%allGo]})
143
+  newGo <- lapply(relist(mapply(append, allGo, goID2Ancestor[allGo]), go),
144
+                  unlist)
144 145
   newGo <- lapply(newGo, function(x){if(is.null(x)){character(0)}else{x}})
145 146
   return(newGo)
146 147
 }