gaospecial / ggVennDiagram

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

transform phyloseq object to a list? #40

Closed marwa38 closed 2 years ago

marwa38 commented 2 years ago

Could you please let me know how to transform my phyloseq object to be accepted as input data to use ggVennDiagram? Many thanks M

gaospecial commented 2 years ago

I am afraid that I can't answer your question until a reproducible example of your phyloseq object is provided.

marwa38 commented 1 year ago

Dear @gaospecial sorry for my late reply here is a phyloseq object in form of .rds (zipped) ps.prev.rooted.zip please let mem know Cheers M

marwa38 commented 1 year ago

Hi @gaospecial again Incase more clarification is needed, I want to create Venn diagrams of ASVs for each group examples that I need to create from my above-shared dataset image image image Thanks M

gaospecial commented 1 year ago

FYI.

d = readRDS("ps.prev.rooted.rds")
sample = sample_data(d)
library(dplyr)
sample_origin = sample$sample  %>%  unique()

get_otu = function(x){
  otu = otu_table(x)
  otu_count = colSums(otu)
  otu_name = names(otu_count)
  otu_name[otu>0]
}

list = vector("list", length = 3)
list[[1]] = subset_samples(d, Sample == sample_origin[[1]]) %>% get_otu()
list[[2]] = subset_samples(d, Sample == sample_origin[[2]]) %>% get_otu()
list[[3]] = subset_samples(d, Sample == sample_origin[[3]]) %>% get_otu()

library(ggVennDiagram)
ggVennDiagram(list, category.names = sample_origin)

image