-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdebug.Rmd
123 lines (93 loc) · 2.87 KB
/
debug.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
---
title: "debug"
author: "Yifan Duan"
date: "2024-10-03"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r}
BiocManager::install("clusterProfiler")
BiocManager::install("pathview")
BiocManager::install("enrichplot")
library(clusterProfiler)
library(enrichplot)
# we use ggplot2 to add x axis labels (ex: ridgeplot)
library(ggplot2)
```
```{r}
Idents(filtered_mature_neuron_obj) <- "Time.Point"
table(filtered_mature_neuron_obj$Time.Point)
naive_5_markers_dpi <- FindMarkers(filtered_mature_neuron_obj,
ident.1 = "Naive",
ident.2 = "5 dpi",
slot = "data",
min.pct = 0,
logfc.threshold = 0)
library(EnhancedVolcano)
pdf("DE_5dpi_naive.pdf")
EnhancedVolcano(naive_5_markers_dpi,
rownames(naive_5_markers_dpi),
x ="avg_log2FC",
y ="p_val_adj")
dev.off()
naive_5_markers_dpi |> filter(abs(avg_log2FC) > 2 & p_val_adj < 0.01)
```
```{r}
# SET THE DESIRED ORGANISM HERE
organism = "org.Mm.eg.db"
BiocManager::install(organism, character.only = TRUE)
library(organism, character.only = TRUE)
```
```{r}
# reading in data from deseq2
df <- naive_5_markers_dpi
# we want the log2 fold change
original_gene_list <- df$avg_log2FC
# name the vector
names(original_gene_list) <- rownames(df)
# omit any NA values
gene_list<-na.omit(original_gene_list)
# sort the list in decreasing order (required for clusterProfiler)
gene_list = sort(gene_list, decreasing = TRUE)
```
```{r}
keytypes(org.Mm.eg.db)
gse <- gseGO(geneList=gene_list,
ont ="ALL",
keyType = "SYMBOL",
minGSSize = 10,
maxGSSize = 500,
pvalueCutoff = 0.01,
pAdjustMethod = "BH",
verbose = TRUE,
OrgDb = organism)
dotplot(gse, showCategory = 10, title = "GSEA")
head(gse@result)
head(gse@result$NES)
```
```{r}
df <- naive_5_markers_dpi |> filter(abs(avg_log2FC) > 2 & p_val_adj < 0.01)
# we want the log2 fold change
original_gene_list <- df$avg_log2FC
# name the vector
names(original_gene_list) <- rownames(df)
# omit any NA values
gene_list <- na.omit(original_gene_list)
# sort the list in decreasing order (required for clusterProfiler)
gene_list = sort(gene_list, decreasing = TRUE)
go_enrich <- enrichGO(gene = names(gene_list),
OrgDb = organism,
keyType = 'SYMBOL',
readable = T,
ont = "ALL",
pvalueCutoff = 0.05,
qvalueCutoff = 0.1)
barplot(go_enrich,
drop = TRUE,
showCategory = 10,
title = "GO analysis",
font.size = 8)
DoHeatmap(filtered_mature_neuron_obj, features = rownames(df))
```