Chapter 4 Community composition

load("data/data.Rdata")

4.1 Taxonomy overview

4.1.1 Stacked barplot

genome_counts_filt %>%
  mutate_at(vars(-genome),~./sum(.)) %>% #apply TSS nornalisation
  pivot_longer(-genome, names_to = "sample", values_to = "count") %>% #reduce to minimum number of columns
  left_join(., genome_metadata, by = join_by(genome == genome)) %>% #append genome metadata
  left_join(., sample_metadata, by = join_by(sample == sample)) %>% #append sample metadata
  filter(count > 0) %>% #filter 0 counts
  ggplot(., aes(x=sample,y=count, fill=phylum, group=phylum)) + #grouping enables keeping the same sorting of taxonomic units
    geom_bar(stat="identity", colour="white", linewidth=0.1) + #plot stacked bars with white borders
    scale_fill_manual(values=phylum_colors) +
    facet_nested(. ~ treatment + trial,  scales="free") + #facet per day and treatment
    guides(fill = guide_legend(ncol = 1)) +
    theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1),
          axis.title.x = element_blank(),
          panel.background = element_blank(),
          panel.border = element_blank(),
          panel.grid.major = element_blank(),
          panel.grid.minor = element_blank(),
          axis.line = element_line(linewidth = 0.5, linetype = "solid", colour = "black")) +
   labs(fill="Phylum",y = "Relative abundance",x="Samples")

### Phylum relative abundances

phylum_summary <- genome_counts_filt %>%
  mutate_at(vars(-genome),~./sum(.)) %>% #apply TSS nornalisation
  pivot_longer(-genome, names_to = "sample", values_to = "count") %>%
  left_join(sample_metadata, by = join_by(sample == sample)) %>%
  left_join(genome_metadata, by = join_by(genome == genome)) %>%
  group_by(sample,phylum) %>%
  summarise(relabun=sum(count))

phylum_summary %>%
    group_by(phylum) %>%
    summarise(mean=mean(relabun, na.rm=T),sd=sd(relabun, na.rm=T)) %>%
    arrange(-mean) %>%
    tt()
tinytable_8hnwj52vntxyre8usp6d
phylum mean sd
p__Bacteroidota 0.5429264135 0.0839814443
p__Bacillota_A 0.2053118388 0.0504873476
p__Bacillota 0.0820882796 0.0332609240
p__Bacillota_C 0.0492489327 0.0142741661
p__Spirochaetota 0.0482278851 0.0467236412
p__Cyanobacteriota 0.0310050620 0.0165287926
p__Pseudomonadota 0.0172699714 0.0170094305
p__Campylobacterota 0.0162452268 0.0388594354
p__Patescibacteria 0.0022213343 0.0014395316
p__Thermoplasmatota 0.0019390776 0.0018321268
p__Verrucomicrobiota 0.0010490684 0.0022355045
p__Bacillota_B 0.0010095801 0.0006944021
p__Elusimicrobiota 0.0007469834 0.0010942911
p__Fibrobacterota 0.0007103462 0.0011143593
phylum_arrange <- phylum_summary %>%
    group_by(phylum) %>%
    summarise(mean=mean(relabun)) %>%
    arrange(-mean) %>%
    select(phylum) %>%
    pull()

phylum_summary %>%
    filter(phylum %in% phylum_arrange) %>%
    mutate(phylum=factor(phylum,levels=rev(phylum_arrange))) %>%
    ggplot(aes(x=relabun, y=phylum, group=phylum, color=phylum)) +
        scale_color_manual(values=phylum_colors[rev(phylum_arrange)]) +
        geom_jitter(alpha=0.5) + 
        theme_minimal() + 
        theme(legend.position="none") +
        labs(y="Phylum",x="Relative abundance")

4.2 Taxonomy boxplot

4.2.1 Family

family_summary <- genome_counts_filt %>%
  mutate_at(vars(-genome),~./sum(.)) %>% #apply TSS nornalisation
  pivot_longer(-genome, names_to = "sample", values_to = "count") %>% #reduce to minimum number of columns
  left_join(sample_metadata, by = join_by(sample == sample)) %>% #append sample metadata
  left_join(., genome_metadata, by = join_by(genome == genome)) %>% #append genome metadata
  group_by(sample,family) %>%
  summarise(relabun=sum(count))

family_summary %>%
    group_by(family) %>%
    summarise(mean=mean(relabun, na.rm=T),sd=sd(relabun, na.rm=T)) %>%
    arrange(-mean) %>%
    tt()
tinytable_n2pcb534i9j2b9ydfeb8
family mean sd
f__Bacteroidaceae 0.4700966396 0.1019283906
f__Lachnospiraceae 0.1171338702 0.0452596418
f__Treponemataceae 0.0408387686 0.0440444319
f__Gastranaerophilaceae 0.0296035799 0.0160991852
f__Selenomonadaceae 0.0289746313 0.0095722337
f__Oscillospiraceae 0.0259606214 0.0106720994
f__UBA660 0.0256112036 0.0182125645
f__UBA932 0.0230420425 0.0092838271
f__Ruminococcaceae 0.0180292427 0.0088616619
f__Muribaculaceae 0.0178740843 0.0071982538
f__Acidaminococcaceae 0.0167462889 0.0052414082
f__Campylobacteraceae 0.0159838256 0.0387975785
f__Paludibacteraceae 0.0158802598 0.0125214151
f__Clostridiaceae 0.0142082983 0.0159927811
f__Lactobacillaceae 0.0120870093 0.0141122636
f__Streptococcaceae 0.0119333963 0.0179222778
f__Erysipelotrichaceae 0.0108128987 0.0042497143
f__CAG-508 0.0099733313 0.0062656103
f__Acutalibacteraceae 0.0096833683 0.0060436186
f__UBA3663 0.0094777979 0.0192819112
f__Sphaerochaetaceae 0.0073891166 0.0060831038
f__Mycoplasmoidaceae 0.0057277193 0.0127545402
f__CAG-239 0.0057140284 0.0089502266
f__CAG-826 0.0055560044 0.0028667268
f__Peptostreptococcaceae 0.0049109397 0.0032085173
f__Tannerellaceae 0.0046155985 0.0026566511
f__CAG-288 0.0040602534 0.0021145362
f__Rhodocyclaceae 0.0038788761 0.0130720725
f__Anaeroplasmataceae 0.0030394443 0.0025945089
f__Nanosyncoccaceae 0.0022213343 0.0014395316
f__Succinivibrionaceae 0.0020045919 0.0024676663
f__Methanomethylophilaceae 0.0019390776 0.0018321268
f__Dialisteraceae 0.0017391230 0.0032952488
f__Butyricicoccaceae 0.0017234941 0.0021195229
f__CAG-449 0.0016810036 0.0013345102
f__Pasteurellaceae 0.0015456101 0.0047318494
f__CAG-465 0.0014721087 0.0026676970
f__Megasphaeraceae 0.0014360764 0.0023501498
f__RUG14156 0.0014014821 0.0014210129
f__UBA1997 0.0013531597 0.0023910775
f__Enterobacteriaceae 0.0013411897 0.0024260041
f__Burkholderiaceae_A 0.0012406314 0.0006951609
f__Amoebophilaceae 0.0011667118 0.0023198792
f__Turicibacteraceae 0.0011425956 0.0007583924
f__Peptococcaceae 0.0010095801 0.0006944021
f__Elusimicrobiaceae 0.0007469834 0.0010942911
f__UBA1067 0.0007204041 0.0016219643
f__Fibrobacteraceae 0.0007103462 0.0011143593
f__Cellulosilyticaceae 0.0005937404 0.0009420951
f__UBA3700 0.0005041373 0.0008110409
f__W3P20-009 0.0004944734 0.0006907562
f__Borkfalkiaceae 0.0003881408 0.0010875597
f__Anaerovoracaceae 0.0003775136 0.0007742000
f__Veillonellaceae 0.0003528131 0.0009774385
f__Akkermansiaceae 0.0003286643 0.0011129928
f__P3 0.0002788056 0.0009614512
f__Helicobacteraceae 0.0002614012 0.0005556899
f__Metamycoplasmataceae 0.0002189170 0.0007439893
f__Coprobacillaceae 0.0002178342 0.0005422852
f__CAG-272 0.0002069501 0.0008766710
f__Rs-D84 0.0001918840 0.0007168920
f__UBA1381 0.0001460821 0.0004690733
family_arrange <- family_summary %>%
    group_by(family) %>%
    summarise(mean=sum(relabun)) %>%
    arrange(-mean) %>%
    select(family) %>%
    pull()

# Per treatment
family_summary %>%
    left_join(genome_metadata %>% select(family,phylum) %>% unique(),by=join_by(family==family)) %>%
    left_join(sample_metadata,by=join_by(sample==sample)) %>%
    filter(family %in% family_arrange[1:20]) %>%
    mutate(family=factor(family,levels=rev(family_arrange[1:20]))) %>%
    filter(relabun > 0) %>%
    ggplot(aes(x=relabun, y=family, group=family, color=phylum)) +
        scale_color_manual(values=phylum_colors[-8]) +
        geom_jitter(alpha=0.5) + 
        facet_grid(.~treatment)+
        theme_minimal() + 
        labs(y="Family", x="Relative abundance", color="Phylum")

4.2.2 Genus

genus_summary <- genome_counts_filt %>%
  mutate_at(vars(-genome),~./sum(.)) %>% #apply TSS nornalisation
  pivot_longer(-genome, names_to = "sample", values_to = "count") %>% #reduce to minimum number of columns
  left_join(sample_metadata, by = join_by(sample == sample)) %>% #append sample metadata
  left_join(genome_metadata, by = join_by(genome == genome)) %>% #append genome metadata
  group_by(sample,phylum,genus) %>%
  summarise(relabun=sum(count)) %>%
  filter(genus != "g__") %>%
  mutate(genus= sub("^g__", "", genus))

genus_summary_sort <- genus_summary %>%
    group_by(genus) %>%
    summarise(mean=mean(relabun, na.rm=T),sd=sd(relabun, na.rm=T)) %>%
    arrange(-mean) 

genus_summary_sort %>%
    tt()
tinytable_xzwicfw3ok05a5vc30i3
genus mean sd
Prevotella 3.954166e-01 0.1038048308
Alloprevotella 4.821648e-02 0.0124460045
Treponema_D 4.083877e-02 0.0440444319
Agathobacter 3.516244e-02 0.0159828646
Faecousia 2.290556e-02 0.0102662784
Cryptobacteroides 2.272817e-02 0.0089460479
UBA4372 2.001823e-02 0.0110629331
Phascolarctobacterium_A 1.674629e-02 0.0052414082
Campylobacter 1.598383e-02 0.0387975785
Anaerovibrio 1.522639e-02 0.0065468666
RF16 1.511332e-02 0.0119538706
Clostridium 1.420830e-02 0.0159927811
W0P33-017 1.386459e-02 0.0094151963
CAMCDL01 1.374824e-02 0.0079563270
Streptococcus 1.193340e-02 0.0179222778
CAG-196 1.114276e-02 0.0072720243
UBA3663 9.477798e-03 0.0192819112
Lactobacillus 9.124798e-03 0.0103996217
COE1 8.670377e-03 0.0048120303
Lachnospira 7.757836e-03 0.0044411339
Faecalibacterium 7.403613e-03 0.0063485771
Sodaliphilus 6.259893e-03 0.0023821713
UBA636 6.053954e-03 0.0028821164
Malacoplasma_A 5.727719e-03 0.0127545402
Eubacterium_R 5.688683e-03 0.0048884676
UBA2883 5.630682e-03 0.0043630677
Gemmiger 5.545737e-03 0.0036125674
UBA2868 5.302298e-03 0.0075776580
CAG-605 5.103081e-03 0.0085460034
Parabacteroides 4.615599e-03 0.0026566511
UBA2882 4.556332e-03 0.0078575078
CAJGDV01 4.375272e-03 0.0073946242
SFTJ01 4.357617e-03 0.0031853723
Ornithospirochaeta 4.318767e-03 0.0026875413
Zag111 4.278245e-03 0.0037356591
Terrisporobacter 4.102349e-03 0.0027507957
UMGS1585 3.909555e-03 0.0023016276
SFHR01 3.878876e-03 0.0130720725
CAG-533 3.865377e-03 0.0034100580
Acetatifactor 3.325740e-03 0.0017960296
Onthovivens 3.112364e-03 0.0017978526
Bullifex 3.070349e-03 0.0040188810
Limosilactobacillus 2.962211e-03 0.0040683220
Bulleidia 2.891049e-03 0.0017439113
RUG410 2.854305e-03 0.0030288505
CAG-269 2.829172e-03 0.0024341894
Enterosoma 2.799082e-03 0.0019378803
UBA1221 2.726159e-03 0.0032665396
CAJOJO01 2.608791e-03 0.0120258428
UBA4334 2.524620e-03 0.0021396414
CAG-303 2.357897e-03 0.0024696723
Scatovivens 2.253934e-03 0.0021034110
CAG-485 2.245221e-03 0.0022921856
UBA2834 2.221334e-03 0.0014395316
Butyribacter 2.193939e-03 0.0023715379
UBA11957 2.137090e-03 0.0014526629
Wujia 2.062705e-03 0.0017014595
Succinivibrio 2.004592e-03 0.0024676663
CAG-267 1.985271e-03 0.0069597286
Anaeroplasma 1.970164e-03 0.0020442006
Fimenecus 1.925273e-03 0.0015984100
Limisoma 1.893799e-03 0.0012512398
Roseburia 1.891055e-03 0.0019178824
Onthousia 1.780553e-03 0.0016792228
Oliverpabstia 1.764149e-03 0.0016499416
UBA1712 1.739674e-03 0.0017911848
Dialister 1.739123e-03 0.0032952488
UBA3210 1.681004e-03 0.0013345102
UBA6382 1.668529e-03 0.0015786673
1XD8-76 1.647968e-03 0.0009404726
Dysosmobacter 1.636559e-03 0.0006376329
CAG-582 1.619036e-03 0.0023101109
UBA3789 1.554678e-03 0.0021954852
UBA71 1.539428e-03 0.0016045421
CAG-452 1.504396e-03 0.0014926048
CAG-465 1.472109e-03 0.0026676970
Megasphaera 1.436076e-03 0.0023501498
CAG-95 1.397961e-03 0.0010793714
Pararoseburia 1.370697e-03 0.0012356294
Stercorousia 1.351763e-03 0.0019389629
Escherichia 1.341190e-03 0.0024260041
RUG14156 1.320438e-03 0.0012877631
HGM13634 1.287840e-03 0.0015722660
HGM10890 1.261172e-03 0.0008205742
Sutterella 1.240631e-03 0.0006951609
Blautia_A 1.187043e-03 0.0016384301
Oribacterium 1.143520e-03 0.0011593782
Turicibacter 1.142596e-03 0.0007583924
Phocaeicola 1.124783e-03 0.0015425034
CAG-873 1.121972e-03 0.0014125215
CAG-882 1.119737e-03 0.0015619435
Coprococcus_A 1.090054e-03 0.0010674014
CAG-307 1.069280e-03 0.0009607836
RUG115 1.050968e-03 0.0014226574
Ventrimonas 1.025837e-03 0.0026445007
CAG-194 9.877873e-04 0.0011572030
RGIG3102 9.708819e-04 0.0004929237
Enteromonas 9.659928e-04 0.0007463490
CAG-245 9.031702e-04 0.0010680329
Butyricicoccus_A 8.674245e-04 0.0010970992
Agathobaculum 8.560696e-04 0.0017107271
CAG-590 8.339065e-04 0.0020798200
Basfia_A 8.158406e-04 0.0025857850
Romboutsia 8.085906e-04 0.0005738447
CALZFJ01 7.973847e-04 0.0005977457
CALZKI01 7.643313e-04 0.0009697478
MGBC100174 7.579825e-04 0.0014812246
UBA1436 7.469834e-04 0.0010942911
Actinobacillus_A 7.297695e-04 0.0029938658
CAG-632 7.195232e-04 0.0014437470
Aphodocola 6.951033e-04 0.0007698976
Ruminococcus_E 6.922093e-04 0.0008334298
Blautia 6.863243e-04 0.0008814138
CAG-1000 6.658396e-04 0.0011250480
UBA3207 6.566213e-04 0.0008392876
MGBC108787 6.111432e-04 0.0008075631
Clostridium_Q 6.109169e-04 0.0004432668
CAG-115 6.102927e-04 0.0014104650
JALEVB01 6.085658e-04 0.0004062303
Cellulosilyticum 5.937404e-04 0.0009420951
UBA7185 5.890955e-04 0.0005426874
Holdemanella 5.881670e-04 0.0005929724
CALXSC01 5.868139e-04 0.0013578825
Mediterranea 5.783514e-04 0.0009685560
Bariatricus 5.678290e-04 0.0004912286
Scatousia 5.644188e-04 0.0008769630
VSOB01 5.599855e-04 0.0006888622
JALFVM01 5.507130e-04 0.0006101708
RGIG9287 5.465083e-04 0.0024433056
SIG333 5.445884e-04 0.0009002716
CAG-45 5.338278e-04 0.0008164413
HGM13010 5.258450e-04 0.0004502508
Limivicinus 5.253983e-04 0.0005487623
SFRY01 5.246062e-04 0.0004813940
SFJ001 5.180974e-04 0.0003930913
Hallerella 5.172076e-04 0.0008613899
CAG-826 5.170304e-04 0.0008743808
SFIE01 5.169742e-04 0.0005550785
RUG11198 5.127886e-04 0.0008351012
UBA3700 5.041373e-04 0.0008110409
W3P20-009 4.944734e-04 0.0006907562
UMGS363 4.929590e-04 0.0012273398
UMGS1491 4.858508e-04 0.0005399772
Aphodosoma 4.779456e-04 0.0013579188
Choladocola 4.738155e-04 0.0004342450
Scatocola 4.604184e-04 0.0010371059
Ruminococcus 4.445026e-04 0.0006919929
UBA3282 4.438616e-04 0.0005083950
UMGS1994 4.344562e-04 0.0007934213
UMGS1590 4.204847e-04 0.0004036875
RUG705 4.195280e-04 0.0007771757
UBA7173 4.100424e-04 0.0005561943
UBA1783 4.099466e-04 0.0005640421
Ruminococcus_C 4.056678e-04 0.0004844254
Methanomethylophilus 3.996493e-04 0.0004802023
UBA1067 3.983207e-04 0.0009244905
CAG-238 3.775136e-04 0.0007742000
Bacteroides_F 3.759222e-04 0.0006304753
RUG14891 3.696802e-04 0.0008003112
JAHHSE01 3.672573e-04 0.0011485065
CAG-877 3.558107e-04 0.0007632094
Fusicatenibacter 3.544812e-04 0.0006932089
CAMBIX01 3.528131e-04 0.0009774385
CALVUP01 3.510109e-04 0.0004922037
UBA7050 3.420853e-04 0.0004308404
Ruminiclostridium_E 3.410333e-04 0.0008951955
UMGS1668 3.388053e-04 0.0005266594
Akkermansia 3.286643e-04 0.0011129928
RUG572 3.220834e-04 0.0007503658
Merdicola 3.141435e-04 0.0006916879
Egerieousia 3.138723e-04 0.0006309551
UBA4951 3.039960e-04 0.0004628059
UBA6398 3.003435e-04 0.0005128175
W0P28-013 2.889906e-04 0.0013727816
MGBC120314 2.861871e-04 0.0006231744
CAKOTZ01 2.857955e-04 0.0004180249
Onthomorpha 2.788056e-04 0.0009614512
W0P31-042 2.635487e-04 0.0003389963
CAG-302 2.621592e-04 0.0006045524
Helicobacter_D 2.614012e-04 0.0005556899
Floccifex 2.612166e-04 0.0003383941
JAHHTP01 2.592354e-04 0.0002896173
NK4A136 2.416155e-04 0.0010312163
CAZU01 2.408714e-04 0.0005713470
Butyrivibrio_A 2.279423e-04 0.0003667137
Copromonas 2.255607e-04 0.0003928410
UBA710 2.189170e-04 0.0007439893
Catenibacterium 2.178342e-04 0.0005422852
SIG301 2.025205e-04 0.0004021773
Fibrobacter 1.931386e-04 0.0007993952
Enterousia 1.918840e-04 0.0007168920
HUN007 1.814426e-04 0.0005192063
Ventrenecus 1.734925e-04 0.0004976721
CAKQTH01 1.731625e-04 0.0004666181
Marvinbryantia 1.649863e-04 0.0003614440
Eubacterium_F 1.637006e-04 0.0003477185
UMGS1663 1.604242e-04 0.0005928074
OMSK01 1.512188e-04 0.0007063771
JALEPO01 1.460821e-04 0.0004690733
Coprococcus 1.392515e-04 0.0002761491
Scybalousia 1.366405e-04 0.0007230946
Fimousia 1.197481e-04 0.0006118080
CAG-557 1.179812e-04 0.0007325510
Clostridium_AI 1.070752e-04 0.0007418386
RGIG1934 8.794057e-05 0.0002976833
Galligastranaerophilus_A 8.104457e-05 0.0003930025
genus_arrange <- genus_summary %>%
    group_by(genus) %>%
    summarise(mean=sum(relabun)) %>%
    filter(genus != "g__")%>%
    arrange(-mean) %>%
    select(genus) %>%
    mutate(genus= sub("^g__", "", genus)) %>%
    pull()

#Per treatment
genus_summary %>%
    left_join(sample_metadata,by=join_by(sample==sample)) %>%
    mutate(genus=factor(genus, levels=rev(genus_summary_sort %>% pull(genus)))) %>%
    filter(relabun > 0) %>%
    ggplot(aes(x=relabun, y=genus, group=genus, color=phylum)) +
        scale_color_manual(values=phylum_colors) +
        geom_jitter(alpha=0.5) + 
        facet_grid(.~treatment)+
        theme_minimal() + 
        labs(y="Family", x="Relative abundance", color="Phylum")