Commit 4b0d1ac6 authored by Marek Ostaszewski's avatar Marek Ostaszewski
Browse files

Correction for the case of enpty enrichment results.

parent fc0d38d0
......@@ -112,14 +112,18 @@ library(enrichR)
message("Enrichment of pathways")
### Header of the enrichment table, it's consecutive segments will be written
### later below
cat(file = "enriched_pathways.txt",
"pathway_db\tTerm\tAdjusted.P.value\n",
append = F)
pathway_dbs <- config[config$type == "pathway_db","resource"]
### Run Enrichr
enriched_pathways <- enrichr(input, databases = pathway_dbs)
### Leave only the pathways with adjusted p lower than 0.1
adj_pathways <- lapply(enriched_pathways,
function(x) {
selected <- which(x$Adjusted.P.value < 0.1)
......@@ -129,8 +133,12 @@ adj_pathways <- lapply(enriched_pathways,
x[selected, ]
})
for(aep in 1:length(adj_pathways)) {
write.table(cbind(pathway_db = pathway_dbs[aep],
### Clean empty results
adj_pathways <- adj_pathways[sapply(adj_pathways, dim)[1,] > 0]
### Write results down in the file
for(aep in names(adj_pathways)) {
write.table(cbind(pathway_db = aep,
adj_pathways[[aep]][,c("Term","Adjusted.P.value")],
stringsAsFactors = F),
file = "enriched_pathways.txt", sep = "\t", quote = F, col.names = F, row.names = F, append = T)
......
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