Skip to contents

This function takes a MultiAssayExperiment object and a specified taxon level of interest and creates a long data.frame that can be used more easily for plotting counts data in a stacked bar plot or a stacked area chart. The function groups taxa and computes relative abundance within taxa strata.

Usage

get_stacked_data(dat, taxon_level = "genus", covariate_1, covariate_time)

Arguments

dat

A MultiAssayExperiment object specially formatted as an animalcules output.

taxon_level

Character string indicating the level of taxonomy to aggregate the counts data. Must be the name of a column in MultiAssayExperiment::rowData(dat).

covariate_1

Character string, the name of the covariate in `dat` by which to color and group samples. Default is NULL.

covariate_time

Character string giving the name of the discrete time-based covariate in the metadata to group abundances by.

Value

A data.frame consisting of the counts data, taxa, and metadata.

Examples

in_dat <- system.file("extdata/MAE_small.RDS", package = "LegATo") |> readRDS()
get_stacked_data(in_dat, "genus", covariate_1 = "Sex", covariate_time = "Month")
#>                  taxon covariate_1 covariate_t        value
#> 1        Acinetobacter      Female           1 5.391689e-01
#> 2            Aeromonas      Female           1 2.438339e-03
#> 3     Alkalihalophilus      Female           1 9.691706e-03
#> 4             Brucella      Female           1 7.903853e-03
#> 5      Corynebacterium      Female           1 5.658341e-02
#> 6        Cutibacterium      Female           1 3.254340e-06
#> 7              Delftia      Female           1 5.878204e-04
#> 8       Dolosigranulum      Female           1 2.097972e-03
#> 9         Enterobacter      Female           1 5.019068e-02
#> 10         Escherichia      Female           1 0.000000e+00
#> 11         Haemophilus      Female           1 6.461345e-03
#> 12             Kocuria      Female           1 1.636577e-02
#> 13            Listeria      Female           1 5.812874e-02
#> 14           Moraxella      Female           1 1.659765e-02
#> 15          Mycoplasma      Female           1 1.337991e-03
#> 16  Noviherbaspirillum      Female           1 3.339523e-02
#> 17               Other      Female           1 7.158095e-03
#> 18          Paracoccus      Female           1 2.638631e-04
#> 19         Pseudomonas      Female           1 5.979654e-02
#> 20      Staphylococcus      Female           1 1.060623e-01
#> 21       Streptococcus      Female           1 1.022373e-02
#> 22           Weissella      Female           1 1.554279e-02
#> 23       Acinetobacter        Male           1 7.186046e-01
#> 24           Aeromonas        Male           1 2.558981e-03
#> 25    Alkalihalophilus        Male           1 5.785040e-03
#> 26            Brucella        Male           1 1.301520e-02
#> 27     Corynebacterium        Male           1 5.996756e-02
#> 28       Cutibacterium        Male           1 0.000000e+00
#> 29             Delftia        Male           1 2.019060e-04
#> 30      Dolosigranulum        Male           1 0.000000e+00
#> 31        Enterobacter        Male           1 8.146629e-04
#> 32         Escherichia        Male           1 1.717688e-04
#> 33         Haemophilus        Male           1 1.861050e-03
#> 34             Kocuria        Male           1 1.676032e-02
#> 35            Listeria        Male           1 4.135671e-02
#> 36           Moraxella        Male           1 1.825386e-02
#> 37          Mycoplasma        Male           1 0.000000e+00
#> 38  Noviherbaspirillum        Male           1 1.885875e-02
#> 39               Other        Male           1 3.330495e-03
#> 40          Paracoccus        Male           1 1.210947e-04
#> 41         Pseudomonas        Male           1 2.097881e-02
#> 42      Staphylococcus        Male           1 2.859913e-02
#> 43       Streptococcus        Male           1 7.354020e-03
#> 44           Weissella        Male           1 4.140605e-02
#> 45       Acinetobacter      Female           2 2.891848e-01
#> 46           Aeromonas      Female           2 3.293784e-03
#> 47    Alkalihalophilus      Female           2 2.061783e-02
#> 48            Brucella      Female           2 1.184035e-01
#> 49     Corynebacterium      Female           2 2.085925e-01
#> 50       Cutibacterium      Female           2 2.319900e-04
#> 51             Delftia      Female           2 0.000000e+00
#> 52      Dolosigranulum      Female           2 2.334195e-04
#> 53        Enterobacter      Female           2 4.474153e-03
#> 54         Escherichia      Female           2 3.616898e-05
#> 55         Haemophilus      Female           2 7.602519e-03
#> 56             Kocuria      Female           2 5.997889e-02
#> 57            Listeria      Female           2 1.571650e-02
#> 58           Moraxella      Female           2 2.717076e-03
#> 59          Mycoplasma      Female           2 2.120441e-04
#> 60  Noviherbaspirillum      Female           2 5.206077e-02
#> 61               Other      Female           2 1.715177e-03
#> 62          Paracoccus      Female           2 1.221874e-03
#> 63         Pseudomonas      Female           2 2.581273e-02
#> 64      Staphylococcus      Female           2 1.551813e-01
#> 65       Streptococcus      Female           2 2.197573e-02
#> 66           Weissella      Female           2 1.073722e-02
#> 67       Acinetobacter        Male           2 1.999837e-01
#> 68           Aeromonas        Male           2 6.493406e-03
#> 69    Alkalihalophilus        Male           2 4.080035e-02
#> 70            Brucella        Male           2 0.000000e+00
#> 71     Corynebacterium        Male           2 2.927187e-01
#> 72       Cutibacterium        Male           2 0.000000e+00
#> 73             Delftia        Male           2 5.355868e-04
#> 74      Dolosigranulum        Male           2 4.088307e-04
#> 75        Enterobacter        Male           2 1.424023e-02
#> 76         Escherichia        Male           2 0.000000e+00
#> 77         Haemophilus        Male           2 0.000000e+00
#> 78             Kocuria        Male           2 7.883521e-02
#> 79            Listeria        Male           2 8.806327e-03
#> 80           Moraxella        Male           2 9.599653e-03
#> 81          Mycoplasma        Male           2 1.482604e-03
#> 82  Noviherbaspirillum        Male           2 1.252488e-01
#> 83               Other        Male           2 3.985658e-02
#> 84          Paracoccus        Male           2 3.379633e-03
#> 85         Pseudomonas        Male           2 3.334081e-02
#> 86      Staphylococcus        Male           2 1.155584e-01
#> 87       Streptococcus        Male           2 2.810115e-02
#> 88           Weissella        Male           2 6.099738e-04
#> 89       Acinetobacter      Female           3 6.499687e-01
#> 90           Aeromonas      Female           3 2.236433e-03
#> 91    Alkalihalophilus      Female           3 1.882353e-02
#> 92            Brucella      Female           3 2.520446e-02
#> 93     Corynebacterium      Female           3 5.835613e-02
#> 94       Cutibacterium      Female           3 1.988599e-04
#> 95             Delftia      Female           3 0.000000e+00
#> 96      Dolosigranulum      Female           3 4.770992e-04
#> 97        Enterobacter      Female           3 3.162774e-04
#> 98         Escherichia      Female           3 0.000000e+00
#> 99         Haemophilus      Female           3 2.275651e-03
#> 100            Kocuria      Female           3 5.001987e-02
#> 101           Listeria      Female           3 1.093955e-02
#> 102          Moraxella      Female           3 9.422491e-03
#> 103         Mycoplasma      Female           3 0.000000e+00
#> 104 Noviherbaspirillum      Female           3 5.850758e-02
#> 105              Other      Female           3 8.480622e-03
#> 106         Paracoccus      Female           3 7.002915e-04
#> 107        Pseudomonas      Female           3 1.428963e-02
#> 108     Staphylococcus      Female           3 4.560926e-02
#> 109      Streptococcus      Female           3 2.034611e-02
#> 110          Weissella      Female           3 2.382747e-02
#> 111      Acinetobacter        Male           3 3.981444e-01
#> 112          Aeromonas        Male           3 4.853417e-03
#> 113   Alkalihalophilus        Male           3 1.966537e-02
#> 114           Brucella        Male           3 2.308467e-04
#> 115    Corynebacterium        Male           3 3.140045e-01
#> 116      Cutibacterium        Male           3 0.000000e+00
#> 117            Delftia        Male           3 2.364092e-05
#> 118     Dolosigranulum        Male           3 0.000000e+00
#> 119       Enterobacter        Male           3 1.154233e-04
#> 120        Escherichia        Male           3 0.000000e+00
#> 121        Haemophilus        Male           3 4.694783e-03
#> 122            Kocuria        Male           3 5.619978e-02
#> 123           Listeria        Male           3 5.486090e-03
#> 124          Moraxella        Male           3 9.738111e-03
#> 125         Mycoplasma        Male           3 0.000000e+00
#> 126 Noviherbaspirillum        Male           3 7.001699e-02
#> 127              Other        Male           3 2.225028e-05
#> 128         Paracoccus        Male           3 9.047289e-04
#> 129        Pseudomonas        Male           3 2.237977e-02
#> 130     Staphylococcus        Male           3 7.795437e-02
#> 131      Streptococcus        Male           3 9.372974e-03
#> 132          Weissella        Male           3 6.192548e-03
#> 133      Acinetobacter      Female           4 2.452786e-01
#> 134          Aeromonas      Female           4 3.086301e-03
#> 135   Alkalihalophilus      Female           4 3.376783e-02
#> 136           Brucella      Female           4 8.995811e-05
#> 137    Corynebacterium      Female           4 4.324418e-01
#> 138      Cutibacterium      Female           4 0.000000e+00
#> 139            Delftia      Female           4 1.028093e-05
#> 140     Dolosigranulum      Female           4 2.008520e-04
#> 141       Enterobacter      Female           4 4.476406e-05
#> 142        Escherichia      Female           4 9.820426e-06
#> 143        Haemophilus      Female           4 5.577735e-03
#> 144            Kocuria      Female           4 8.218467e-02
#> 145           Listeria      Female           4 6.245263e-03
#> 146          Moraxella      Female           4 1.310476e-03
#> 147         Mycoplasma      Female           4 1.916964e-05
#> 148 Noviherbaspirillum      Female           4 1.018919e-01
#> 149              Other      Female           4 3.873295e-04
#> 150         Paracoccus      Female           4 7.560971e-04
#> 151        Pseudomonas      Female           4 2.241424e-02
#> 152     Staphylococcus      Female           4 5.451741e-02
#> 153      Streptococcus      Female           4 1.804766e-03
#> 154          Weissella      Female           4 7.960703e-03
#> 155      Acinetobacter        Male           4 3.639182e-01
#> 156          Aeromonas        Male           4 3.759683e-03
#> 157   Alkalihalophilus        Male           4 2.856256e-02
#> 158           Brucella        Male           4 1.373995e-02
#> 159    Corynebacterium        Male           4 2.573700e-01
#> 160      Cutibacterium        Male           4 0.000000e+00
#> 161            Delftia        Male           4 0.000000e+00
#> 162     Dolosigranulum        Male           4 1.173147e-03
#> 163       Enterobacter        Male           4 1.602598e-03
#> 164        Escherichia        Male           4 8.383635e-05
#> 165        Haemophilus        Male           4 1.417828e-03
#> 166            Kocuria        Male           4 9.316342e-02
#> 167           Listeria        Male           4 1.135734e-03
#> 168          Moraxella        Male           4 7.655696e-03
#> 169         Mycoplasma        Male           4 0.000000e+00
#> 170 Noviherbaspirillum        Male           4 7.109326e-02
#> 171              Other        Male           4 5.361930e-03
#> 172         Paracoccus        Male           4 7.002801e-04
#> 173        Pseudomonas        Male           4 1.543425e-02
#> 174     Staphylococcus        Male           4 9.262638e-02
#> 175      Streptococcus        Male           4 5.947442e-03
#> 176          Weissella        Male           4 3.525386e-02
#> 177      Acinetobacter      Female           5 4.984428e-01
#> 178          Aeromonas      Female           5 4.407478e-03
#> 179   Alkalihalophilus      Female           5 2.382268e-02
#> 180           Brucella      Female           5 1.965445e-02
#> 181    Corynebacterium      Female           5 7.248403e-02
#> 182      Cutibacterium      Female           5 1.622850e-04
#> 183            Delftia      Female           5 7.631683e-04
#> 184     Dolosigranulum      Female           5 2.855837e-04
#> 185       Enterobacter      Female           5 2.046007e-03
#> 186        Escherichia      Female           5 0.000000e+00
#> 187        Haemophilus      Female           5 1.095410e-02
#> 188            Kocuria      Female           5 8.403286e-02
#> 189           Listeria      Female           5 1.334244e-03
#> 190          Moraxella      Female           5 5.641280e-02
#> 191         Mycoplasma      Female           5 4.057124e-04
#> 192 Noviherbaspirillum      Female           5 7.468856e-02
#> 193              Other      Female           5 1.380452e-02
#> 194         Paracoccus      Female           5 7.857236e-03
#> 195        Pseudomonas      Female           5 2.493605e-02
#> 196     Staphylococcus      Female           5 8.655116e-02
#> 197      Streptococcus      Female           5 5.756125e-03
#> 198          Weissella      Female           5 1.119812e-02
#> 199      Acinetobacter        Male           5 4.782496e-01
#> 200          Aeromonas        Male           5 3.048189e-03
#> 201   Alkalihalophilus        Male           5 1.903549e-02
#> 202           Brucella        Male           5 3.601268e-04
#> 203    Corynebacterium        Male           5 6.770415e-02
#> 204      Cutibacterium        Male           5 0.000000e+00
#> 205            Delftia        Male           5 9.363296e-04
#> 206     Dolosigranulum        Male           5 0.000000e+00
#> 207       Enterobacter        Male           5 4.035776e-03
#> 208        Escherichia        Male           5 0.000000e+00
#> 209        Haemophilus        Male           5 1.645411e-02
#> 210            Kocuria        Male           5 9.284262e-02
#> 211           Listeria        Male           5 8.081554e-04
#> 212          Moraxella        Male           5 1.605611e-02
#> 213         Mycoplasma        Male           5 2.431315e-04
#> 214 Noviherbaspirillum        Male           5 7.839088e-02
#> 215              Other        Male           5 5.470460e-03
#> 216         Paracoccus        Male           5 5.310659e-04
#> 217        Pseudomonas        Male           5 1.962648e-02
#> 218     Staphylococcus        Male           5 1.656998e-01
#> 219      Streptococcus        Male           5 2.097397e-02
#> 220          Weissella        Male           5 9.533558e-03