Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Scale circles to reflect overlap #13

Open
tayaza opened this issue Jan 21, 2021 · 11 comments
Open

Scale circles to reflect overlap #13

tayaza opened this issue Jan 21, 2021 · 11 comments

Comments

@tayaza
Copy link

tayaza commented Jan 21, 2021

Hi,
Thank you for creating this. I was wondering if there's an option to make the circle areas represent the percentage of overlap, like the scale parameter in VennDiagram. Thank you!

@yanlinlin82
Copy link
Owner

Hi @tayaza! Thanks for asking this. So far the ggvenn package supports only fixed-size circles. My hesitation in whether or not to add this feature started from the first day of writing this package, because the scaled size (diameter or area) may lead to confusion sometimes. Anyway, I will keep this issue open, so that I may implement scaled-circles in the future.

@tayaza
Copy link
Author

tayaza commented Jan 22, 2021

Thank you, @yanlinlin82. Understood.

@GioBrug
Copy link

GioBrug commented Oct 1, 2021

Hi everyone,

I'd like to sincerely thank @yanlinlin82 for making this amazing package and @tayaza for bringing to the creator attention the "fixed-size circle issue". I'd love to make a Venn diagramm displaying the elements instead of count/percentage. Unfortunately, regardless of text_size and label_sep settings, the graph becomes unreadible. Scaling the size of the circles can be an absolutely valuable upgrade for this powerful package. @yanlinlin82 I'd really appreciate it if you'd implement the customazible-size argument. Thank you all for your time!

@yanlinlin82
Copy link
Owner

Hi @GioBrug,

I just submitted a new commit supporting auto-scaling circles for two sets (argument auto_scale). You may try it by upgrading to the latest (test) version code:

devtools::install_github("yanlinlin82/ggvenn")

And then,

library(ggvenn)
ggvenn(list(A = 1:8, B = 7:10), auto_scale = TRUE)

BTW, this is a very early version just for testing. In addition, for three sets, it will take me more time to improve the code. So, please be patient to wait.

@GioBrug
Copy link

GioBrug commented Oct 3, 2021 via email

@GioBrug
Copy link

GioBrug commented Oct 3, 2021

Dear @yanlinlin82,

I've just tried the test version. As far as I'm concerned, a customazible-scale feature may be easier to manage and more effective than the auto-scaling - that, unfortunately, did not help me solve my problem - allowing the user to simply choose the desired circle/ellipse size. Do you think it is possible?

Thank you again,

Giorgio

@yanlinlin82
Copy link
Owner

Hi @GioBrug,

Well, scaling circle size for plotting three sets is still possible. However, it may take some time to consider pretty-looking as well. Therefore, I may finish that at least in a few weeks.

Furthermore, it should be too complicated to scale circles for four sets simultaneously, including their intersections. That is the reason why I have no confidence to achieve the goal very soon.

So, how about you try other better visualization methods, such as the UpSetR plot?

@yanlinlin82
Copy link
Owner

Dear @yanlinlin82,

I've just tried the test version. As far as I'm concerned, a customazible-scale feature may be easier to manage and more effective than the auto-scaling - that, unfortunately, did not help me solve my problem - allowing the user to simply choose the desired circle/ellipse size. Do you think it is possible?

Thank you again,

Giorgio

Allowing the user to specify circle size directly is not a good option. In my opinion, an eligible API should help its user to avoid evil results, such as misleading large areas representing small values. So, unless it is absolutely necessary, I will not want to choose that way.

@GioBrug
Copy link

GioBrug commented Oct 4, 2021

Dear @yanlinlin82,

Thank you for your time and giving me a heads up on UpSetR. Unfortunately, I have to necessarily make a Venn diagramm. I completely understand that ensuring a high quality plot and making a package as user-friendly as possible are vital commitments for great API like you.

I apologize for bothering you.

Best

@yanlinlin82
Copy link
Owner

Dear @yanlinlin82,

Thank you for your time and giving me a heads up on UpSetR. Unfortunately, I have to necessarily make a Venn diagramm. I completely understand that ensuring a high quality plot and making a package as user-friendly as possible are vital commitments for great API like you.

I apologize for bothering you.

Best

If you insist on using Venn, I guess you can draw it manually. Code from ggvenn package may help. Here goes a simple example:

library(tidyverse)

gen_circle <- function(group, x_offset = 0, y_offset = 0, radius = 1,
                       radius_b = radius, theta_offset = 0, length.out = 100) {
  tibble(group = group,
         theta = seq(0, 2 * pi, length.out = length.out)) %>%
    mutate(x_raw = radius * cos(theta),
           y_raw = radius_b * sin(theta),
           x = x_offset + x_raw * cos(theta_offset) - y_raw * sin(theta_offset),
           y = y_offset + x_raw * sin(theta_offset) + y_raw * cos(theta_offset))
}

g <- ggplot() +
  geom_polygon(aes(x = x, y = y),
               data = gen_circle(group = 0L, x_offset = 0, y_offset = 0, radius = 1),
               color = "blue", fill = "red", alpha = .5) +
  geom_polygon(aes(x = x, y = y),
               data = gen_circle(group = 0L, x_offset = 2, y_offset = 1, radius = 2, radius_b = 1),
               color = "darkgray" , fill = "yellow", alpha = .5) +
  geom_polygon(aes(x = x, y = y),
               data = gen_circle(group = 0L, x_offset = 2, y_offset = 2,
                                 radius = 3, radius_b = .5, theta_offset = -pi / 4),
               color = "darkgreen" , fill = "green", alpha = .5)
print(g)

@GioBrug
Copy link

GioBrug commented Oct 5, 2021

@yanlinlin82, your example is tremendously enlightening! I'm grateful for all the work you've done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants