Commit 00632614 authored by Lena Hersemann's avatar Lena Hersemann

added information on (min) GO levels to the enrResults data frame

parent 5eae0706
......@@ -134,6 +134,37 @@ glMapped %<>% filter(! is.na(entrez_gene_id))
enrResults <- quote(glMapped %>% do(cp_test(.$entrez_gene_id, annoDb, cp_species, q_cutoff = q_cutoff))) %>%
cache_it(paste0("enrdata_", digest(glMapped)))
# add information on GO levels:
library(clusterProfiler)
library(goProfiles)
getlevels <- function(x){
dbs <- x %>% filter(grepl("go_", ontology)) %>% mutate(GOs = str_replace(ontology, "go_", ""))
GOs <- unique(dbs$GOs)
GOs <- toupper(GOs)
#print(GOs)
listofGOs <- list()
for (db in GOs) {
ont = db
for (level in (1:50)) {
terms <- getGOLevel(ont, level) %>% as.vector()
level.name <- paste(ont, "level", level, sep="_")
listofGOs[[level.name]] <- terms
}
}
return(listofGOs)
}
levdata <- getlevels(enrResults)
levdata <- data.frame(level = rep(names(levdata), lapply(levdata, length), stringsAsFactors = FALSE), ID = unlist(levdata)) %>% mutate(rownames = NULL) %>% mutate(min_level = str_replace(level, "^*[A-Z]{2}_level_", "")) %>% select(-level) %>% arrange(ID) %>% group_by(ID) %>% slice(which.min(min_level))
enrResults %<>% left_join(levdata, by = "ID")
enrResults[is.na(enrResults)] <- "-"
## run the actual enrichment test for all clusters and all ontologies
#library(foreach); library(doMC); registerDoMC(cores=20)
## https://support.bioconductor.org/p/38541/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment