Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

more customizability for boxplot #264

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions R/Boxplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,29 @@ IntersectionBoxPlot <- function(data1, data2, start_col, names){
}

## Generate boxplot summary plots
BoxPlotsPlot <- function(bdat, att, att_color){
BoxPlotsPlot <- function(bdat, att, att_color, boxpl_kw = NULL){
yaxis <- as.character(att)
col <- match(att, colnames(bdat))
colnames(bdat)[col] <- "attribute"
upper_xlim <- as.numeric((max(bdat$x) + 1))
plot_lims <- as.numeric(0:upper_xlim)
bdat$x <- as.factor(bdat$x)
# if boxpl_kw is not null, read the width and colour/color value of this named
# list, and use in boxplot
if(!is.null(boxpl_kw)){
if("width" %in% names(boxpl_kw)){
width <- boxpl_kw$width
} else {
width <- 1
}
if("color" %in% names(boxpl_kw)){
border_color <- boxpl_kw$color
} else if ("colour" %in% names(boxpl_kw)) {
border_color <- boxpl_kw$colour
} else {
border_color <- "gray80"
}
}
boxplots <- ggplotGrob(ggplot()
+ theme_bw() +ylab(yaxis)
+ scale_x_discrete(limits = plot_lims, expand = c(0,0))
Expand All @@ -52,6 +68,7 @@ BoxPlotsPlot <- function(bdat, att, att_color){
panel.grid.major = element_blank(),
axis.title.x = element_blank())
+ geom_boxplot(data = bdat, aes_string(x="x", y="attribute"),
fill = att_color, colour = "gray80"))
fill = att_color, colour = border_color,
width = width))
return(boxplots)
}
6 changes: 4 additions & 2 deletions R/upset.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
#' @param set_size.show Logical, display the set sizes on the set size bar chart
#' @param set_size.numbers_size If set_size.show is TRUE, adjust the size of the numbers
#' @param set_size.scale_max Increase the maximum of set size scale
#' @param boxpl_kw Named list of parameters to be passed to the boxplot function. Options include width and color/colour. If not specified, defaults (width = 1 and colour = "grey80") are used.
#' @details Visualization of set data in the layout described by Lex and Gehlenborg in \url{http://www.nature.com/nmeth/journal/v11/n8/abs/nmeth.3033.html}.
#' UpSet also allows for visualization of queries on intersections and elements, along with custom queries queries implemented using
#' Hadley Wickham's apply function. To further analyze the data contained in the intersections, the user may select additional attribute plots
Expand Down Expand Up @@ -124,7 +125,8 @@ upset <- function(data, nsets = 5, nintersects = 40, sets = NULL, keep.order = F
decreasing = c(T, F), show.numbers = "yes", number.angles = 0, number.colors=NULL, group.by = "degree",cutoff = NULL,
queries = NULL, query.legend = "none", shade.color = "gray88", shade.alpha = 0.25, matrix.dot.alpha =0.5,
empty.intersections = NULL, color.pal = 1, boxplot.summary = NULL, attribute.plots = NULL, scale.intersections = "identity",
scale.sets = "identity", text.scale = 1, set_size.angles = 0 , set_size.show = FALSE, set_size.numbers_size = NULL, set_size.scale_max = NULL){
scale.sets = "identity", text.scale = 1, set_size.angles = 0 , set_size.show = FALSE, set_size.numbers_size = NULL, set_size.scale_max = NULL,
boxpl_kw = NULL){

startend <-FindStartEnd(data)
first.col <- startend[1]
Expand Down Expand Up @@ -193,7 +195,7 @@ upset <- function(data, nsets = 5, nintersects = 40, sets = NULL, keep.order = F
BoxData <- IntersectionBoxPlot(All_Freqs, New_data, first.col, Set_names)
BoxPlots <- list()
for(i in seq_along(boxplot.summary)){
BoxPlots[[i]] <- BoxPlotsPlot(BoxData, boxplot.summary[i], att.color)
BoxPlots[[i]] <- BoxPlotsPlot(BoxData, boxplot.summary[i], att.color, boxpl_kw)
}
}

Expand Down