Skip to content
Snippets Groups Projects
Commit 3edf5a1b authored by Simeon's avatar Simeon
Browse files

Revised top n genera figures for all markers

Revision request, reknitted as a result
parent cce9eee6
Branches
No related tags found
No related merge requests found
Showing
with 251 additions and 246 deletions
...@@ -817,9 +817,9 @@ set$ignore_na = TRUE ...@@ -817,9 +817,9 @@ set$ignore_na = TRUE
##### Optional settings (sensible defaults) ##### ##### Optional settings (sensible defaults) #####
# Can be changed to change the width (in cm) of the saved plot. # Can be changed to change the width (in cm) of the saved plot.
set$wp = 20 set$wp = 25
# Can be changed to change the height (in cm) of the saved plot. # Can be changed to change the height (in cm) of the saved plot.
set$hp = 13 set$hp = 15
# Can be changed to change the resolution (in dpi) of the saved plot. # Can be changed to change the resolution (in dpi) of the saved plot.
set$res = 300 set$res = 300
...@@ -843,7 +843,7 @@ set$ps.topnTax <- cuphyr::abundant_tax_physeq(ps.trans, lvl = set$taxlvl, ...@@ -843,7 +843,7 @@ set$ps.topnTax <- cuphyr::abundant_tax_physeq(ps.trans, lvl = set$taxlvl,
set$my_scale_fill <- my_scale_fill set$my_scale_fill <- my_scale_fill
set$topntax_tbl <- psmelt(set$ps.topnTax) %>% set$topntax_tb <- psmelt(set$ps.topnTax) %>%
as_tibble() %>% as_tibble() %>%
left_join(set$alpha_div_ps_trans, by = "Sample") %>% left_join(set$alpha_div_ps_trans, by = "Sample") %>%
select(Genus, Alias, ndvi, Abundance, Shannon) %>% select(Genus, Alias, ndvi, Abundance, Shannon) %>%
...@@ -853,35 +853,34 @@ set$topntax_tbl <- psmelt(set$ps.topnTax) %>% ...@@ -853,35 +853,34 @@ set$topntax_tbl <- psmelt(set$ps.topnTax) %>%
arrange(ndvi) %>% arrange(ndvi) %>%
mutate(ndvi_rank = c(1:length(ndvi))) mutate(ndvi_rank = c(1:length(ndvi)))
set$other <- set$topntax_tbl %>% set$other <- set$topntax_tb %>%
group_by(Alias) %>% group_by(Alias) %>%
summarise(sumabu = sum(Abundance)) %>% summarise(sumabu = sum(Abundance)) %>%
mutate(Genus = 'Other', Abundance = 1-sumabu) %>% mutate(Genus = 'Other', Abundance = 1-sumabu) %>%
select(-sumabu) select(-sumabu)
set$topntax_tbl <- bind_rows(set$topntax_tbl, set$other) set$topntax_tbl <- bind_rows(set$topntax_tb, set$other) %>%
mutate(Genus = factor(Genus, levels = c(
sort(unique(set$topntax_tb$Genus)),
"Other")
))
plots$topn_tax_custom <- ggplot(set$topntax_tbl, aes(x = fct_reorder(Alias, ndvi), plots$topn_tax_custom <- ggplot(set$topntax_tbl, aes(x = fct_reorder(Alias, ndvi),
y = Abundance, y = Abundance,
fill = Genus)) + fill = Genus)) +
#title = paste0("Top ", set$top_n, " ", set$taxlvl))) + geom_col(color = "black", size = 0.1) +
geom_col(color = "black") +
scale_fill_viridis(discrete = TRUE, na.value = "grey") + scale_fill_viridis(discrete = TRUE, na.value = "grey") +
ylab(set$y_axis_label) + ylab(set$y_axis_label) +
xlab(set$x_axis_label) + xlab(set$x_axis_label) +
theme(strip.background = element_blank(), theme(strip.background = element_blank(),
# strip.text = element_text(size = 16), legend.key.size = unit(0.9, "line"),
# axis.title=element_text(size=16), legend.text = element_text(margin = margin(0,10, 0, 1)),
# legend.text = element_text(size=14),
legend.position = "bottom") legend.position = "bottom")
plots$ndvi_dot_plot <- ggplot(set$topntax_tbl, aes(fct_reorder(Alias, ndvi), plots$ndvi_dot_plot <- ggplot(set$topntax_tbl, aes(fct_reorder(Alias, ndvi),
y = ndvi)) + y = ndvi)) +
geom_point() + geom_point() +
theme(strip.background = element_blank(), theme(strip.background = element_blank(),
#strip.text = element_text(size = 16),
# axis.title=element_text(size=16),
# legend.text = element_text(size=14)
axis.title.x=element_blank()) + axis.title.x=element_blank()) +
ylab("NDVI") ylab("NDVI")
...@@ -890,9 +889,6 @@ plots$shannon_dot_plot <- ggplot(set$topntax_tbl, ...@@ -890,9 +889,6 @@ plots$shannon_dot_plot <- ggplot(set$topntax_tbl,
y = Shannon)) + y = Shannon)) +
geom_point() + geom_point() +
theme(strip.background = element_blank(), theme(strip.background = element_blank(),
#strip.text = element_text(size = 16),
#axis.title=element_text(size=16),
#legend.text = element_text(size=14),
axis.title.x=element_blank()) + axis.title.x=element_blank()) +
ylab("Shannon") ylab("Shannon")
...@@ -905,7 +901,9 @@ plots$combo_topn_custom <- ggarrange(plots$ndvi_dot_plot, ...@@ -905,7 +901,9 @@ plots$combo_topn_custom <- ggarrange(plots$ndvi_dot_plot,
align = "v") align = "v")
save_plot(plots$combo_topn_custom, plot_name = paste0("Customized_NDVI_Shannon_plot"), save_plot(plots$combo_topn_custom, plot_name = paste0("Customized_NDVI_Shannon_plot"),
filetype = tmp$out) filetype = ".png")
save_plot(plots$combo_topn_custom, plot_name = paste0("Customized_NDVI_Shannon_plot"),
filetype = ".pdf")
plots$combo_topn_custom plots$combo_topn_custom
......
Source diff could not be displayed: it is too large. Options to address this: view the blob.
No preview for this file type
File deleted
No preview for this file type
analysis/16S/16S_DADA2_results_260821/analysis_output/Customized_NDVI_Shannon_plot.png

171 KiB

No preview for this file type
No preview for this file type
File deleted
No preview for this file type
File deleted
No preview for this file type
No preview for this file type
...@@ -726,7 +726,7 @@ set$ps.topnTax <- cuphyr::abundant_tax_physeq(ps.trans, lvl = set$taxlvl, ...@@ -726,7 +726,7 @@ set$ps.topnTax <- cuphyr::abundant_tax_physeq(ps.trans, lvl = set$taxlvl,
set$my_scale_fill <- my_scale_fill set$my_scale_fill <- my_scale_fill
set$topntax_tbl <- psmelt(set$ps.topnTax) %>% set$topntax_tb <- psmelt(set$ps.topnTax) %>%
as_tibble() %>% as_tibble() %>%
left_join(set$alpha_div_ps_trans, by = "Sample") %>% left_join(set$alpha_div_ps_trans, by = "Sample") %>%
select(Genus, Alias, ndvi, Abundance, Shannon) %>% select(Genus, Alias, ndvi, Abundance, Shannon) %>%
...@@ -736,17 +736,28 @@ set$topntax_tbl <- psmelt(set$ps.topnTax) %>% ...@@ -736,17 +736,28 @@ set$topntax_tbl <- psmelt(set$ps.topnTax) %>%
arrange(ndvi) %>% arrange(ndvi) %>%
mutate(ndvi_rank = c(1:length(ndvi))) mutate(ndvi_rank = c(1:length(ndvi)))
set$other <- set$topntax_tb %>%
plots$topn_tax_custom <- ggplot(set$topntax_tbl, aes( group_by(Alias) %>%
x = fct_reorder(Alias, ndvi), summarise(sumabu = sum(Abundance)) %>%
mutate(Genus = 'Other', Abundance = 1-sumabu) %>%
select(-sumabu)
set$topntax_tbl <- bind_rows(set$topntax_tb, set$other) %>%
mutate(Genus = factor(Genus, levels = c(
sort(unique(set$topntax_tb$Genus)),
"Other")
))
plots$topn_tax_custom <- ggplot(set$topntax_tbl, aes(x = fct_reorder(Alias, ndvi),
y = Abundance, y = Abundance,
fill = Genus)) + fill = Genus)) +
#title = paste0("Top ", set$top_n, " ", set$taxlvl))) + geom_col(color = "black", size = 0.1) +
geom_col(color = "black") + scale_fill_viridis(discrete = TRUE, na.value = "grey") +
set$my_scale_fill +
ylab(set$y_axis_label) + ylab(set$y_axis_label) +
xlab(set$x_axis_label) + xlab(set$x_axis_label) +
theme(strip.background = element_blank(), theme(strip.background = element_blank(),
legend.key.size = unit(0.9, "line"),
legend.text = element_text(margin = margin(0,10, 0, 1)),
legend.position = "bottom") legend.position = "bottom")
plots$ndvi_dot_plot <- ggplot(set$topntax_tbl, aes(fct_reorder(Alias, ndvi), plots$ndvi_dot_plot <- ggplot(set$topntax_tbl, aes(fct_reorder(Alias, ndvi),
...@@ -765,17 +776,17 @@ plots$shannon_dot_plot <- ggplot(set$topntax_tbl, ...@@ -765,17 +776,17 @@ plots$shannon_dot_plot <- ggplot(set$topntax_tbl,
ylab("Shannon") ylab("Shannon")
plots$combo_topn_custom <- ggarrange(plots$ndvi_dot_plot, plots$combo_topn_custom <- ggarrange(plots$ndvi_dot_plot,
plots$shannon_dot_plot, plots$shannon_dot_plot,
plots$topn_tax_custom, plots$topn_tax_custom,
nrow = 3, nrow = 3,
heights = c(1, 1, 3), heights = c(1, 1, 3),
align = "v") align = "v")
save_plot(plots$combo_topn_custom, plot_name = paste0("Customized_NDVI_Shannon_plot"), save_plot(plots$combo_topn_custom, plot_name = paste0("Customized_NDVI_Shannon_plot"),
filetype = tmp$out) filetype = ".png")
save_plot(plots$combo_topn_custom, plot_name = paste0("Customized_NDVI_Shannon_plot"),
filetype = ".pdf")
plots$combo_topn_custom plots$combo_topn_custom
``` ```
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment