dusadrian / venn

Draw Venn Diagrams
30 stars 7 forks source link

labels instead of count #18

Closed antoine4ucsd closed 2 years ago

antoine4ucsd commented 2 years ago

Hello thank you for providing this nice package! I have a dataset made of 5 lists of overlapping genes across 5 tissues it works as expected when using:

venn(mydata,ilabels=T,ellipse=T,ggplot=T,borders = T, box = F,zcolor=mycols)

but instead of showing the number of genes in each section, I would like to show the gene names themselves the data looks like that:

$`lymph node `
[1] "LUZP2"  "PDCD2L" "TFB1M" 

$PBMC
[1] "KDM2A"  "PDCD2L"

$Rectum
[1] "PDCD2L" "TFB1M" 
(...)

is there a simple way to plot the gene NAMES . this option exists in ggvenn (show_elements=TRUE) but this package can only show up to 4 sets.

thank you!

mmahmoudian commented 2 years ago

There is no such option in venn. I don't think it is a useful feature as typically the number of elements in each zone are way more than the available space in the zones of the venn. Also some items might not fit simply because they are long. In your case, the LOC genes are typically long and Entez gene IDs are even longer.

The following imho are more logical solutions:

  1. Save the venn as PDF, then use Inkscape and add them yourself. This way you can control the positioning and avoid overlapping

  2. Use interactive plots. Things like plotly or ggplotly packages

The former is useful for manuscripts and the latter for exploration during research

P.s: I'm not the main dev of this package, I jist expressed my opinion, that's all

dusadrian commented 2 years ago

That is correct. The more sets are added, the smaller and smaller the intersections will become, and there is simply not enough space to plot anything much more than numbers (even numbers have to be reduced in size to fit). You could however plot whatever your want, with additional base R commands, keeping in mind the entire plot region is a rectangle of 1000 x 1000 units.

For instance:

venn(4)
text(500, 400, "Hello world!")

Or, as @mmahmoudian suggests, you could save the plot using a different graphics device (I would use SVG and open it in Inkscape, but that is a matter of choice). See for instance ?svg

mmahmoudian commented 2 years ago

The comment of @dusadrian is correct, but I thought I should point out one critical point: in SVG the fonts are not embedded, but in PDF they are. Better wording of this can be found here by the lead dev of Inkscape:

https://mastodon.social/@doctormo/109050173578326556

dusadrian commented 2 years ago

Good point, @mmahmoudian. The native file type for Inkscape is SVG, but PDF files can be imported just as easily, preserving the fonts (or their closest approximation, Inkscape warns about that at the import phase).