-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathspectra.R
89 lines (80 loc) · 4.05 KB
/
spectra.R
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
library(ggplot2)
library(cowplot)
library(scales)
# Load input
load(file.path("input.RData"))
input_df$Methods <- gsub(":", "\n", input_df$Methods)
input_df$Methods <- factor(input_df$Methods, levels = unique(input_df$Methods))
cv_df <- input_df
cv_df$Mean <- ifelse(cv_df$LOD == 1, cv_df$Mean, 0)
# Plot liver samples without method 7b (Figure 3)
liver_temp <- filter(cv_df, Tissue == "Liver" & Method != "7b")
ggplot(liver_temp, aes(x = Metabolite, y = Mean, fill = Class)) +
geom_bar(stat = "identity") +
scale_fill_manual(values = col_vector) +
facet_wrap(~ Methods, ncol = 1, strip.position = "right") +
theme_bw() +
scale_y_log10(breaks = trans_breaks("log10", function(x) 10^x),
labels = trans_format("log10", math_format(10^.x))) +
ylab("Mean Concentration [pmol/mg]") +
theme(axis.text.x = element_blank(), axis.ticks.length.x = unit(0, "cm"),
panel.grid.major= element_line(color = "white"),
panel.grid.minor.y = element_blank(),
strip.text.y = element_text(angle = 270, size = 6))
# Plot HEK samples
hek_temp <- filter(cv_df, Tissue == "HEK")
ggplot(hek_temp, aes(x = Metabolite, y = Mean, fill = Class)) +
geom_bar(stat = "identity") +
scale_fill_manual(values = col_vector) +
facet_wrap(~ Methods, ncol = 1, strip.position = "right") +
theme_bw() +
scale_y_log10(breaks = trans_breaks("log10", function(x) 10^x),
labels = trans_format("log10", math_format(10^.x))) +
ylab(expression(paste("Mean Concentration [pmol/", 10^6, " cells]"))) +
theme(axis.text.x = element_blank(), axis.ticks.length.x = unit(0, "cm"),
panel.grid.major= element_line(color = "white"),
panel.grid.minor.y = element_blank(),
strip.text.y = element_text(angle = 270, size = 6))
# Plot HL60 samples
hl_temp <- filter(cv_df, Tissue == "HL60")
ggplot(hl_temp, aes(x = Metabolite, y = Mean, fill = Class)) +
geom_bar(stat = "identity") +
scale_fill_manual(values = col_vector) +
facet_wrap(~ Methods, ncol = 1, strip.position = "right") +
theme_bw() +
scale_y_log10(breaks = trans_breaks("log10", function(x) 10^x),
labels = trans_format("log10", math_format(10^.x))) +
ylab(expression(paste("Mean Concentration [pmol/", 10^6, " cells]"))) +
theme(axis.text.x = element_blank(), axis.ticks.length.x = unit(0, "cm"),
panel.grid.major= element_line(color = "white"),
panel.grid.minor.y = element_blank(),
strip.text.y = element_text(angle = 270, size = 6))
# Plot bone marrow samples
bm_temp <- filter(cv_df, Tissue == "Bone Marrow")
ggplot(bm_temp, aes(x = Metabolite, y = Mean, fill = Class)) +
geom_bar(stat = "identity") +
scale_fill_manual(values = col_vector) +
facet_wrap(~ Methods, ncol = 1, strip.position = "right") +
theme_bw() +
scale_y_log10(breaks = trans_breaks("log10", function(x) 10^x),
labels = trans_format("log10", math_format(10^.x))) +
ylab(expression(paste("Mean Concentration [pmol/", 10^6, " cells]"))) +
theme(axis.text.x = element_blank(), axis.ticks.length.x = unit(0, "cm"),
panel.grid.major= element_line(color = "white"),
panel.grid.minor.y = element_blank(),
strip.text.y = element_text(angle = 270, size = 6))
# Plot method 7b across all tissues
method_temp <- filter(cv_df, Method == "7b")
method_temp$Tissue <- factor(method_temp$Tissue, levels = c("Liver", "Bone Marrow", "HEK", "HL60"))
ggplot(method_temp, aes(x = Metabolite, y = Mean, fill = Class)) +
geom_bar(stat = "identity") +
scale_fill_manual(values = col_vector) +
facet_wrap(~ Tissue, ncol = 1, strip.position = "top") +
theme_bw() +
scale_y_log10(breaks = trans_breaks("log10", function(x) 10^x),
labels = trans_format("log10", math_format(10^.x))) +
ylab(expression(paste("Mean Concentration [pmol/mg] or [pmol/", 10^6, " cells]"))) +
theme(axis.text.x = element_blank(), axis.ticks.length.x = unit(0, "cm"),
panel.grid.major= element_line(color = "white"),
panel.grid.minor.y = element_blank(),
strip.text.y = element_text(angle = 360, size = 6), legend.position = "none")