#' Volcano plots
#' @param x Output of edgeR::topTags
#' @param multiplot Draw multiple plots?
#' @param ncol Number of columns in grid
#' @param plot_title Titles for the plots
#' @export
plot_Volcano <- function(x, multiplot = FALSE,
plot_title, nrow, ncol) {
single_plot <- function(data) {
ggplot2::ggplot(data=data) +
ggplot2::geom_point(aes(logFC, logP, col = de)) +
ggplot2::xlab("logFC") +
ggplot2::ylab("-log10(P-value)") +
labs(color = "FDR")
}
if(multiplot) {
merged_table <- list()
for(i in seq_along(x)) {
y <- x[[i]]$table
merged_table[[i]] <- data.frame(logP = -log10(y$PValue),
logFC = y$logFC,
de = factor(c("NS", "FDR < 0.05")[as.numeric(y$FDR < 0.05) + 1]),
contrast = rep(plot_title[i], nrow(y)))
}
merged_table <- do.call("rbind", merged_table)
out <- single_plot(merged_table) + ggplot2::facet_wrap(~contrast,
nrow = nrow,
ncol = ncol,
scales = c("free"))
} else {
out <- single_plot(x)
if(!is.null(title)) {
out <- out + ggtitle(plot_title)
}
}
out
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.