Skip to content

Commit

Permalink
parameter to change intersection number colors
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeConway committed Dec 7, 2020
1 parent 572be88 commit df2151f
Show file tree
Hide file tree
Showing 17 changed files with 76 additions and 1,568 deletions.
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
Package: UpSetR
Title: A More Scalable Alternative to Venn and Euler Diagrams for Visualizing Intersecting Sets
Version: 1.4.0
Date: 2016-1-3
Date: 2019-5-9
URL: http://github.com/hms-dbmi/UpSetR
BugReports: http://github.com/hms-dbmi/UpSetR/issues
Authors@R: c(
person("Jake", "Conway", email = "[email protected]", role = "cre"),
person("Nils", "Gehlenborg", email = "[email protected]", role = "aut"))
Description: Creates visualizations of intersecting sets using a novel matrix
design, along with visualizations of several common set, element and attribute
related tasks.
related tasks (Conway 2017) <doi:10.1093/bioinformatics/btx364>.
Depends:
R (>= 3.0)
Imports:
Expand All @@ -26,4 +26,4 @@ LazyData: true
VignetteBuilder: knitr
Suggests:
knitr
RoxygenNote: 6.1.0
RoxygenNote: 7.0.2
17 changes: 13 additions & 4 deletions R/MainBar.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ Counter <- function(data, num_sets, start_col, name_of_sets, nintersections, mba
}

## Generate main bar plot
Make_main_bar <- function(Main_bar_data, Q, show_num, ratios, customQ, number_angles,
ebar, ylabel, ymax, scale_intersections, text_scale, attribute_plots){
Make_main_bar <- function(Main_bar_data, Q, show_num, ratios, customQ, number_angles, number.colors,
ebar, ylabel, ymax, scale_intersections, text_scale, attribute_plots, plot.title){

bottom_margin <- (-1)*0.65

Expand Down Expand Up @@ -128,9 +128,15 @@ Make_main_bar <- function(Main_bar_data, Q, show_num, ratios, customQ, number_an
axis.title.y = element_text(vjust = -0.8, size = 8.3*y_axis_title_scale), axis.text.y = element_text(vjust=0.3,
size=7*y_axis_tick_label_scale)))
if((show_num == "yes") || (show_num == "Yes")){
Main_bar_plot <- (Main_bar_plot + geom_text(aes_string(label = "freq"), size = 2.2*intersection_size_number_scale, vjust = -1,
angle = number_angles, colour = Main_bar_data$color))
if(is.null(number.colors)) {
Main_bar_plot <- (Main_bar_plot + geom_text(aes_string(label = "freq"), size = 2.2*intersection_size_number_scale, vjust = -1,
angle = number_angles, colour = Main_bar_data$color))
} else {
Main_bar_plot <- (Main_bar_plot + geom_text(aes_string(label = "freq"), size = 2.2*intersection_size_number_scale, vjust = -1,
angle = number_angles, colour = number.colors))
}
}

bInterDat <- NULL
pInterDat <- NULL
bCustomDat <- NULL
Expand Down Expand Up @@ -188,6 +194,9 @@ Make_main_bar <- function(Main_bar_data, Q, show_num, ratios, customQ, number_an
+ geom_vline(xintercept = 0, color = "gray0")
+ geom_hline(yintercept = 0, color = "gray0"))

if(!is.na(plot.title)) {
Main_bar_plot <- c(Main_bar_plot + ggtitle(plot.title))
}
Main_bar_plot <- ggplotGrob(Main_bar_plot)
return(Main_bar_plot)
}
6 changes: 3 additions & 3 deletions R/SizeBar.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ log2_reverse_trans <- function(){
trans_new(paste0("reverselog2-", format(2), "reverse"), trans, inv,
log_breaks(base = 2), domain = c(1e-100, Inf))
}

globalVariables(c("y"))
## Generate set size plot
Make_size_plot <- function(Set_size_data, sbar_color, ratios, ylabel, scale_sets, text_scale, set_size_angle, set_size.show, set_size.scale_max,
set_size.number_size){
Expand Down Expand Up @@ -64,9 +64,9 @@ Make_size_plot <- function(Set_size_data, sbar_color, ratios, ylabel, scale_sets
}

if(!is.null(set_size.number_size)) {
num.size <- (set_size.number_size/ggplot2:::.pt)*x_axis_tick_label_scale
num.size <- (set_size.number_size/2.845276)*x_axis_tick_label_scale
} else {
num.size <- (7/ggplot2:::.pt)*x_axis_tick_label_scale
num.size <- (7/2.845276)*x_axis_tick_label_scale
}

Size_plot <- (ggplot(data = Set_size_data, aes_string(x ="x", y = "y"))
Expand Down
14 changes: 8 additions & 6 deletions R/upset.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#' will be the specific intersections listed.
#' @param matrix.color Color of the intersection points
#' @param main.bar.color Color of the main bar plot
#' @param plot.title Title of UpSetR plot
#' @param mainbar.y.label The y-axis label of the intersection size bar plot
#' @param mainbar.y.max The maximum y value of the intersection size bar plot scale. May be useful when aligning multiple UpSet plots horizontally.
#' @param sets.bar.color Color of set size bar plot
Expand All @@ -28,6 +29,7 @@
#' @param decreasing How the variables in order.by should be ordered. "freq" is decreasing (greatest to least) and "degree" is increasing (least to greatest)
#' @param show.numbers Show numbers of intersection sizes above bars
#' @param number.angles The angle of the numbers atop the intersection size bars
#' @param number.colors The colors of the numbers atop the intersection size bars
#' @param group.by How the data should be grouped ("degree" or "sets")
#' @param cutoff The number of intersections from each set (to cut off at) when aggregating by sets
#' @param queries Unified query of intersections, elements, and custom row functions. Entered as a list that contains a list of
Expand Down Expand Up @@ -117,9 +119,9 @@
#' @export
upset <- function(data, nsets = 5, nintersects = 40, sets = NULL, keep.order = F, set.metadata = NULL, intersections = NULL,
matrix.color = "gray23", main.bar.color = "gray23", mainbar.y.label = "Intersection Size", mainbar.y.max = NULL,
sets.bar.color = "gray23", sets.x.label = "Set Size", point.size = 2.2, line.size = 0.7,
sets.bar.color = "gray23", plot.title = NA, sets.x.label = "Set Size", point.size = 2.2, line.size = 0.7,
mb.ratio = c(0.70,0.30), expression = NULL, att.pos = NULL, att.color = main.bar.color, order.by = c("freq", "degree"),
decreasing = c(T, F), show.numbers = "yes", number.angles = 0, group.by = "degree",cutoff = NULL,
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){
Expand Down Expand Up @@ -255,8 +257,8 @@ upset <- function(data, nsets = 5, nintersects = 40, sets = NULL, keep.order = F
if(is.null(ShadingData) == TRUE){
ShadingData <- MakeShading(Matrix_layout, shade.color)
}
Main_bar <- suppressMessages(Make_main_bar(All_Freqs, Bar_Q, show.numbers, mb.ratio, customQBar, number.angles, EBar_data, mainbar.y.label,
mainbar.y.max, scale.intersections, text.scale, attribute.plots))
Main_bar <- suppressMessages(Make_main_bar(All_Freqs, Bar_Q, show.numbers, mb.ratio, customQBar, number.angles, number.colors, EBar_data, mainbar.y.label,
mainbar.y.max, scale.intersections, text.scale, attribute.plots, plot.title))
Matrix <- Make_matrix_plot(Matrix_layout, Set_sizes, All_Freqs, point.size, line.size,
text.scale, labels, ShadingData, shade.alpha)
Sizes <- Make_size_plot(Set_sizes, sets.bar.color, mb.ratio, sets.x.label, scale.sets, text.scale, set_size.angles,set_size.show,
Expand Down Expand Up @@ -292,7 +294,7 @@ upset <- function(data, nsets = 5, nintersects = 40, sets = NULL, keep.order = F
}

#' @export
print.upset <- function(x, newpage = TRUE) {
print.upset <- function(x, ..., newpage = TRUE) {
Make_base_plot(
Main_bar_plot = x$Main_bar,
Matrix_plot = x$Matrix,
Expand All @@ -318,6 +320,6 @@ print.upset <- function(x, newpage = TRUE) {
}

#' @export
summary.upset <- function(x) {
summary.upset <- function(...) {
cat("An object of class `upset`. Call print() to show.")
}
32 changes: 0 additions & 32 deletions inst/doc/attribute.plots.R

This file was deleted.

100 changes: 0 additions & 100 deletions inst/doc/attribute.plots.Rmd

This file was deleted.

246 changes: 0 additions & 246 deletions inst/doc/attribute.plots.html

This file was deleted.

38 changes: 0 additions & 38 deletions inst/doc/basic.usage.R

This file was deleted.

Loading

0 comments on commit df2151f

Please sign in to comment.