#seqFile
#goal: overview of an RNA-seq experiment
#page 1: mapping, counts
#page 2: diff Expr
#page 3: GSEA
#' RNA-Seq mapping summary
#'
#' Imports:
#' ggplot2
#' reshape2
#'
#' @param datatable data.frame, containing a column for each sample, rownames must be the mapping status (mapped, unmapped etc.) and cells contain numbers
#' @param colors vector, containing a color string for each column stack
#' @return ggplot object
#' @examples
#' a <- seekMappingInfo(datatable)
seekMappingInfo <- function(datatable, colors=c("black","purple","blue","turquoise","limegreen")){
perc <- as.data.frame(round(apply(datatable, 2, function(x) x/sum(x)), 3)*100)
plotMe <- function(data, line){
data <- subset(data, rowSums(data)>0)
data <- cbind(status=rownames(data), data)
data$status <- factor(data$status, levels=sort(data$status, decreasing=T))
data <- reshape2::melt(data, value.name="status")
colnames(data) <- c("status","sample","counts")
ggplot2::ggplot(data, ggplot2::aes(x=sample, y=counts, fill=status)) +
ggplot2::geom_bar(stat="identity") +
ggplot2::geom_hline(yintercept=line, linetype="dashed") +
ggplot2::scale_fill_manual(values=colors[seq(data$status)]) +
ggplot2::scale_y_continuous(expand=c(0,0)) +
ggplot2::theme_classic() +
ggplot2::theme(axis.title.x=ggplot2::element_blank(), axis.text.x=ggplot2::element_text(angle=45, hjust=1))
}
ggpubr::ggarrange(plotMe(datatable, line=2*10^7) +
ggplot2::ylab("absolute number of reads"),
plotMe(perc, line=70) +
ggplot2::ylab("relative number of reads (%)"),
common.legend=T, legend="right")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.