11main_dir <- dirname(rstudioapi :: getSourceEditorContext()$ path )
22setwd(main_dir )
33
4- if (! require(" pacman" ))
4+ if (! require(" pacman" )) {
55 install.packages(" pacman" )
6+ }
67
78pacman :: p_load(tidyverse , reshape2 , patchwork , ggtext , ggVennDiagram )
89
9- df_bar_plot <- read.csv(" ABRicate_results/summary/tsv/merged_summary.tsv" , sep = " \t " ) %> %
10+ df_bar_plot <- read.csv(
11+ " ABRicate_results/summary/tsv/merged_summary.tsv" ,
12+ sep = " \t "
13+ ) %> %
1014 filter(SAMPLE != " D4" ) %> %
1115 mutate(
1216 SAMPLE = str_replace(SAMPLE , " D1" , " VM1" ),
@@ -35,9 +39,14 @@ barplot <- df_bar_plot_long %>%
3539 color = " gray"
3640 ) +
3741 geom_vline(
38- xintercept = seq(1.5 , length(unique(
39- df_bar_plot_long $ SAMPLE
40- )) - 0.5 , by = 1 ),
42+ xintercept = seq(
43+ 1.5 ,
44+ length(unique(
45+ df_bar_plot_long $ SAMPLE
46+ )) -
47+ 0.5 ,
48+ by = 1
49+ ),
4150 linetype = " dashed" ,
4251 color = " black"
4352 ) +
@@ -54,8 +63,10 @@ barplot <- df_bar_plot_long %>%
5463 labels = c(" CARD" , " ResFinder" , " VFDB" ),
5564 values = c(" #8DA0CB" , ' #FC8D62' , " #66C2A5" )
5665 ) +
57- theme(legend.title = element_text(size = 14 ),
58- legend.text = element_text(size = 14 )) +
66+ theme(
67+ legend.title = element_text(size = 14 ),
68+ legend.text = element_text(size = 14 )
69+ ) +
5970 geom_text(
6071 aes(label = number ),
6172 position = position_dodge(width = 0.9 ),
@@ -114,14 +125,17 @@ df_card_long <- melt(
114125) %> %
115126 filter(ARG != " NUM FOUND" )
116127
117- heatmap_card <- ggplot(df_card_long , aes(x = SAMPLE , y = ARG , fill = presence )) +
118- geom_tile(color = " black" ,
119- linewidth = 0.25 ,
120- show.legend = FALSE ) +
121- scale_fill_manual(# name = "ARG presence",
128+ heatmap_card <- ggplot(
129+ df_card_long ,
130+ aes(x = SAMPLE , y = ARG , fill = presence )
131+ ) +
132+ geom_tile(color = " black" , linewidth = 0.25 , show.legend = FALSE ) +
133+ scale_fill_manual(
134+ # name = "ARG presence",
122135 breaks = c(" plus" , " minus" ),
123136 # labels = c("Present", "Absent"),
124- values = c(" #8DA0CB" , " white" )) +
137+ values = c(" #8DA0CB" , " white" )
138+ ) +
125139 theme_classic() +
126140 labs(x = NULL , y = NULL ) +
127141 theme(axis.line = element_blank(), axis.text = element_markdown())
@@ -170,14 +184,17 @@ df_resfinder_long <- melt(
170184df_resfinder_long <- df_resfinder_long %> %
171185 mutate(ARG = word(ARG , 1 ))
172186
173- heatmap_resfinder <- ggplot(df_resfinder_long , aes(x = SAMPLE , y = ARG , fill = presence )) +
174- geom_tile(color = " black" ,
175- linewidth = 0.25 ,
176- show.legend = FALSE ) +
177- scale_fill_manual(# name = "ARG presence",
187+ heatmap_resfinder <- ggplot(
188+ df_resfinder_long ,
189+ aes(x = SAMPLE , y = ARG , fill = presence )
190+ ) +
191+ geom_tile(color = " black" , linewidth = 0.25 , show.legend = FALSE ) +
192+ scale_fill_manual(
193+ # name = "ARG presence",
178194 breaks = c(" plus" , " minus" ),
179195 # labels = c("Present", "Absent"),
180- values = c(" #FC8D62" , " white" )) +
196+ values = c(" #FC8D62" , " white" )
197+ ) +
181198 theme_classic() +
182199 labs(x = NULL , y = NULL ) +
183200 theme(axis.line = element_blank(), axis.text = element_markdown())
@@ -232,8 +249,18 @@ n_col_part3 <- 104
232249
233250# Split the dataframe into three parts
234251df_vfdb_part1 <- cbind(SAMPLE , df_vfdb_no_sample [, 1 : n_col_part1 ])
235- df_vfdb_part2 <- cbind(SAMPLE , df_vfdb_no_sample [, (n_col_part1 + 1 ): (n_col_part1 + n_col_part2 )])
236- df_vfdb_part3 <- cbind(SAMPLE , df_vfdb_no_sample [, (n_col_part1 + n_col_part2 + 1 ): (n_col_part1 + n_col_part2 + n_col_part3 )])
252+
253+ df_vfdb_part2 <- cbind(
254+ SAMPLE ,
255+ df_vfdb_no_sample [, (n_col_part1 + 1 ): (n_col_part1 + n_col_part2 )]
256+ )
257+
258+ df_vfdb_part3 <- cbind(
259+ SAMPLE ,
260+ df_vfdb_no_sample [,
261+ (n_col_part1 + n_col_part2 + 1 ): (n_col_part1 + n_col_part2 + n_col_part3 )
262+ ]
263+ )
237264
238265# VFDB: PART 1 #
239266
@@ -244,14 +271,17 @@ df_vfdb_part1_long <- melt(
244271 value.name = " presence"
245272)
246273
247- heatmap_vfdb_part1 <- ggplot(df_vfdb_part1_long , aes(x = SAMPLE , y = ARG , fill = presence )) +
248- geom_tile(color = " black" ,
249- linewidth = 0.25 ,
250- show.legend = FALSE ) +
251- scale_fill_manual(# name = "ARG presence",
274+ heatmap_vfdb_part1 <- ggplot(
275+ df_vfdb_part1_long ,
276+ aes(x = SAMPLE , y = ARG , fill = presence )
277+ ) +
278+ geom_tile(color = " black" , linewidth = 0.25 , show.legend = FALSE ) +
279+ scale_fill_manual(
280+ # name = "ARG presence",
252281 breaks = c(" plus" , " minus" ),
253282 # labels = c("Present", "Absent"),
254- values = c(" #66C2A5" , " white" )) +
283+ values = c(" #66C2A5" , " white" )
284+ ) +
255285 theme_classic() +
256286 labs(x = NULL , y = NULL ) +
257287 theme(axis.line = element_blank(), axis.text = element_markdown())
@@ -266,14 +296,17 @@ df_vfdb_part2_long <- melt(
266296 value.name = " presence"
267297)
268298
269- heatmap_vfdb_part2 <- ggplot(df_vfdb_part2_long , aes(x = SAMPLE , y = ARG , fill = presence )) +
270- geom_tile(color = " black" ,
271- linewidth = 0.25 ,
272- show.legend = FALSE ) +
273- scale_fill_manual(# name = "ARG presence",
299+ heatmap_vfdb_part2 <- ggplot(
300+ df_vfdb_part2_long ,
301+ aes(x = SAMPLE , y = ARG , fill = presence )
302+ ) +
303+ geom_tile(color = " black" , linewidth = 0.25 , show.legend = FALSE ) +
304+ scale_fill_manual(
305+ # name = "ARG presence",
274306 breaks = c(" plus" , " minus" ),
275307 # labels = c("Present", "Absent"),
276- values = c(" #66C2A5" , " white" )) +
308+ values = c(" #66C2A5" , " white" )
309+ ) +
277310 theme_classic() +
278311 labs(x = NULL , y = NULL ) +
279312 theme(axis.line = element_blank(), axis.text = element_markdown())
@@ -288,22 +321,27 @@ df_vfdb_part3_long <- melt(
288321 value.name = " presence"
289322)
290323
291- heatmap_vfdb_part3 <- ggplot(df_vfdb_part3_long , aes(x = SAMPLE , y = ARG , fill = presence )) +
292- geom_tile(color = " black" ,
293- linewidth = 0.25 ,
294- show.legend = FALSE ) +
295- scale_fill_manual(# name = "ARG presence",
324+ heatmap_vfdb_part3 <- ggplot(
325+ df_vfdb_part3_long ,
326+ aes(x = SAMPLE , y = ARG , fill = presence )
327+ ) +
328+ geom_tile(color = " black" , linewidth = 0.25 , show.legend = FALSE ) +
329+ scale_fill_manual(
330+ # name = "ARG presence",
296331 breaks = c(" plus" , " minus" ),
297332 # labels = c("Present", "Absent"),
298- values = c(" #66C2A5" , " white" )) +
333+ values = c(" #66C2A5" , " white" )
334+ ) +
299335 theme_classic() +
300336 labs(x = NULL , y = NULL ) +
301337 theme(axis.line = element_blank(), axis.text = element_markdown())
302338# axis.text.x = element_text(size=18, angle=35, hjust=1)
303339
304340# VFDB: ALLTOGETHER #
305341
306- VFDB_combined <- heatmap_vfdb_part1 + heatmap_vfdb_part2 + heatmap_vfdb_part3 &
342+ VFDB_combined <- heatmap_vfdb_part1 +
343+ heatmap_vfdb_part2 +
344+ heatmap_vfdb_part3 &
307345 plot_annotation(tag_levels = list (c(" A" , " B" , " C" )))
308346
309347ggsave(
@@ -388,7 +426,8 @@ ggsave(
388426resfinder_venn <- (heatmap_resfinder / venn_diag ) +
389427 plot_layout(heights = c(11 , 3 ))
390428
391- wombo_ultra <- (free(barplot , type = " label" ) / (heatmap_card + resfinder_venn )) +
429+ wombo_ultra <- (free(barplot , type = " label" ) /
430+ (heatmap_card + resfinder_venn )) +
392431 plot_layout(heights = c(3 , 14 ))
393432
394433wombo_ultra_combo <- (wombo_ultra | VFDB_combined ) +
0 commit comments