yanlinlin82 / ggvenn

Venn Diagram by ggplot2, with really easy-to-use API.
Other
167 stars 25 forks source link

Scale circles to reflect overlap #13

Open tayaza opened 3 years ago

tayaza commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

Thank you, @yanlinlin82. Understood.

GioBrug commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

Dear @yanlinlin82,

I'd like to sincerely thank you for the reply and submitting this trial version. I'll contact you once I try it to give you a feedback. Regarding the further improvement of the code, I appreciate your willingness to do it. However, let me add that I'm currently dealing with four sets. Do you think it could be possible to improve the code, according with you agenda, to manage four sets instead of three?

I look forward to hearing from you. Regards,

Giorgio Brugaletta

Il dom 3 ott 2021, 02:26 Linlin Yan (颜林林) @.***> ha scritto:

Hi @GioBrug https://github.com/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.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/yanlinlin82/ggvenn/issues/13#issuecomment-932880166, or unsubscribe https://github.com/notifications/unsubscribe-auth/AV3VDXE7NHAPJNGRO42SLB3UFAASTANCNFSM4WNU6AJQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

GioBrug commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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