-
Notifications
You must be signed in to change notification settings - Fork 1
/
script.R
59 lines (40 loc) · 1.49 KB
/
script.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
#download libraries
library(readxl)
library(DescTools)
library(ggplot2)
# data wrangling
# group by Target
new_df <- data[order(data$Target), ]
# sample the dataframe and create new column Group
sample_group_ <- data.frame(
sample_name = c("414", "415", "417", "418"),
group_name = "Control"
)
# new column with NA
new_df$Group <- NA
# loop through Sample and write corresponding Group to Sample
for (i in 1:nrow(sample_group)) {
new_df$Group[new_df$Sample %in% sample_group$sample_name[i]] <- sample_group$group_name[i]
}
# data reorder
data$Group <- factor(data$Group, levels = c("Control", "CD", "AKG", "CD + AKG"))
ggplot(data, aes(Target, Ct)) +
geom_violin(position = position_dodge(width = .7), width = 2, aes(fill = Group), outlier.colour = NA, draw_quantiles = c(0.25, 0.5, 0.75)) +
#geom_jitter(position = position_jitter(width = 1), alpha = 0.5) +
labs(y = "Relative expression", x = " ") +
ggtitle("qRT-PCR set 2. 2023-10-31") +
theme_bw() +
theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank())
# barplot
ggplot(data, aes(Target, Ct, fill = Group)) +
geom_bar(stat = "identity", position = "dodge") +
theme_bw() +
theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank())
# duncan test for all genes
genes <- unique(data$Target)
for (gene in genes) {
gene_df <- subset(data, Target == gene)
cM.aov <- aov(Ct ~ Group, data = gene_df)
print(gene)
print(PostHocTest(cM.aov, method = "duncan"))
}