Skip to content

Commit df2151f

Browse files
committed
parameter to change intersection number colors
1 parent 572be88 commit df2151f

17 files changed

+76
-1568
lines changed

DESCRIPTION

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
Package: UpSetR
22
Title: A More Scalable Alternative to Venn and Euler Diagrams for Visualizing Intersecting Sets
33
Version: 1.4.0
4-
Date: 2016-1-3
4+
Date: 2019-5-9
55
URL: http://github.com/hms-dbmi/UpSetR
66
BugReports: http://github.com/hms-dbmi/UpSetR/issues
77
Authors@R: c(
88
person("Jake", "Conway", email = "[email protected]", role = "cre"),
99
person("Nils", "Gehlenborg", email = "[email protected]", role = "aut"))
1010
Description: Creates visualizations of intersecting sets using a novel matrix
1111
design, along with visualizations of several common set, element and attribute
12-
related tasks.
12+
related tasks (Conway 2017) <doi:10.1093/bioinformatics/btx364>.
1313
Depends:
1414
R (>= 3.0)
1515
Imports:
@@ -26,4 +26,4 @@ LazyData: true
2626
VignetteBuilder: knitr
2727
Suggests:
2828
knitr
29-
RoxygenNote: 6.1.0
29+
RoxygenNote: 7.0.2

R/MainBar.R

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ Counter <- function(data, num_sets, start_col, name_of_sets, nintersections, mba
6060
}
6161

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

6666
bottom_margin <- (-1)*0.65
6767

@@ -128,9 +128,15 @@ Make_main_bar <- function(Main_bar_data, Q, show_num, ratios, customQ, number_an
128128
axis.title.y = element_text(vjust = -0.8, size = 8.3*y_axis_title_scale), axis.text.y = element_text(vjust=0.3,
129129
size=7*y_axis_tick_label_scale)))
130130
if((show_num == "yes") || (show_num == "Yes")){
131-
Main_bar_plot <- (Main_bar_plot + geom_text(aes_string(label = "freq"), size = 2.2*intersection_size_number_scale, vjust = -1,
132-
angle = number_angles, colour = Main_bar_data$color))
131+
if(is.null(number.colors)) {
132+
Main_bar_plot <- (Main_bar_plot + geom_text(aes_string(label = "freq"), size = 2.2*intersection_size_number_scale, vjust = -1,
133+
angle = number_angles, colour = Main_bar_data$color))
134+
} else {
135+
Main_bar_plot <- (Main_bar_plot + geom_text(aes_string(label = "freq"), size = 2.2*intersection_size_number_scale, vjust = -1,
136+
angle = number_angles, colour = number.colors))
137+
}
133138
}
139+
134140
bInterDat <- NULL
135141
pInterDat <- NULL
136142
bCustomDat <- NULL
@@ -188,6 +194,9 @@ Make_main_bar <- function(Main_bar_data, Q, show_num, ratios, customQ, number_an
188194
+ geom_vline(xintercept = 0, color = "gray0")
189195
+ geom_hline(yintercept = 0, color = "gray0"))
190196

197+
if(!is.na(plot.title)) {
198+
Main_bar_plot <- c(Main_bar_plot + ggtitle(plot.title))
199+
}
191200
Main_bar_plot <- ggplotGrob(Main_bar_plot)
192201
return(Main_bar_plot)
193202
}

R/SizeBar.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ log2_reverse_trans <- function(){
3030
trans_new(paste0("reverselog2-", format(2), "reverse"), trans, inv,
3131
log_breaks(base = 2), domain = c(1e-100, Inf))
3232
}
33-
33+
globalVariables(c("y"))
3434
## Generate set size plot
3535
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,
3636
set_size.number_size){
@@ -64,9 +64,9 @@ Make_size_plot <- function(Set_size_data, sbar_color, ratios, ylabel, scale_sets
6464
}
6565

6666
if(!is.null(set_size.number_size)) {
67-
num.size <- (set_size.number_size/ggplot2:::.pt)*x_axis_tick_label_scale
67+
num.size <- (set_size.number_size/2.845276)*x_axis_tick_label_scale
6868
} else {
69-
num.size <- (7/ggplot2:::.pt)*x_axis_tick_label_scale
69+
num.size <- (7/2.845276)*x_axis_tick_label_scale
7070
}
7171

7272
Size_plot <- (ggplot(data = Set_size_data, aes_string(x ="x", y = "y"))

R/upset.R

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#' will be the specific intersections listed.
1515
#' @param matrix.color Color of the intersection points
1616
#' @param main.bar.color Color of the main bar plot
17+
#' @param plot.title Title of UpSetR plot
1718
#' @param mainbar.y.label The y-axis label of the intersection size bar plot
1819
#' @param mainbar.y.max The maximum y value of the intersection size bar plot scale. May be useful when aligning multiple UpSet plots horizontally.
1920
#' @param sets.bar.color Color of set size bar plot
@@ -28,6 +29,7 @@
2829
#' @param decreasing How the variables in order.by should be ordered. "freq" is decreasing (greatest to least) and "degree" is increasing (least to greatest)
2930
#' @param show.numbers Show numbers of intersection sizes above bars
3031
#' @param number.angles The angle of the numbers atop the intersection size bars
32+
#' @param number.colors The colors of the numbers atop the intersection size bars
3133
#' @param group.by How the data should be grouped ("degree" or "sets")
3234
#' @param cutoff The number of intersections from each set (to cut off at) when aggregating by sets
3335
#' @param queries Unified query of intersections, elements, and custom row functions. Entered as a list that contains a list of
@@ -117,9 +119,9 @@
117119
#' @export
118120
upset <- function(data, nsets = 5, nintersects = 40, sets = NULL, keep.order = F, set.metadata = NULL, intersections = NULL,
119121
matrix.color = "gray23", main.bar.color = "gray23", mainbar.y.label = "Intersection Size", mainbar.y.max = NULL,
120-
sets.bar.color = "gray23", sets.x.label = "Set Size", point.size = 2.2, line.size = 0.7,
122+
sets.bar.color = "gray23", plot.title = NA, sets.x.label = "Set Size", point.size = 2.2, line.size = 0.7,
121123
mb.ratio = c(0.70,0.30), expression = NULL, att.pos = NULL, att.color = main.bar.color, order.by = c("freq", "degree"),
122-
decreasing = c(T, F), show.numbers = "yes", number.angles = 0, group.by = "degree",cutoff = NULL,
124+
decreasing = c(T, F), show.numbers = "yes", number.angles = 0, number.colors=NULL, group.by = "degree",cutoff = NULL,
123125
queries = NULL, query.legend = "none", shade.color = "gray88", shade.alpha = 0.25, matrix.dot.alpha =0.5,
124126
empty.intersections = NULL, color.pal = 1, boxplot.summary = NULL, attribute.plots = NULL, scale.intersections = "identity",
125127
scale.sets = "identity", text.scale = 1, set_size.angles = 0 , set_size.show = FALSE, set_size.numbers_size = NULL, set_size.scale_max = NULL){
@@ -255,8 +257,8 @@ upset <- function(data, nsets = 5, nintersects = 40, sets = NULL, keep.order = F
255257
if(is.null(ShadingData) == TRUE){
256258
ShadingData <- MakeShading(Matrix_layout, shade.color)
257259
}
258-
Main_bar <- suppressMessages(Make_main_bar(All_Freqs, Bar_Q, show.numbers, mb.ratio, customQBar, number.angles, EBar_data, mainbar.y.label,
259-
mainbar.y.max, scale.intersections, text.scale, attribute.plots))
260+
Main_bar <- suppressMessages(Make_main_bar(All_Freqs, Bar_Q, show.numbers, mb.ratio, customQBar, number.angles, number.colors, EBar_data, mainbar.y.label,
261+
mainbar.y.max, scale.intersections, text.scale, attribute.plots, plot.title))
260262
Matrix <- Make_matrix_plot(Matrix_layout, Set_sizes, All_Freqs, point.size, line.size,
261263
text.scale, labels, ShadingData, shade.alpha)
262264
Sizes <- Make_size_plot(Set_sizes, sets.bar.color, mb.ratio, sets.x.label, scale.sets, text.scale, set_size.angles,set_size.show,
@@ -292,7 +294,7 @@ upset <- function(data, nsets = 5, nintersects = 40, sets = NULL, keep.order = F
292294
}
293295

294296
#' @export
295-
print.upset <- function(x, newpage = TRUE) {
297+
print.upset <- function(x, ..., newpage = TRUE) {
296298
Make_base_plot(
297299
Main_bar_plot = x$Main_bar,
298300
Matrix_plot = x$Matrix,
@@ -318,6 +320,6 @@ print.upset <- function(x, newpage = TRUE) {
318320
}
319321

320322
#' @export
321-
summary.upset <- function(x) {
323+
summary.upset <- function(...) {
322324
cat("An object of class `upset`. Call print() to show.")
323325
}

inst/doc/attribute.plots.R

Lines changed: 0 additions & 32 deletions
This file was deleted.

inst/doc/attribute.plots.Rmd

Lines changed: 0 additions & 100 deletions
This file was deleted.

inst/doc/attribute.plots.html

Lines changed: 0 additions & 246 deletions
This file was deleted.

inst/doc/basic.usage.R

Lines changed: 0 additions & 38 deletions
This file was deleted.

0 commit comments

Comments
 (0)