YuLab-SMU / MicrobiotaProcess

:microbe: A comprehensive R package for deep mining microbiome
https://www.sciencedirect.com/science/article/pii/S2666675823000164
182 stars 37 forks source link

mp_cal_venn and mp_plot_venn calculation #92

Closed etorres475 closed 1 year ago

etorres475 commented 1 year ago

Hi!,

Can you please help me get more information about mp_cal_venn and mp_plot_venn? I am building my Venn diagrams using the following commands:

r.Venn.12 <- r.mpse12.a %>% mp_cal_venn(.abundance=RareAbundance, .group=Plants_grown_in_soil, action="add")

r.Venn.12.p <- r.Venn.12 %>% mp_plot_venn(.venn = vennOfPlants_grown_in_soil, .group = Plants_grown_in_soil) + scale_color_manual(values = c("#00A087FF","#E08B00", "#3C5488FF")) + theme_void() + scale_fill_gradient(low = "#F4FAFE", high = "#4981BF")

r.Venn.12 contains 3021 OTUs, nevertheless, I only get 999 OTUs represented in the plot. Is it something about the plot representation or calculation? or Am I understanding the calculation/plot wrong?

Screenshot 2023-05-03 at 9 44 36 PM

Sorry to bother you! Thanks a lot for your help!

xiangpin commented 1 year ago

Some ASVs were removed since they are no longer present in any sample after rarefying.

> library(MicrobiotaProcess)
> data(mouse.time.mpse)
> mouse.time.mpse %>% mp_rrarefy()
# A MPSE-tibble (MPSE object) abstraction: 4,142 × 12
# OTU=218 | Samples=19 | Assays=Abundance, RareAbundance | Taxonomy=Kingdom, Phylum, Class, Order, Family, Genus, Species
   OTU    Sample Abundance RareAbundance time  Kingdom Phylum Class Order Family
   <chr>  <chr>      <int>         <int> <chr> <chr>   <chr>  <chr> <chr> <chr>
 1 OTU_1  F3D0         579           214 Early k__Bac… p__Ba… c__B… o__B… f__Mu…
 2 OTU_2  F3D0         345           116 Early k__Bac… p__Ba… c__B… o__B… f__Mu…
 3 OTU_3  F3D0         449           179 Early k__Bac… p__Ba… c__B… o__B… f__Mu…
 4 OTU_4  F3D0         430           167 Early k__Bac… p__Ba… c__B… o__B… f__Mu…
 5 OTU_5  F3D0         154            54 Early k__Bac… p__Ba… c__B… o__B… f__Ba…
 6 OTU_6  F3D0         470           174 Early k__Bac… p__Ba… c__B… o__B… f__Mu…
 7 OTU_7  F3D0         282           115 Early k__Bac… p__Ba… c__B… o__B… f__Mu…
 8 OTU_8  F3D0         184            74 Early k__Bac… p__Ba… c__B… o__B… f__Ri…
 9 OTU_9  F3D0          45            16 Early k__Bac… p__Ba… c__B… o__B… f__Mu…
10 OTU_10 F3D0         158            59 Early k__Bac… p__Ba… c__B… o__B… f__Mu…
# ℹ 4,132 more rows
# ℹ 2 more variables: Genus <chr>, Species <chr>
# ℹ Use `print(n = ...)` to see more rows
> mouse.time.mpse %>% mp_rrarefy() %>% mp_extract_assays(.abundance=RareAbundance) %>% rowSums() %>% `>`(0) %>% table()
.
FALSE  TRUE
    3   215
> mouse.time.mpse %>% mp_rrarefy(.abundance=Abundance, trimOTU=T)
3 OTUs were removed because they are no longer present in any sample after
rarefaction, if you want to keep them you can set 'trimOTU = FALSE' !
# A MPSE-tibble (MPSE object) abstraction: 4,085 × 12
# OTU=215 | Samples=19 | Assays=Abundance, RareAbundance | Taxonomy=Kingdom, Phylum, Class, Order, Family, Genus, Species
   OTU    Sample Abundance RareAbundance time  Kingdom Phylum Class Order Family
   <chr>  <chr>      <int>         <int> <chr> <chr>   <chr>  <chr> <chr> <chr>
 1 OTU_1  F3D0         579           214 Early k__Bac… p__Ba… c__B… o__B… f__Mu…
 2 OTU_2  F3D0         345           116 Early k__Bac… p__Ba… c__B… o__B… f__Mu…
 3 OTU_3  F3D0         449           179 Early k__Bac… p__Ba… c__B… o__B… f__Mu…
 4 OTU_4  F3D0         430           167 Early k__Bac… p__Ba… c__B… o__B… f__Mu…
 5 OTU_5  F3D0         154            54 Early k__Bac… p__Ba… c__B… o__B… f__Ba…
 6 OTU_6  F3D0         470           174 Early k__Bac… p__Ba… c__B… o__B… f__Mu…
 7 OTU_7  F3D0         282           115 Early k__Bac… p__Ba… c__B… o__B… f__Mu…
 8 OTU_8  F3D0         184            74 Early k__Bac… p__Ba… c__B… o__B… f__Ri…
 9 OTU_9  F3D0          45            16 Early k__Bac… p__Ba… c__B… o__B… f__Mu…
10 OTU_10 F3D0         158            59 Early k__Bac… p__Ba… c__B… o__B… f__Mu…
# ℹ 4,075 more rows
# ℹ 2 more variables: Genus <chr>, Species <chr>
# ℹ Use `print(n = ...)` to see more rows
>
etorres475 commented 1 year ago

mmm, thanks a lot! :)