#' @title GroupBoxplot
#' @name GroupBoxplot
#'
#' @importFrom data.table as.data.table
#' @importFrom data.table setnames
#' @import ggplot2
#'
#' @param object an ICASDataSet
#' @param SJ a charactor of SJ
#' @param InterGroup the group for box (default is design)
#'
#' @author Tang Chao
#' @export
GroupBoxplot <- function(object, SJ, InterGroup = NULL) {
if(is.null(InterGroup)) {
InterGroup <- object@design
}
if(!is.element(InterGroup, colnames(object@colData))) {
stop("InterGroup must be one of column in colData")
}
Tab <- data.table::as.data.table(na.omit(merge(t(PSIofSJ(object, SJ)), subset(object@colData, select = colnames(object@colData) == InterGroup), by = 0)))
setnames(Tab, SJ, "PSI")
setnames(Tab, InterGroup, "Group")
ggplot(Tab, aes(x = Group, y = PSI, colour = Group)) +
geom_boxplot(outlier.colour = NA) +
geom_jitter(height = 0) +
scale_x_discrete(labels = paste0(names(Tab[, table(Group)]), " (", Tab[, table(Group)], ")")) +
labs(title = SJ, x = InterGroup) +
theme_pubr() +
theme(legend.title = element_blank())
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.