Note that the venn() function from gplots is limited to a small number of sets
How do I look for shared OTUs in an abundance matrix?
Dear all,
Let's assume I have an abundance matrix that looks like this:
SampleA SampleB SampleC
OTU1 5 6 0
OTU2 3 1 2
OTU3 1 0 1
OTU4 0 0 2
If I have a large abundance matrix, what software or scripts will you recommend constructing a Venn diagram that can look for shared OTUs, or OTUs that are unique to each sample? The software / script should also produce an output that denotes the number of unique and shared OTUs.
Thank you!
• 3,857 views
•
link
1 answer
Transpose the dataframe/matrix so that OTUs are the sets, then convert into logical, then plot:
# example data
df1 <- read.table(text = "SampleA SampleB SampleC
OTU1 5 6 0
OTU2 3 1 2
OTU3 1 0 1
OTU4 0 0 2", header = TRUE, stringsAsFactors = FALSE)
library(gplots)
venn(t(df1 > 0))
• 0 views
•
link
• 0 views
•
link
True, not sure what OP wants, OTUs as sets or samples as sets, in their example both less than 5 sets. So 4 set Venn should be OK. Agreed, UpSet is more suitable when sets are more than 4.
• 0 views
•
link
Log in to answer this question.
For more than three sets, Euler diagrams quickly become unreadable. You may want to explore alternatives such as UpSetR.