-
Notifications
You must be signed in to change notification settings - Fork 0
/
Fig5_plots.R
280 lines (255 loc) · 14.4 KB
/
Fig5_plots.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
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
library(ggplot2) #basic ggplot
library(ggpubr) #provides plots and some statistics
library(ggtext) #allows HTML-tags in text (element_markdown)
library(svglite) #for saving images in svg format
library(broom) #simplifies statistical data (tidy())
library(ggbeeswarm) #make symmetric datapoints distribution (geom_beeswarm)
setwd("/media/sf_Genomik-data/user_data/Zemlianski Viacheslav/Cut project/Manuscript/Fig5")
theme_set(theme_classic() + theme(text = element_text(family = "Arial")))
Fig5_data <- read.csv(file = "Fig5_data.csv", header = TRUE) %>% # loading raw data
mutate(sample = paste(genotype, treatment, sep = "_"),
sample = factor(sample, levels = c("WT_YES", "WT_YES_N",
"Dcbf11_YES", "Dcbf11_YES_N")),
genotype = factor(genotype, levels = c("WT","Dcbf11")),
treatment = factor(treatment, levels = c("YES","YES_N")),
phase = factor(phase, levels = c("A", "PM")))
################################################################################
#Fig5B, length of the whole mitosis
Fig5_data_PM <- Fig5_data[Fig5_data$phase == "PM",] # generating data subset
Fig5_data_A <- Fig5_data[Fig5_data$phase == "A",]
Fig5B_data <- Fig5_data_PM[,c("genotype","treatment","sample")] %>%
mutate(length = Fig5_data_PM$length + Fig5_data_A$length)
rm(Fig5_data_PM, Fig5_data_A)
# Fig5B_t_1 <- t.test(c(Fig5B_data$length[Fig5_data$sample == "WT_YES"]), #statistical tests
# y = c(Fig5B_data$length[Fig5_data$sample == "Dcbf11_YES"]),
# alternative = "less",
# var.equal = T)
# Fig5B_t_2 <- t.test(c(Fig5B_data$length[Fig5_data$sample == "Dcbf11_YES_N"]),
# y = c(Fig5B_data$length[Fig5_data$sample == "Dcbf11_YES"]),
# alternative = "less",
# var.equal = T)
# Fig5B_stats <- rbind(tidy(Fig5B_t_1), tidy(Fig5B_t_2)) %>%
# mutate(p.adj = p.adjust(p.value, method = "holm"))
# rm(Fig5B_t_1, Fig5B_t_2)
Fig5B_stats <- aov(length ~ sample, # statistical test
data = Fig5B_data) %>%
glht(mcp(sample = c("WT_YES - Dcbf11_YES >= 0",
"Dcbf11_YES_N - Dcbf11_YES >= 0"
))) %>%
tidy()
ggplot(data = Fig5_data, aes(x = sample, fill = phase, y = length)) + # plot initialization
geom_bar(stat="summary", fun = "mean", colour="black") + # adding bars
scale_fill_manual(values = c("gray90", "gray40"), # bar colors
labels = c("Anaphase", "Prophase + metaphase")) +
scale_x_discrete(labels = c("-","+","-","+")) + # x-axis labels
annotate(geom = "text", x = c(1.5, 3.5), y = -7.5,
label = c("WT", expression(italic("\u0394cbf11"))), size = 3) +
labs(tag = expression("NH"[4]*"Cl"), textsize = 9) +
geom_hline(yintercept = -5.5) +
geom_beeswarm(data = Fig5B_data, # adding datapoints
aes(x = sample, y = length, fill = NULL),
cex = 2,
alpha = 0.3,
key_glyph = draw_key_blank) +
ylab("Mitosis (P+M+A) length (min)") + # y-axis title
scale_y_continuous(expand=c(0, 0), limits=c(-10, 60), # y-axis scale and labels
breaks=c(0, 10, 20, 30, 40, 50, 60)) +
coord_cartesian(ylim = c(0, 60), expand = T, clip = "off") +
theme(axis.line = element_line(colour = "black", linewidth = 0.75), # axes design
axis.ticks.x = element_blank(),
axis.title.x = element_blank(),
axis.text.x = element_text(colour = "black", size = 9, vjust = 0),
plot.tag.position = c(0, 0),
plot.tag = element_text(size = 9, hjust = 0, vjust = 0.3),
axis.title.y = element_markdown(size = 9, colour = "black"),
axis.text.y = element_text(size = 9, colour = "black"),
axis.ticks.y = element_line(colour = "black", linewidth = 0.75),
legend.position = "top",
legend.title = element_blank(), # legend design
legend.text = element_text(size = 9, colour = "black"),
legend.key.height = unit(0.35, 'cm'),
legend.key.width = unit(0.35, 'cm'),
legend.background = element_blank(),
plot.margin=unit(c(0.2, 0.2, 0.7, 0.2), "cm") # plot margins
) +
geom_errorbar(data = aggregate(length~sample, # adding errorbars
data = Fig5B_data,
FUN = function(Fig5B_data)
c(AVG = mean(Fig5B_data, na.rm=T),
SD = sd(Fig5B_data, na.rm=T))),
aes(y = length[,"AVG"],
ymin = pmax(length[,"AVG"]-length[,"SD"], 0),
ymax = length[,"AVG"]+length[,"SD"],
fill = NULL),
width=0.3,
colour="black", linewidth=0.75
) +
geom_signif(xmin = c(1, 3), # adding statistics
xmax = c(3, 4),
y_position = c(59.5, 52),
annotations = ""
) +
geom_text(data = Fig5B_stats,
aes(x = c(2, 3.5),
y = c(59.5, 52),
vjust = -0.5,
fill = NULL,
label = paste0("p=", format(adj.p.value, scientific=T, digits=2))),
position = position_nudge(0, 0.4),
size = 9/.pt,
colour = symnum(Fig5B_stats$adj.p.value,
cutpoints = c(0, 0.05, Inf),
symbols = c("black", "gray"))
)
ggsave("Fig5B.png", width = 8, height = 10, units = "cm", dpi = 600) # saving the plot
ggsave("Fig5B.svg", width=8, height=10, units="cm", dpi=600, fix_text_size=F)
################################################################################
#Fig5C, prophase + metaphase length
Fig5C_data <- Fig5_data[Fig5_data$phase == "PM",] # generating data subset
Fig5C_stats <- aov(length ~ sample, # statistical tests
data = Fig5C_data) %>%
glht(mcp(sample = c("WT_YES - Dcbf11_YES >= 0",
"Dcbf11_YES_N - Dcbf11_YES >= 0"
))) %>%
tidy()
# Fig5C_t_1 <- t.test(c(Fig5C_data$length[Fig5C_data$sample == "WT_YES"]), #statistical tests
# y = c(Fig5C_data$length[Fig5C_data$sample == "Dcbf11_YES"]),
# alternative = "less",
# var.equal = T)
# Fig5C_t_2 <- t.test(c(Fig5C_data$length[Fig5C_data$sample == "Dcbf11_YES_N"]),
# y = c(Fig5C_data$length[Fig5C_data$sample == "Dcbf11_YES"]),
# alternative = "less",
# var.equal = T)
# Fig5C_stats <- rbind(tidy(Fig5C_t_1), tidy(Fig5C_t_2)) %>%
# mutate(p.adj = p.adjust(p.value, method = "holm"))
# rm(Fig5C_t_1, Fig5C_t_2)
ggplot(data = Fig5C_data, aes(x = genotype, fill = treatment, y = length)) + # plot initialization
stat_boxplot(geom ='errorbar', # adding boxes
position = position_dodge(0.8),
width = 0.3) +
geom_boxplot(position = position_dodge(0.8),
outlier.shape=NA,
key_glyph = draw_key_polygon,
colour="black", width = 0.7) +
geom_beeswarm(dodge.width = 0.8, # adding datapoints
cex = 1.7,
alpha = 0.3,
key_glyph = draw_key_blank) +
scale_fill_manual(values = c("white", "gray50"), # boxes colors and legend labels
labels = c("YES",
expression("YES+NH"[4]*"Cl"))) +
scale_x_discrete(labels = c("WT", "<i>\u0394cbf11</i>")) + # x-labels
scale_y_continuous(expand=c(0, 0), limits=c(5, 46.5), # y-axis scale and labels
breaks=c(5, 15, 25, 35, 45)) +
ylab("Prophase+metaphase length (min)") + # y-axis title
theme(plot.title = element_text(hjust = 0.5), # plot title formatting
panel.grid.major = element_blank(), # removing background
panel.grid.minor = element_blank(),
panel.background = element_blank(),
axis.line = element_line(colour = "black", linewidth = 0.75), # axes design
axis.ticks.x = element_blank(),
axis.title.x = element_blank(),
axis.text.x = element_markdown(size = 9, colour = "black"),
axis.title.y = element_markdown(size = 9, colour = "black"),
axis.text.y = element_text(size = 9, colour = "black"),
axis.ticks.y = element_line(colour = "black", linewidth = 0.75),
legend.position = c(0.2, 0.9), # legend design
legend.title = element_blank(),
legend.text = element_text(size = 9, colour = "black",
vjust = 0.5, hjust = 0),
legend.key.height = unit(0.35, 'cm'),
legend.key.width = unit(0.35, 'cm'),
legend.background = element_blank(),
plot.margin=unit(c(0.2, 0.2, 0, 0.2), "cm") # plot margins
) +
geom_signif(xmin = c(0.8, 1.8), # adding errorbars
xmax = c(1.8, 2.2),
y_position = c(36, 38),
annotations = ""
) +
geom_text(data = Fig5C_stats,
aes(x = c(1.3, 2),
y = c(36, 38),
vjust = -0.4,
fill = NULL,
label = paste0("p=", format(adj.p.value, scientific=F, digits=2))),
position = position_nudge(0, 0.4),
size = 9/.pt,
colour = symnum(Fig5C_stats$adj.p.value,
cutpoints = c(0, 0.05, Inf),
symbols = c("black", "gray"))
)
ggsave("Fig5C.png", width = 8, height = 8, units = "cm", dpi = 600) # saving the plot
ggsave("Fig5C.svg", width=8, height=8, units="cm", dpi=600, fix_text_size=F)
################################################################################
#Fig5D, anaphase length
Fig5D_data <- Fig5_data[Fig5_data$phase == "A",] # generating data subset
Fig5D_stats <- aov(length ~ sample, # statistical tests
data = Fig5D_data) %>%
glht(mcp(sample = c("WT_YES - Dcbf11_YES >= 0",
"Dcbf11_YES_N - Dcbf11_YES >= 0"
))) %>%
tidy()
# Fig5D_t_1 <- t.test(c(Fig5D_data$length[Fig5D_data$sample == "WT_YES"]), #statistical tests
# y = c(Fig5D_data$length[Fig5D_data$sample == "Dcbf11_YES"]),
# alternative = "less",
# var.equal = T)
# Fig5D_t_2 <- t.test(c(Fig5D_data$length[Fig5D_data$sample == "Dcbf11_YES_N"]),
# y = c(Fig5D_data$length[Fig5D_data$sample == "Dcbf11_YES"]),
# alternative = "less",
# var.equal = T)
# Fig5D_stats <- rbind(tidy(Fig5D_t_1), tidy(Fig5D_t_2)) %>%
# mutate(p.adj = p.adjust(p.value, method = "holm"))
# rm(Fig5D_t_1, Fig5D_t_2)
ggplot(data = Fig5D_data, aes(x = genotype, fill = treatment, y = length)) + # plot initialization
stat_boxplot(geom ='errorbar', # adding boxes
position = position_dodge(0.9),
width = 0.3) +
geom_boxplot(position = position_dodge(0.9),
outlier.shape=NA,
key_glyph = draw_key_polygon,
colour="black", width = 0.7) +
geom_beeswarm(dodge.width = 0.9, # adding datapoints
cex = 1.3,
alpha = 0.3,
key_glyph = draw_key_blank) +
scale_fill_manual(values = c("white", "gray50"), # boxes colors and legend labels
labels = c("YES",
expression("YES+NH"[4]*"Cl"))) +
scale_x_discrete(labels = c("WT", "<i>\u0394cbf11</i>")) + # x-labels
scale_y_continuous(expand=c(0, 0), limits=c(5, 35), # y-axis scale and labels
breaks=c(5, 10, 15, 20, 25, 30, 35)) +
ylab("Anaphase length (min)") + # y-axis title
theme(plot.title = element_text(hjust = 0.5), # plot title formatting
panel.grid.major = element_blank(), # removing background
panel.grid.minor = element_blank(),
panel.background = element_blank(),
axis.line = element_line(colour = "black", linewidth = 0.75), # axes design
axis.ticks.x = element_blank(),
axis.title.x = element_blank(),
axis.text.x = element_markdown(size = 9, colour = "black"),
axis.title.y = element_markdown(size = 9, colour = "black"),
axis.text.y = element_text(size = 9, colour = "black"),
axis.ticks.y = element_line(colour = "black", linewidth = 0.75),
legend.position = "none", # legend design
plot.margin=unit(c(0.2, 0.2, 0, 0.2), "cm") # plot margins
) +
geom_signif(xmin = c(0.77, 1.77), # adding errorbars
xmax = c(1.77, 2.27),
y_position = c(30, 25),
annotations = ""
) +
geom_text(data = Fig5D_stats,
aes(x = c(1.27, 2.03),
y = c(30, 25),
vjust = -0.3,
fill = NULL,
label = paste0("p=", format(adj.p.value, scientific=T, digits=2))),
position = position_nudge(0, 0.4),
size = 9/.pt,
colour = symnum(Fig5D_stats$adj.p.value,
cutpoints = c(0, 0.05, Inf),
symbols = c("black", "gray"))
)
ggsave("Fig5D.png", width = 8, height = 8, units = "cm", dpi = 600) # saving the plot
ggsave("Fig5D.svg", width=8, height=8, units="cm", dpi=600, fix_text_size=F)