-
Notifications
You must be signed in to change notification settings - Fork 133
/
GO_in_R.Rmd
83 lines (55 loc) · 1.41 KB
/
GO_in_R.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
---
title: "R Notebook"
output: html_notebook
---
```{r}
library(DESeq2)
Counts <- read.delim("../count_table.csv", header = TRUE, row.names = 1, sep = ",")
Counts <- Counts[which(rowSums(Counts) > 0),]
condition <- factor(c("C","C","C","C", "S","S","S","S"))
coldata <- data.frame(row.names = colnames(Counts), condition)
dds <- DESeqDataSetFromMatrix(countData = Counts, colData = coldata, design = ~condition)
dds <- DESeq(dds)
res <- results(dds, contrast = c("condition", "S", "C"))
sigs <- na.omit(res)
sigs <- sigs[sigs$padj < 0.05 & sigs$baseMean > 50,]
```
```{r}
sigs
```
```{r}
if (!require("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install("clusterProfiler")
if (!require("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install("AnnotationDbi")
if (!require("BiocManager", quietly = TRUE))
install.packages("BiocManager")
BiocManager::install("org.Hs.eg.db")
```
```{r}
library(clusterProfiler)
library(org.Hs.eg.db)
library(AnnotationDbi)
```
```{r}
genes_to_test <- rownames(sigs[sigs$log2FoldChange > 0.5,])
```
```{r}
GO_results <- enrichGO(gene = genes_to_test, OrgDb = "org.Hs.eg.db", keyType = "ENSEMBL", ont = "BP")
```
```{r}
as.data.frame(GO_results)
```
```{r}
fit <- plot(barplot(GO_results, showCategory = 15))
png("out.png", res = 250, width = 1400, height = 1800)
print(fit)
dev.off()
fit
```
```{r}
```
```{r}
```