Skip to content

Commit

Permalink
Allow user to keep order of sets entered using sets parameter. Fixes #46
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeConway committed Aug 1, 2016
1 parent e987bca commit 74c27b5
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 53 deletions.
15 changes: 10 additions & 5 deletions R/upset.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#' @param nsets Number of sets to look at
#' @param nintersects Number of intersections to plot
#' @param sets Specific sets to look at (Include as combinations. Ex: c("Name1", "Name2"))
#' @param keep.order Keep sets in the order entered using the sets parameter. The default is FALSE, which orders the sets by their sizes.
#' @param set.metadata Metadata that offers insight to an attribute of the sets. Input should be a data frame where the first column is set names, and the
#' remaining columns are attributes of those sets. To learn how to use this parameter it is highly suggested to view the set metadata vignette. The link
#' can be found on the package's GitHub page.
Expand Down Expand Up @@ -109,10 +110,10 @@
#' @import grDevices
#' @import scales
#' @export
upset <- function(data, nsets = 5, nintersects = 40, sets = NULL, 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, name.size = 7, mb.ratio = c(0.70,0.30),
expression = NULL, att.pos = NULL, att.color = main.bar.color, order.by = c("freq", "degree"),
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, name.size = 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,
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",
Expand All @@ -136,7 +137,9 @@ upset <- function(data, nsets = 5, nintersects = 40, sets = NULL, set.metadata =
Sets_to_remove <- Remove(data, first.col, last.col, Set_names)
New_data <- Wanted(data, Sets_to_remove)
Num_of_set <- Number_of_sets(Set_names)
Set_names <- order_sets(New_data, Set_names)
if(keep.order == F){
Set_names <- order_sets(New_data, Set_names)
}
All_Freqs <- specific_intersections(data, first.col, last.col, intersections, order.by, group.by, decreasing,
cutoff, main.bar.color, Set_names)
}
Expand All @@ -148,7 +151,9 @@ upset <- function(data, nsets = 5, nintersects = 40, sets = NULL, set.metadata =
Sets_to_remove <- Remove(data, first.col, last.col, Set_names)
New_data <- Wanted(data, Sets_to_remove)
Num_of_set <- Number_of_sets(Set_names)
if(keep.order == F){
Set_names <- order_sets(New_data, Set_names)
}
All_Freqs <- Counter(New_data, Num_of_set, first.col, Set_names, nintersects, main.bar.color,
order.by, group.by, cutoff, empty.intersections, decreasing)
}
Expand Down
10 changes: 5 additions & 5 deletions inst/doc/attribute.plots.html

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions inst/doc/basic.usage.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ upset(movies, sets = c("Action", "Adventure", "Comedy", "Drama", "Mystery", "Thr
## ---- out.width="850px", fig.width=13, fig.height =7,tidy=TRUE, fig.align='center'----
upset(movies, sets = c("Action", "Adventure", "Comedy", "Drama", "Mystery", "Thriller", "Romance", "War", "Western"), mb.ratio = c(0.55,0.45), order.by = c("degree", "freq"))

## ---- out.width="850px", fig.width=13, fig.height =7, tidy=TRUE, fig.align='center'----
upset(movies, sets = c("Action", "Adventure", "Comedy", "Drama", "Mystery", "Thriller", "Romance", "War", "Western"), mb.ratio = c(0.55,0.45), order.by = "freq", keep.order = TRUE)

## ---- out.width="850px", fig.width=13, fig.height =7,tidy=TRUE, fig.align='center'----
upset(movies, nintersects = 70, group.by = "sets", cutoff = 7)

Expand Down
13 changes: 11 additions & 2 deletions inst/doc/basic.usage.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,16 @@ upset(movies, sets = c("Action", "Adventure", "Comedy", "Drama", "Mystery", "Thr

<br>

Example 4: Grouping of Intersections
Example 4: Keeping Order of Sets When Using Sets Parameter
------------
To keep the sets in the order entered using the `sets` parameter (Example 3), set the `keep.order` parameter to **TRUE**.
```{r, out.width="850px", fig.width=13, fig.height =7, tidy=TRUE, fig.align='center'}
upset(movies, sets = c("Action", "Adventure", "Comedy", "Drama", "Mystery", "Thriller", "Romance", "War", "Western"), mb.ratio = c(0.55,0.45), order.by = "freq", keep.order = TRUE)
```

<br>

Example 5: Grouping of Intersections
------------
Instead of the default method of grouping by degree, grouping by sets can be acheived using `group.by`. To set a cutoff for the number of intersections per group of sets use `cutoff`.
```{r, out.width="850px", fig.width=13, fig.height =7,tidy=TRUE, fig.align='center'}
Expand All @@ -68,7 +77,7 @@ upset(movies, nintersects = 70, group.by = "sets", cutoff = 7)

<br>

Example 5: Displaying Empty Intersections
Example 6: Displaying Empty Intersections
------------
There may be times where an intersection you are looking for is not present in the matrix. This may be due to not showing enough intersections which can be changes with `nintersects`, or it may be because the intersection contains no elements. To additionally show empty intersections turn on `empty.intersections`.
```{r, out.width="850px", fig.width=13, fig.height =7,tidy=TRUE, fig.align='center'}
Expand Down
38 changes: 24 additions & 14 deletions inst/doc/basic.usage.html

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions inst/doc/queries.html

Large diffs are not rendered by default.

38 changes: 19 additions & 19 deletions inst/doc/set.metadata.plots.html

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion man/upset.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 11 additions & 2 deletions vignettes/basic.usage.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,16 @@ upset(movies, sets = c("Action", "Adventure", "Comedy", "Drama", "Mystery", "Thr

<br>

Example 4: Grouping of Intersections
Example 4: Keeping Order of Sets When Using Sets Parameter
------------
To keep the sets in the order entered using the `sets` parameter (Example 3), set the `keep.order` parameter to **TRUE**.
```{r, out.width="850px", fig.width=13, fig.height =7, tidy=TRUE, fig.align='center'}
upset(movies, sets = c("Action", "Adventure", "Comedy", "Drama", "Mystery", "Thriller", "Romance", "War", "Western"), mb.ratio = c(0.55,0.45), order.by = "freq", keep.order = TRUE)
```

<br>

Example 5: Grouping of Intersections
------------
Instead of the default method of grouping by degree, grouping by sets can be acheived using `group.by`. To set a cutoff for the number of intersections per group of sets use `cutoff`.
```{r, out.width="850px", fig.width=13, fig.height =7,tidy=TRUE, fig.align='center'}
Expand All @@ -68,7 +77,7 @@ upset(movies, nintersects = 70, group.by = "sets", cutoff = 7)

<br>

Example 5: Displaying Empty Intersections
Example 6: Displaying Empty Intersections
------------
There may be times where an intersection you are looking for is not present in the matrix. This may be due to not showing enough intersections which can be changes with `nintersects`, or it may be because the intersection contains no elements. To additionally show empty intersections turn on `empty.intersections`.
```{r, out.width="850px", fig.width=13, fig.height =7,tidy=TRUE, fig.align='center'}
Expand Down

0 comments on commit 74c27b5

Please sign in to comment.