gaospecial / ggVennDiagram

A 'ggplot2' implement of Venn Diagram.
https://gaospecial.github.io/ggVennDiagram/
GNU General Public License v3.0
284 stars 38 forks source link

how to remove zero from the image #50

Closed crebli closed 1 year ago

crebli commented 1 year ago

hi, two much 0s were found in it, how to discard these digits from the venn image?

gaospecial commented 1 year ago

see: https://gaospecial.github.io/ggVennDiagram/articles/using-ggVennDiagram.html

crebli commented 1 year ago

hi, Like this,how to neatly remove the useless 0 from the image?

image

在 2023-03-27 09:10:15,"Chun-Hui Gao" @.***> 写道:

see: https://gaospecial.github.io/ggVennDiagram/articles/using-ggVennDiagram.html

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

gaospecial commented 1 year ago

我看不到图片。

crebli commented 1 year ago

image

crebli commented 1 year ago

Like this. Many useless 0s make the image untidy. It's usefult to remove all of these 0 by a certain setting in the package.

gaospecial commented 1 year ago

Like this. Many useless 0s make the image untidy. It's usefult to remove all of these 0 by a certain setting in the package.

see this: https://gaospecial.github.io/ggVennDiagram/articles/fully-customed.html

geom_sf_text(aes(label = count), fontface = "bold", data = venn_setlabel(data) %>% filter(count != 0)) +

crebli commented 1 year ago

Nice!

crebli commented 1 year ago

Sorry! A small error with your newly added code: ggplot() +

1. region count layer

geom_sf(aes(fill = count), data = venn_region(data)) +

2. set edge layer

geom_sf(aes(color = id), data = venn_setedge(data), show.legend = FALSE) +

3. set label layer

geom_sf_text(aes(label = count), fontface = "bold", data = venn_setlabel(data) %>% filter(count!= 0)) +

4. region label layer

geom_sf_label(aes(label = count), data = venn_region(data)) + theme_void()

Error in stopifnot(): i In argument: count != 0. Caused by error in count != 0: ! comparison (2) is possible only for atomic and list types

rlang::last_error() <error/rlang_error> Error in stopifnot(): i In argument: count != 0. Caused by error in count != 0: ! comparison (2) is possible only for atomic and list types

Backtrace:

  1. ggplot2::geom_sf_text(...)
    1. dplyr:::filter.data.frame(., count != 0)
    2. dplyr:::filter_rows(.data, dots, by)
    3. dplyr:::filter_eval(dots, mask = mask, error_call = error_call)
    4. mask$eval_all_filter(dots, env_filter)
    5. dplyr (local) eval()
gaospecial commented 1 year ago

Thanks for your feedback.

Corrected a mistake.

genes <- paste0("gene",1:20)
set.seed(20230406)
gene_list <- list(A = sample(genes,5),
                  B = sample(genes,5),
                  C = sample(genes,5),
                  D = sample(genes,5),
                  E = sample(genes,5),
                  F = sample(genes,5),
                  G = sample(genes,5))

library(ggVennDiagram)
library(ggplot2)
library(dplyr)
venn <- Venn(gene_list)
data <- process_data(venn)
ggplot() +
  # 1. region count layer
  geom_sf(aes(fill = count), data = venn_region(data)) +
  # 2. set edge layer
  geom_sf(aes(color = id), data = venn_setedge(data), show.legend = FALSE) +
  # 3. set label layer
  geom_sf_text(aes(label = name), data = venn_setlabel(data)) +
  # 4. region label layer
  geom_sf_label(aes(label = count), data = venn_region(data) %>% filter(count != 0), alpha = 0.5) +
  theme_void()

image

crebli commented 1 year ago

Nice. Thank you!

At 2023-04-06 10:31:41, "Chun-Hui Gao" @.***> wrote:

Thanks for your feedback.

Corrected a mistake.

genes<- paste0("gene",1:1000) set.seed(20210302) gene_list<-list(A= sample(genes,100), B= sample(genes,200), C= sample(genes,300), D= sample(genes,200))

library(ggVennDiagram) library(ggplot2) library(dplyr) venn<- Venn(gene_list) data<- process_data(venn) ggplot() +# 1. region count layer geom_sf(aes(fill=count), data= venn_region(data)) +# 2. set edge layer geom_sf(aes(color=id), data= venn_setedge(data), show.legend=FALSE) +# 3. set label layer geom_sf_text(aes(label=name), data= venn_setlabel(data)) +# 4. region label layer geom_sf_label(aes(label=count), data= venn_region(data) %>% filter(count>10)) + theme_void()

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

crebli commented 1 year ago

Hi, A question with the ggVennDiagram is that all empty cells can be regarded as one cell in the column with less rows. For example, A: 60 items, B: 50 items, C: 40 items. We'll get A: 60, B:51, C:41 items after ploting as below. Please check it and find a resolution for this quetion during data input.

在 2023-05-11 21:35:27,"Chun-Hui Gao" @.***> 写道:

Closed #50 as completed.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

gaospecial commented 1 year ago

Hi, A question with the ggVennDiagram is that all empty cells can be regarded as one cell in the column with less rows. For example, A: 60 items, B: 50 items, C: 40 items. We'll get A: 60, B:51, C:41 items after ploting as below. Please check it and find a resolution for this quetion during data input. 在 2023-05-11 21:35:27,"Chun-Hui Gao" @.> 写道: Closed #50 as completed. — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.>

Please give a reproducible example and open an extra issue to ask.