-
Notifications
You must be signed in to change notification settings - Fork 0
/
codes_for_plotting_in_r.txt
69 lines (55 loc) · 2.4 KB
/
codes_for_plotting_in_r.txt
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
#######################################################################################
# Codes for plotting in R
library(ggplot2)
#### Part 1: GO term Biological process ####
# Set working directory for GO term Biological process
setwd("YOUR_PATH_HERE_GO_TERM")
# Load GO term Biological process data
go_dt <- read.csv("mRNA_TargetGene_GOBP02.csv", header=TRUE)
# Set levels for Groups factor
go_dt$Groups <- factor(go_dt$Groups, levels=c("3dpi", "7dpi", "21dpi"))
# Plotting GO term Biological process data
ggplot(go_dt, aes(Groups, KEGG_Pathways)) +
geom_point(aes(size=GeneNum, color=Qvalue)) +
theme_bw() +
scale_color_gradient(low="#66FF33", high="#CC3300") +
scale_size_continuous(range=c(1.5, 6)) +
labs(x="Groups", y="GO-BP Terms") +
theme(axis.text = element_text(color="black"),
axis.title = element_text(face="bold"),
legend.title = element_text(face="bold"),
plot.margin = unit(rep(0.5, 4), "cm")) +
scale_x_discrete(labels = c('3dpi', '7dpi', '21dpi'))
#### Part 2: KEGG Pathways ####
# Set working directory for KEGG
setwd("YOUR_PATH_HERE_KEGG")
# Load KEGG data
kegg_dt <- read.csv("miRNA_TargetGene_KEGG.csv", header=TRUE)
# Set levels for Groups factor
kegg_dt$Groups <- factor(kegg_dt$Groups, levels=c("3dpi", "7dpi", "21dpi"))
# Plotting KEGG data
ggplot(kegg_dt, aes(Groups, KEGG_Pathways)) +
geom_point(aes(size=GeneNum, color=Qvalue)) +
theme_bw() +
scale_color_gradient(low="#FF3333", high="#0000CC") +
scale_size_continuous(range=c(1.5, 6)) +
labs(x="Groups", y="KEGG Pathways") +
theme(axis.text = element_text(color="black"),
axis.title = element_text(face="bold"),
legend.title = element_text(face="bold"),
plot.margin = unit(rep(0.5, 4), "cm")) +
scale_x_discrete(labels = c('3dpi', '7dpi', '21dpi'))
#### Part 3: Volcano Plot ####
# Set working directory for Volcano plot
setwd("YOUR_PATH_HERE_VOLCANO")
# Load Volcano plot data
volcano_dt <- read.csv("21dpi.csv", header=TRUE, na.strings="#N/A")
# Plotting Volcano plot data
ggplot(volcano_dt, aes(x=Log2FC, y=-log10(Pvalue), colour=Trend)) +
geom_point(alpha=0.75, size=3.5, shape=16) +
scale_color_manual(values=c("#4393C3", "#d2dae2", "#D6604D")) +
xlim(-10, 10) + ylim(-1, 320) +
geom_vline(xintercept=c(-1, 1), lty=2, col="black", lwd=0.3) +
geom_hline(yintercept=-log10(0.05), lty=2, col="black", lwd=0.3) +
theme_bw() +
labs(x="Log2(FoldChange)", y="-Log10(Qvalue)")