diff --git a/DESCRIPTION b/DESCRIPTION index 67db373..19daa7b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: tinyarray Type: Package Title: simplify geo and tcga analysis and plots -Version: 1.7.3 +Version: 1.7.4 Author: Xiaojie Sun Maintainer: Xiaojie Sun <18763899370@163.com> Description: Simplify geo and tcga analysis and plots diff --git a/R/plots.R b/R/plots.R index aa2b87e..d3ca6fd 100644 --- a/R/plots.R +++ b/R/plots.R @@ -263,6 +263,8 @@ draw_venn <- function(x,name){ ##' @param ylab title of the y axis ##' @param grouplab title of group legend ##' @param p.label whether to show p vlaue in the plot +##' @param add_error_bar whether to add error bar +##' @param colset color for boxplot ##' @return a boxplot according to \code{exp} and grouped by \code{group}. ##' @author Xiaojie Sun ##' @importFrom tidyr gather @@ -298,7 +300,10 @@ draw_boxplot = function(exp,group_list, xlab = "Gene", ylab = "Expression", grouplab = "Group", - p.label = F){ + p.label = F, + add_error_bar = F, + colset = c("#66C2A5", "#FC8D62", "#8DA0CB", "#E78AC3", "#A6D854", + "#FFD92F", "#E5C494", "#B3B3B3")){ p0 <- all(apply(exp,2,is.numeric)) & (!is.null(rownames(exp))) if(!p0) stop("exp must be a numeric matrix with rownames") p1 = method %in% c("kruskal.test","aov","t.test","wilcox.test") @@ -344,11 +349,8 @@ draw_boxplot = function(exp,group_list, levels = names(sort(x)), ordered = T) } - colset = c("#66C2A5", "#FC8D62", "#8DA0CB", "#E78AC3", "#A6D854", - "#FFD92F", "#E5C494", "#B3B3B3") col = colset[1:length(levels(group_list))] p = ggplot(dat,aes(rows,exp,fill = group))+ - stat_boxplot(geom ='errorbar', width = width)+ geom_boxplot( width = width)+ theme_bw()+ theme(legend.position = "top")+ @@ -356,6 +358,7 @@ draw_boxplot = function(exp,group_list, x = xlab, y = ylab)+ scale_fill_manual(values = col) + if(add_error_bar) p = stat_boxplot(geom ='errorbar', width = width) if(!p.label){ p = p + stat_compare_means(aes(group = group,label = ..p.signif..),method = method) }else{ diff --git a/man/draw_boxplot.Rd b/man/draw_boxplot.Rd index e95b049..4fdbdd2 100644 --- a/man/draw_boxplot.Rd +++ b/man/draw_boxplot.Rd @@ -15,7 +15,10 @@ draw_boxplot( xlab = "Gene", ylab = "Expression", grouplab = "Group", - p.label = F + p.label = F, + add_error_bar = F, + colset = c("#66C2A5", "#FC8D62", "#8DA0CB", "#E78AC3", "#A6D854", "#FFD92F", + "#E5C494", "#B3B3B3") ) } \arguments{ @@ -40,6 +43,10 @@ draw_boxplot( \item{grouplab}{title of group legend} \item{p.label}{whether to show p vlaue in the plot} + +\item{add_error_bar}{whether to add error bar} + +\item{colset}{color for boxplot} } \value{ a boxplot according to \code{exp} and grouped by \code{group}.