This function aggregates the abundance data at a specified taxonomic level. It accepts a phyloseq object or a data.frame as input.
T_collapse.RdThis function aggregates the abundance data at a specified taxonomic level. It accepts a phyloseq object or a data.frame as input.
Examples
# With BiocManager, package "microbiome"
library(microbiome)
# if is_phyloseq = T
library (microbiome)
data ("dietswap")
T_collapse (is_phyloseq = T, ps = dietswap, names_level ="Phylum")
#> Error in validObject(.Object): invalid class “taxonomyTable” object:
#> Non-character matrix provided as Taxonomy Table.
#> Taxonomy is expected to be characters.
# if is_phyloseq = F
library (seqtime)
colnames (david_stool_lineages)<- c("ID", "Kingdom", "Phylum", "Class", "Order", "Family", "Genus", "Species", "Summary", "ID")
T_collapse(is_phyloseq = F, T_table = david_stool_lineages, O_table = david_stoolA_otus, names_level = "Family")
#> Nitrospiraceae none Rikenellaceae Porphyromonadaceae
#> SAMPLE_Stool1 0 5750 118 859
#> SAMPLE_Stool2 0 7719 125 299
#> SAMPLE_Stool3 0 7336 93 145
#> SAMPLE_Stool4 0 405 0 0
#> SAMPLE_Stool5 0 7180 38 120
#> SAMPLE_Stool6 0 10115 727 658
#> Bacteroidaceae Prevotellaceae Flavobacteriaceae
#> SAMPLE_Stool1 17775 4 5
#> SAMPLE_Stool2 23449 15 0
#> SAMPLE_Stool3 23991 15 0
#> SAMPLE_Stool4 0 0 0
#> SAMPLE_Stool5 25269 34 0
#> SAMPLE_Stool6 40196 5 0
#> Acidobacteriaceae Spirochaetaceae Hyphomicrobiaceae
#> SAMPLE_Stool1 0 0 0
#> SAMPLE_Stool2 0 0 0
#> SAMPLE_Stool3 0 0 0
#> SAMPLE_Stool4 0 0 0
#> SAMPLE_Stool5 0 0 0
#> SAMPLE_Stool6 0 0 0
#> Bradyrhizobiaceae Xanthobacteraceae Methylobacteriaceae
#> SAMPLE_Stool1 0 0 0
#> SAMPLE_Stool2 0 0 0
#> SAMPLE_Stool3 0 0 0
#> SAMPLE_Stool4 93 0 0
#> SAMPLE_Stool5 0 0 0
#> SAMPLE_Stool6 11 0 21
#> Rhizobiaceae Caulobacteraceae Rhodobacteraceae
#> SAMPLE_Stool1 0 0 0
#> SAMPLE_Stool2 0 0 0
#> SAMPLE_Stool3 0 0 0
#> SAMPLE_Stool4 0 0 0
#> SAMPLE_Stool5 0 0 0
#> SAMPLE_Stool6 0 0 0
#> Sphingomonadaceae Neisseriaceae Rhodocyclaceae Alcaligenaceae
#> SAMPLE_Stool1 0 1 0 345
#> SAMPLE_Stool2 0 26 0 463
#> SAMPLE_Stool3 0 2 0 484
#> SAMPLE_Stool4 0 0 0 0
#> SAMPLE_Stool5 0 1 0 22
#> SAMPLE_Stool6 0 2 0 53
#> Comamonadaceae Burkholderiaceae Oxalobacteraceae
#> SAMPLE_Stool1 8 0 0
#> SAMPLE_Stool2 21 0 0
#> SAMPLE_Stool3 1 1 0
#> SAMPLE_Stool4 462 0 0
#> SAMPLE_Stool5 9 0 0
#> SAMPLE_Stool6 67 0 58
#> Cardiobacteriaceae Oceanospirillaceae Moraxellaceae
#> SAMPLE_Stool1 0 0 21
#> SAMPLE_Stool2 1 0 6
#> SAMPLE_Stool3 0 0 28
#> SAMPLE_Stool4 0 0 0
#> SAMPLE_Stool5 0 0 1
#> SAMPLE_Stool6 0 0 8
#> Pseudomonadaceae Pseudoalteromonadaceae Shewanellaceae
#> SAMPLE_Stool1 1 0 0
#> SAMPLE_Stool2 1 0 0
#> SAMPLE_Stool3 0 0 0
#> SAMPLE_Stool4 0 0 0
#> SAMPLE_Stool5 0 0 0
#> SAMPLE_Stool6 0 0 0
#> Vibrionaceae Pasteurellaceae Enterobacteriaceae
#> SAMPLE_Stool1 0 170 86
#> SAMPLE_Stool2 0 305 28
#> SAMPLE_Stool3 0 298 19
#> SAMPLE_Stool4 0 0 0
#> SAMPLE_Stool5 0 26 17
#> SAMPLE_Stool6 0 49 86
#> Desulfovibrionaceae Campylobacteraceae Fusobacteriaceae
#> SAMPLE_Stool1 133 3 0
#> SAMPLE_Stool2 45 2 0
#> SAMPLE_Stool3 24 7 0
#> SAMPLE_Stool4 0 0 0
#> SAMPLE_Stool5 20 0 0
#> SAMPLE_Stool6 161 3 0
#> Coriobacteriaceae Geodermatophilaceae Frankiaceae
#> SAMPLE_Stool1 25 0 0
#> SAMPLE_Stool2 77 0 0
#> SAMPLE_Stool3 32 0 0
#> SAMPLE_Stool4 0 0 0
#> SAMPLE_Stool5 35 0 0
#> SAMPLE_Stool6 132 0 0
#> Microbacteriaceae Cellulomonadaceae Intrasporangiaceae
#> SAMPLE_Stool1 0 0 0
#> SAMPLE_Stool2 0 0 0
#> SAMPLE_Stool3 1 0 0
#> SAMPLE_Stool4 0 0 0
#> SAMPLE_Stool5 0 0 0
#> SAMPLE_Stool6 0 0 0
#> Micrococcaceae Dermabacteraceae Dermacoccaceae Actinomycetaceae
#> SAMPLE_Stool1 6 0 0 15
#> SAMPLE_Stool2 1 0 0 28
#> SAMPLE_Stool3 0 0 0 16
#> SAMPLE_Stool4 0 0 0 0
#> SAMPLE_Stool5 0 0 0 21
#> SAMPLE_Stool6 0 0 0 27
#> Bifidobacteriaceae Propionibacteriaceae Mycobacteriaceae
#> SAMPLE_Stool1 2248 0 0
#> SAMPLE_Stool2 8649 0 0
#> SAMPLE_Stool3 7247 0 0
#> SAMPLE_Stool4 0 0 0
#> SAMPLE_Stool5 9077 0 0
#> SAMPLE_Stool6 13254 0 0
#> Gordoniaceae Corynebacteriaceae Nocardiaceae Veillonellaceae
#> SAMPLE_Stool1 0 1 0 2150
#> SAMPLE_Stool2 0 2 0 1564
#> SAMPLE_Stool3 0 18 0 1395
#> SAMPLE_Stool4 0 211 0 0
#> SAMPLE_Stool5 0 0 0 1411
#> SAMPLE_Stool6 0 1 0 1770
#> Peptococcaceae Lachnospiraceae
#> SAMPLE_Stool1 0 24917
#> SAMPLE_Stool2 0 45793
#> SAMPLE_Stool3 0 40150
#> SAMPLE_Stool4 0 0
#> SAMPLE_Stool5 0 35777
#> SAMPLE_Stool6 0 48166
#> ClostridialesFamilyXIII.IncertaeSedis Clostridiaceae
#> SAMPLE_Stool1 3 104
#> SAMPLE_Stool2 1 66
#> SAMPLE_Stool3 0 40
#> SAMPLE_Stool4 0 0
#> SAMPLE_Stool5 5 82
#> SAMPLE_Stool6 9 32
#> Peptostreptococcaceae ClostridialesFamilyXI.IncertaeSedis
#> SAMPLE_Stool1 0 13
#> SAMPLE_Stool2 0 5
#> SAMPLE_Stool3 0 13
#> SAMPLE_Stool4 0 0
#> SAMPLE_Stool5 0 16
#> SAMPLE_Stool6 0 21
#> Paenibacillaceae Bacillaceae Planococcaceae Gemellaceae
#> SAMPLE_Stool1 0 0 0 2
#> SAMPLE_Stool2 0 0 0 8
#> SAMPLE_Stool3 0 0 0 5
#> SAMPLE_Stool4 0 0 0 0
#> SAMPLE_Stool5 0 0 0 1
#> SAMPLE_Stool6 0 0 0 8
#> Aerococcaceae Carnobacteriaceae Leuconostocaceae
#> SAMPLE_Stool1 0 12 49
#> SAMPLE_Stool2 1 21 32
#> SAMPLE_Stool3 0 14 31
#> SAMPLE_Stool4 44 0 0
#> SAMPLE_Stool5 0 8 30
#> SAMPLE_Stool6 0 10 39
#> Lactobacillaceae Enterococcaceae Streptococcaceae
#> SAMPLE_Stool1 2 1 135
#> SAMPLE_Stool2 2 3 544
#> SAMPLE_Stool3 2 2 281
#> SAMPLE_Stool4 0 0 1
#> SAMPLE_Stool5 51 0 316
#> SAMPLE_Stool6 93 1 3706
#> Erysipelotrichaceae Ruminococcaceae Staphylococcaceae
#> SAMPLE_Stool1 2016 23385 0
#> SAMPLE_Stool2 4681 32174 0
#> SAMPLE_Stool3 3302 31288 0
#> SAMPLE_Stool4 0 1 34
#> SAMPLE_Stool5 537 36646 0
#> SAMPLE_Stool6 2245 60176 0
#> Coxiellaceae Nocardioidaceae Brucellaceae Flexibacteraceae
#> SAMPLE_Stool1 0 0 0 0
#> SAMPLE_Stool2 0 0 0 0
#> SAMPLE_Stool3 0 0 0 0
#> SAMPLE_Stool4 0 0 0 0
#> SAMPLE_Stool5 0 0 0 0
#> SAMPLE_Stool6 0 0 0 0
#> Turicibacteraceae Tsukamurellaceae Phyllobacteriaceae
#> SAMPLE_Stool1 2 0 0
#> SAMPLE_Stool2 1 0 0
#> SAMPLE_Stool3 22 0 0
#> SAMPLE_Stool4 0 0 0
#> SAMPLE_Stool5 4 0 0
#> SAMPLE_Stool6 0 0 0
#> Brevibacteriaceae Aeromonadaceae Sinobacteraceae
#> SAMPLE_Stool1 0 0 0
#> SAMPLE_Stool2 0 0 0
#> SAMPLE_Stool3 0 0 0
#> SAMPLE_Stool4 0 0 0
#> SAMPLE_Stool5 0 0 0
#> SAMPLE_Stool6 0 0 0
#> Beijerinckiaceae Catabacteriaceae Dietziaceae
#> SAMPLE_Stool1 0 2 0
#> SAMPLE_Stool2 0 3 0
#> SAMPLE_Stool3 0 0 0
#> SAMPLE_Stool4 0 0 0
#> SAMPLE_Stool5 0 0 0
#> SAMPLE_Stool6 0 5 0
#> Pseudonocardiaceae F16 Halomonadaceae Xanthomonadaceae
#> SAMPLE_Stool1 0 0 0 2
#> SAMPLE_Stool2 0 0 0 0
#> SAMPLE_Stool3 0 0 0 0
#> SAMPLE_Stool4 0 0 0 213
#> SAMPLE_Stool5 0 0 0 34
#> SAMPLE_Stool6 0 0 0 0
#> Sphingobacteriaceae Alteromonadaceae Dethiosulfovibrionaceae
#> SAMPLE_Stool1 0 0 0
#> SAMPLE_Stool2 0 0 13
#> SAMPLE_Stool3 0 0 0
#> SAMPLE_Stool4 0 0 0
#> SAMPLE_Stool5 0 0 0
#> SAMPLE_Stool6 0 0 2
#> Thermaceae Bacteriovoracaceae Acetobacteraceae Nostocaceae
#> SAMPLE_Stool1 0 0 0 0
#> SAMPLE_Stool2 0 0 0 0
#> SAMPLE_Stool3 0 0 0 0
#> SAMPLE_Stool4 0 0 0 0
#> SAMPLE_Stool5 0 0 0 0
#> SAMPLE_Stool6 0 0 0 0
#> Colwelliaceae Planctomycetaceae Hydrogenophilaceae
#> SAMPLE_Stool1 0 0 0
#> SAMPLE_Stool2 0 0 0
#> SAMPLE_Stool3 0 0 0
#> SAMPLE_Stool4 0 0 0
#> SAMPLE_Stool5 0 0 0
#> SAMPLE_Stool6 0 0 0
#> Nocardiopsaceae Rhodospirillaceae Methylophilaceae
#> SAMPLE_Stool1 0 0 0
#> SAMPLE_Stool2 0 0 0
#> SAMPLE_Stool3 0 0 0
#> SAMPLE_Stool4 0 0 0
#> SAMPLE_Stool5 0 0 0
#> SAMPLE_Stool6 0 0 0
#> Promicromonosporaceae OM60 Cryomorphaceae Methylocystaceae
#> SAMPLE_Stool1 0 0 0 0
#> SAMPLE_Stool2 0 0 0 0
#> SAMPLE_Stool3 0 0 0 0
#> SAMPLE_Stool4 0 0 0 0
#> SAMPLE_Stool5 0 0 0 0
#> SAMPLE_Stool6 0 0 0 0
#> Bdellovibrionaceae Streptomycetaceae Hyphomonadaceae
#> SAMPLE_Stool1 0 0 0
#> SAMPLE_Stool2 0 0 0
#> SAMPLE_Stool3 0 0 0
#> SAMPLE_Stool4 0 0 0
#> SAMPLE_Stool5 0 0 0
#> SAMPLE_Stool6 0 0 0
#> Solibacteraceae Rubrobacteraceae Chromatiaceae Bogoriellaceae
#> SAMPLE_Stool1 0 0 0 0
#> SAMPLE_Stool2 0 0 0 0
#> SAMPLE_Stool3 0 0 0 0
#> SAMPLE_Stool4 0 0 0 0
#> SAMPLE_Stool5 0 0 0 0
#> SAMPLE_Stool6 0 0 0 0
#> Williamsiaceae Legionellaceae Gallionellaceae Armatimonadaceae
#> SAMPLE_Stool1 0 0 0 0
#> SAMPLE_Stool2 0 0 0 0
#> SAMPLE_Stool3 0 0 0 0
#> SAMPLE_Stool4 0 0 0 0
#> SAMPLE_Stool5 0 0 0 0
#> SAMPLE_Stool6 0 0 0 0
#> Opitutaceae Alicyclobacillaceae Solirubrobacteraceae
#> SAMPLE_Stool1 0 0 0
#> SAMPLE_Stool2 0 0 0
#> SAMPLE_Stool3 0 0 0
#> SAMPLE_Stool4 0 0 0
#> SAMPLE_Stool5 0 0 0
#> SAMPLE_Stool6 0 0 0
#> Spartobacteriaceae Aurantimonadaceae Gemmatimonadaceae
#> SAMPLE_Stool1 0 0 0
#> SAMPLE_Stool2 0 0 0
#> SAMPLE_Stool3 0 0 0
#> SAMPLE_Stool4 0 0 0
#> SAMPLE_Stool5 0 0 0
#> SAMPLE_Stool6 0 0 0
#> Micromonosporaceae Saccharospirillaceae Xenococcaceae
#> SAMPLE_Stool1 0 0 0
#> SAMPLE_Stool2 0 0 0
#> SAMPLE_Stool3 0 0 0
#> SAMPLE_Stool4 0 0 0
#> SAMPLE_Stool5 0 0 0
#> SAMPLE_Stool6 0 0 0
#> Verrucomicrobiaceae Dermatophilaceae Listeriaceae
#> SAMPLE_Stool1 0 0 0
#> SAMPLE_Stool2 0 0 0
#> SAMPLE_Stool3 0 0 0
#> SAMPLE_Stool4 0 0 0
#> SAMPLE_Stool5 0 0 0
#> SAMPLE_Stool6 0 0 0
#> Psychromonadaceae Gemmataceae Syntrophobacteraceae
#> SAMPLE_Stool1 0 0 0
#> SAMPLE_Stool2 0 0 0
#> SAMPLE_Stool3 0 0 0
#> SAMPLE_Stool4 0 0 0
#> SAMPLE_Stool5 0 0 0
#> SAMPLE_Stool6 0 0 0
#> Haliangiaceae Idiomarinaceae Dehalobacteriaceae AKIW874 ACK-M1
#> SAMPLE_Stool1 0 0 0 0 0
#> SAMPLE_Stool2 0 0 0 0 0
#> SAMPLE_Stool3 0 0 0 0 0
#> SAMPLE_Stool4 0 0 0 0 0
#> SAMPLE_Stool5 0 0 0 0 0
#> SAMPLE_Stool6 0 0 0 0 0
#> Eubacteriaceae Deinococcaceae Leptospiraceae
#> SAMPLE_Stool1 3 0 0
#> SAMPLE_Stool2 4 0 0
#> SAMPLE_Stool3 0 0 0
#> SAMPLE_Stool4 0 0 0
#> SAMPLE_Stool5 1 0 0
#> SAMPLE_Stool6 4 0 0
#> ThermoanaerobacteralesFamilyIII.IncertaeSedis Nitrosomonadaceae
#> SAMPLE_Stool1 0 0
#> SAMPLE_Stool2 0 0
#> SAMPLE_Stool3 0 0
#> SAMPLE_Stool4 0 0
#> SAMPLE_Stool5 0 0
#> SAMPLE_Stool6 0 0
#> Erythrobacteraceae Thermicanaceae Victivallaceae A29
#> SAMPLE_Stool1 0 0 0 0
#> SAMPLE_Stool2 0 0 0 0
#> SAMPLE_Stool3 0 0 0 0
#> SAMPLE_Stool4 0 0 0 0
#> SAMPLE_Stool5 0 0 0 0
#> SAMPLE_Stool6 0 0 0 0
#> Rhodothermaceae Helicobacteraceae Exiguobacteraceae
#> SAMPLE_Stool1 0 0 0
#> SAMPLE_Stool2 0 0 0
#> SAMPLE_Stool3 0 0 0
#> SAMPLE_Stool4 0 0 0
#> SAMPLE_Stool5 0 0 0
#> SAMPLE_Stool6 0 0 0
#> Patulibacteraceae Methanobacteriaceae Sanguibacteraceae
#> SAMPLE_Stool1 0 0 0
#> SAMPLE_Stool2 0 0 0
#> SAMPLE_Stool3 0 0 0
#> SAMPLE_Stool4 0 0 0
#> SAMPLE_Stool5 0 0 0
#> SAMPLE_Stool6 0 0 0
#> Phormidiaceae
#> SAMPLE_Stool1 0
#> SAMPLE_Stool2 0
#> SAMPLE_Stool3 0
#> SAMPLE_Stool4 0
#> SAMPLE_Stool5 0
#> SAMPLE_Stool6 0
#> [ reached getOption("max.print") -- omitted 323 rows ]