Commit 19d31786 authored by Holger Brandl's avatar Holger Brandl

simplified level assignment

parent 9c31a387
......@@ -164,10 +164,15 @@ getlevels <- function(x){
}
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))
levdataDF = str_match(names(levdata), "_([0-9]*)$")[,2] %>%
{ data_frame(level=as.integer(.), term=levdata) } %>% unnest() %>%
group_by(term) %>% slice(which.min(level)) %>%
rename(min_level=level, ID=term)
enrResults %<>% left_join(levdata, by = "ID")
enrResults[is.na(enrResults)] <- "-"
enrResults %<>% left_join(levdataDF, by = "ID")
# enrResults[is.na(enrResults)] <- "-"
# enrResults %<>% mutate_at(vars(min_level), replaceNA, "-")
# enrResults$min_level %<>% replaceNA("-")
......@@ -189,7 +194,7 @@ enrResults[is.na(enrResults)] <- "-"
# enrResults %<>% select(- geneID)
write_tsv(enrResults, path = paste0(resultsBaseName, "enrResults.txt"))
# enrResults <- read.delim(paste0(resultsBaseName, "enrResults.txt"))
# enrResults <- read_tsv(paste0(resultsBaseName, "enrResults.txt"))
#' [Enrichment Results](`r paste0(resultsBaseName, "enrResults.txt")`)
load_pack(DT)
......@@ -291,7 +296,7 @@ erPlotData %<>% mutate(fixed_width_term = str_sub(Term, 1, 70) %>% str_pad(70))
erPlotData %<>% mutate(gene_ratio = map_dbl(GeneRatio, ~ eval(parse(text = .x))))
term_barplot_files = erPlotData %>% do({
# DEBUG enrResultsGrp <- erPlotData %>% head(30)
# DEBUG enrResultsGrp <- erPlotData %>% first_group()
enrResultsGrp <- .
label = subset(enrResultsGrp, select = group_col)[1, 1] %>%
......
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