-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcorrected_data_analysis.R
More file actions
82 lines (68 loc) · 1.89 KB
/
corrected_data_analysis.R
File metadata and controls
82 lines (68 loc) · 1.89 KB
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
metadata <- read.csv("sample_metadata.csv", header = TRUE)
compound_rt_database <-
read.csv("compound_rt_database.csv", header = TRUE)
maven_data <-
read.csv("Maven_corrected_for_analysis.csv", header = TRUE)
library(dplyr)
library(ggplot2)
library(ggbiplot)
library(tidyr)
library(reshape2)
pool_total <- maven_data %>% select(-c(note)) %>%
group_by(compound) %>% summarize_all(funs(sum))
metadata$Sample <- paste0("X", metadata$Sample)
df2 <- maven_data %>%
group_by(compound, note)
df3 <- melt(df2, id = c("compound", "note"))
names(df3)[names(df3) == "variable"] <- "Sample"
df4 <- full_join(df3, metadata)
df5 <- pool_total %>% ungroup() %>%
group_by(compound)
df6 <- melt(df5, id = c("compound"))
names(df6)[names(df6) == "variable"] <- "Sample"
names(df6)[names(df6) == "value"] <- "Total"
df7 <- full_join(df6, metadata)
fraction_enrichment <- full_join(df4, df7)
fraction_enrichment <-
fraction_enrichment %>% mutate("fraction_enrich" = (value / Total) * 100)
totalgraph <- ggplot(
fraction_enrichment,
aes(
x = Time..mins.,
y = Total,
group = interaction(compound, Phenotype),
color = Phenotype
)
) +
geom_line() +
labs(title = "Pool Total",
x = "Time Points (in mins)",
y = "Metabolite Levels") +
facet_wrap(. ~ compound)
print(totalgraph)
dev.copy(pdf,
file = "correctedtotalgraph.pdf",
width = 5,
height = 5)
dev.off ()
fractiongraph <- ggplot(
fraction_enrichment,
aes(
x = Time..mins.,
y = fraction_enrich,
group = interaction(note, Phenotype),
color = note
)
) +
geom_line() +
labs(title = "Fraction Enrichment",
x = "Time Points (in mins)",
y = "Fraction Enrichment") +
theme(legend.position = "bottom") +
facet_wrap(. ~ compound + Phenotype)
print(fractiongraph)
dev.copy(pdf,
file = "correctedfractiongraph.pdf",
width = 8,
height = 8)
dev.off ()