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 269 additions and 194 deletions
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
...@@ -719,7 +719,7 @@ set$ps.topnTax <- cuphyr::abundant_tax_physeq(ps.trans, lvl = set$taxlvl, ...@@ -719,7 +719,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) %>%
...@@ -729,16 +729,28 @@ set$topntax_tbl <- psmelt(set$ps.topnTax) %>% ...@@ -729,16 +729,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 %>%
group_by(Alias) %>%
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), 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),
...@@ -757,19 +769,18 @@ plots$shannon_dot_plot <- ggplot(set$topntax_tbl, ...@@ -757,19 +769,18 @@ 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.
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
...@@ -856,42 +856,69 @@ set$ps.topnTax <- cuphyr::abundant_tax_physeq(ps.trans, lvl = set$taxlvl, ...@@ -856,42 +856,69 @@ set$ps.topnTax <- cuphyr::abundant_tax_physeq(ps.trans, lvl = set$taxlvl,
ignore_na = set$ignore_na) ignore_na = set$ignore_na)
# Plot # Plot
set$my_scale_fill <- my_scale_fill # Custom, more narrow color ranges based on viridis
# Base order to have adjacent colors be distinct from each other
sort_colors <- c(rbind(c(1:5), c(6:10), c(11:15), c(16:20)))
# Customized color vectors
n_col <- 20
viridis_reds <- viridis(n_col, option = "B",
begin = 0.7 ,end = 0.5)[sort_colors]
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, ndvi_july, Abundance, Shannon) %>% select(Genus, Alias, ndvi, Abundance, Shannon) %>%
filter(Abundance > 0) %>% filter(Abundance > 0) %>%
group_by(Genus, Alias, ndvi, ndvi_july, Shannon) %>% group_by(Genus, Alias, ndvi, Shannon) %>%
summarise(Abundance = sum(Abundance)) %>% summarise(Abundance = sum(Abundance)) %>%
arrange(ndvi) %>% arrange(ndvi) %>%
mutate(ndvi_rank = c(1:length(ndvi))) mutate(ndvi_rank = c(1:length(ndvi)))
set$other <- set$topntax_tb %>%
group_by(Alias) %>%
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")
))
colors_comb <- c(
viridis(4, option = "D", begin = 0 ,end = 0.4),
viridis_reds[c(1,4)],
viridis(5, option = "D", begin = 0.5 ,end = 1)
)
names(colors_comb) <- levels(set$topntax_tbl$Genus)
formatted_labs <- c(as.expression(lapply(levels(set$topntax_tbl$Genus)[1:10],
function(x) bquote(italic(.(x))))),
expression("Other"))
set$my_scale_fill <- scale_fill_manual(values = colors_comb,
labels = formatted_labs,
na.value = "grey")
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") + set$my_scale_fill +
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(),
#strip.text = element_text(size = 12), legend.key.size = unit(0.9, "line"),
#axis.title=element_text(size=12), legend.text = element_text(margin = margin(0,10, 0, 1)),
#legend.text = element_text(size=12),
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 = 12), axis.title.x=element_blank()) +
# axis.title=element_text(size=12),
# legend.text = element_text(size=12),
axis.title.x=element_blank()) +
ylab("NDVI") ylab("NDVI")
plots$shannon_dot_plot <- ggplot(set$topntax_tbl, plots$shannon_dot_plot <- ggplot(set$topntax_tbl,
...@@ -899,26 +926,23 @@ plots$shannon_dot_plot <- ggplot(set$topntax_tbl, ...@@ -899,26 +926,23 @@ 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 = 12), axis.title.x=element_blank()) +
# axis.title=element_text(size=12),
# legend.text = element_text(size=12),
axis.title.x=element_blank()) +
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"),
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
save_plot(plots$combo_topn_custom, plot_name = paste0("Customized_NDVI_Shannon_plot"),
filetype = tmp$out)
``` ```
......
Source diff could not be displayed: it is too large. Options to address this: view the blob.
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment