从韦恩图的每个区域提取数值。

huangapple go评论60阅读模式
英文:

Extract values from each region of a venn diagram

问题

从韦恩图的每个区域提取数值。

我有6个列表。每个列表都包含特定状况下感兴趣的基因。然后使用这六个列表在R中使用venn包制作了一个Venn图。

这个Venn图正是我想要的,但现在我想生成一个包含Venn图中每个部分基因的列表。我该怎么做?即如何找出我的列表中构成每个列表/条件中存在的1251个基因的基因?

library(venn)

venn_list_no <- list(pt_v_lb = rownames(pt_v_lb_no), lbdm_v_lb = rownames(lbdm_v_lb_no), ptdm_v_lb = rownames(ptdm_v_lb_no), lbdm_v_pt = rownames(lbdm_v_pt_no), ptdm_v_pt = rownames(ptdm_v_pt_no), ptdm_v_lbdm = rownames(ptdm_v_lbdm_no))

venn(venn_list_no, zcolor = "style", ggplot = T, opacity = 0.2, box = F)+
  theme()
英文:

从韦恩图的每个区域提取数值。

I have 6 lists. Each contains genes of interest from a given condition. These six lists were then used to make a venn diagram in r using the venn package.

The venn diagram is precisely what I want, but now I would like to produce a list of genes from each section of the venn diagram. how do I do this? i.e. how do I figure out what genes from my lists comprise the 1251 genes that are present in each list/condition?

library(venn)

venn_list_no <- list(pt_v_lb = rownames(pt_v_lb_no), lbdm_v_lb = rownames(lbdm_v_lb_no), ptdm_v_lb = rownames(ptdm_v_lb_no), lbdm_v_pt = rownames(lbdm_v_pt_no), ptdm_v_pt = rownames(ptdm_v_pt_no), ptdm_v_lbdm = rownames(ptdm_v_lbdm_no))

venn(venn_list_no, zcolor = "style", ggplot = T, opacity = 0.2, box = F)+
  theme()

答案1

得分: 0

我查看了包的源代码,但我找不到任何文档化的用于提取区域元素的函数。实际上,venn 函数不返回任何内容,因此你无法进行检查。你可能想尝试使用我的 nVennR 包。目前该包在 CRAN 上不可用,但你可以通过以下命令从 Github 安装它:devtools::install_github("vqf/nVennR")。以下是一个示例:

>library(nVennR)
>myV <- plotVenn(list(set1=c(1, 2, 3), set2=c(2, 3, 4), set3=c(3, 4, 5, 'a', 'b'), set4=c(5, 6, 1, 4)))

[![在此输入图片描述][1]][1]

>getVennRegion(myV, c('set2', 'set3', 'set4'))
[1] 4

>getVennRegion(myV, c('set3'))
[1] "a" "b"

>listVennRegions(myV)
$`0, 0, 0, 1 (set4)`
[1] 6

$`0, 0, 1, 0 (set3)`
[1] "a" "b"

$`0, 0, 1, 1 (set3, set4)`
[1] 5

$`0, 1, 1, 1 (set2, set3, set4)`
[1] 4

$`1, 0, 0, 1 (set1, set4)`
[1] 1

$`1, 1, 0, 0 (set1, set2)`
[1] 2

$`1, 1, 1, 0 (set1, set2, set3)`
[1] "3"

你可以在 [vignette][2] 中找到更多示例。


  [1]: https://i.stack.imgur.com/i17x2.png
  [2]: https://mran.microsoft.com/snapshot/2022-01-07/web/packages/nVennR/vignettes/nVennR.html

<details>
<summary>英文:</summary>

I have had a look at the package source and I cannot see any documented function to extract the elements in a region. In fact, the `venn` function does not return anything, so there is nothing you can check.
You might want to try my `nVennR` package for that. At this time it is not available in CRAN, but you can install it from Github with `devtools::install_github(&quot;vqf/nVennR&quot;)`. An example:

    &gt;library(nVennR)
    &gt;myV &lt;- plotVenn(list(set1=c(1, 2, 3), set2=c(2, 3, 4), set3=c(3, 4, 5, &#39;a&#39;, &#39;b&#39;), set4=c(5, 6, 1, 4)))

[![enter image description here][1]][1]

    &gt;getVennRegion(myV, c(&#39;set2&#39;, &#39;set3&#39;, &#39;set4&#39;))
    [1] 4

    &gt;getVennRegion(myV, c(&#39;set3&#39;))
    [1] &quot;a&quot; &quot;b&quot;
    
    &gt;listVennRegions(myV)
    $`0, 0, 0, 1 (set4)`
    [1] 6

    $`0, 0, 1, 0 (set3)`
    [1] &quot;a&quot; &quot;b&quot;

    $`0, 0, 1, 1 (set3, set4)`
    [1] 5

    $`0, 1, 1, 1 (set2, set3, set4)`
    [1] 4

    $`1, 0, 0, 1 (set1, set4)`
    [1] 1

    $`1, 1, 0, 0 (set1, set2)`
    [1] 2

    $`1, 1, 1, 0 (set1, set2, set3)`
    [1] &quot;3&quot;

You can see more examples at the [vignette][2].


  [1]: https://i.stack.imgur.com/i17x2.png
  [2]: https://mran.microsoft.com/snapshot/2022-01-07/web/packages/nVennR/vignettes/nVennR.html

</details>



huangapple
  • 本文由 发表于 2023年4月17日 11:24:44
  • 转载请务必保留本文链接:https://go.coder-hub.com/76031519.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定