Skip to content

Commit

Permalink
add new param force_upset
Browse files Browse the repository at this point in the history
  • Loading branch information
gaospecial committed Dec 21, 2023
1 parent b891031 commit c77cafe
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
6 changes: 4 additions & 2 deletions R/ggVennDiagram.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ NULL
#' @param label_txtWidth width of text used in showing intersect members, will be ignored unless show_intersection is TRUE (40)
#' @param edge_lty line type of set edges ("solid")
#' @param edge_size line width of set edges (1)
#' @param force_upset if TRUE, will always produce Upset plot no matter how many sets have (FALSE)
#' @param ... useless
#'
#' @return A ggplot object
Expand All @@ -61,6 +62,7 @@ ggVennDiagram = function(x,
label_txtWidth = 40,
edge_lty = "solid",
edge_size = 1,
force_upset = FALSE,
...){
if (!is.list(x)){
stop(simpleError("ggVennDiagram() requires at least a list."))
Expand All @@ -71,7 +73,7 @@ ggVennDiagram = function(x,

label = match.arg(label)
label_geom = match.arg(label_geom)
if (dimension <= 7){
if (dimension <= 7 & !force_upset){
data = process_data(venn)
plot_venn(data,
show_intersect = show_intersect,
Expand All @@ -89,7 +91,7 @@ ggVennDiagram = function(x,
...)
}
else{
warning("Only support 2-7 dimension Venn diagram. Will give a plain upset plot instead.")
if (!force_upset) warning("Only support 2-7 dimension Venn diagram. Will give a plain upset plot instead.")
plot_upset(venn, nintersects = 30, order.intersect.by = "size", order.set.by = "name")
}
}
Expand Down
2 changes: 1 addition & 1 deletion inst/shiny/shinyApp.R
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ server = function(input, output, session){
for (i in 1:input$nsets){
x[[i]] = input[[paste0("set_", i)]] |> strsplit(split = ",") |> unlist()
}
(session$userData$plot = ggVennDiagram(x))
(session$userData$plot = ggVennDiagram(x, force_upset = input$force_upset))
})
output$plot_note = renderUI(
NULL
Expand Down
3 changes: 3 additions & 0 deletions man/ggVennDiagram.Rd

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

0 comments on commit c77cafe

Please sign in to comment.