-
Notifications
You must be signed in to change notification settings - Fork 2
/
GSEA.Rmd
79 lines (56 loc) · 1.65 KB
/
GSEA.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
---
title: "GSEA"
output:
html_document:
code_folding: hide
---
```{r setup, include=FALSE}
library(msigdbr)
library(fgsea)
#library(multiGSEA)
library(EGSEA)
knitr::opts_chunk$set(echo = TRUE)
source('functions.R')
library(kableExtra)
library(stringr)
library(dplyr)
library(ggpubr)
knitr::opts_chunk$set(cache=TRUE, warning=FALSE, message=FALSE)
```
```{r yaml, echo=TRUE,warning=FALSE,message=FALSE,error=FALSE, include=FALSE}
params <- read_yaml("config.yml")
if(params$kallisto){
design_files <- list.files(path="designs_kallisto/", pattern = "design_")}else{
design_files <- list.files(path='designs_featurecounts/', pattern = "design_")
}
```
# GSEA rank list
```{r}
for (i in design_files){
res_name <- sub('.csv', '', i, perl = TRUE)
res_name = paste("results/", res_name,"_annotate_res.csv", sep="")
if(file.exists(res_name)){
results_annotated = read.csv(res_name)
dir.create("results_rnk/", showWarnings = FALSE)
results_dir = paste("results_rnk/", i,".rnk", sep="")
gsea_rnk(results_annotated=results_annotated, results_dir=results_dir)
}
}
```
# GSEA run
```{r}
for (i in design_files){
pathways <- "Hallmark"
title = gsub(".csv","",i)
res_name <- sub('.csv', '', i, perl = TRUE)
res_name = paste("results/", res_name,"_annotate_res.csv", sep="")
dir.create("results_gsea/", showWarnings = FALSE)
skip_to_next <- FALSE
# Note that print(b) fails since b doesn't exist
if(file.exists(res_name)){
print(i)
results_dir = read.csv(res_name)
tryCatch(print(GSEA_plots(pathways, title, results_dir)), error = function(e) { skip_to_next <<- TRUE})}
if(skip_to_next) { next }
}
```