Create a long data.frame from a MultiAssayExperiment counts object
Source:R/get_long_data.R
get_long_data.Rd
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.
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)
.- log
logical. Indicate whether an assay returned should be the log of whichever assay is specified in
"output_name"
. Ifcounts_to_CPM = TRUE
as well, then a log CPM assay will also be created. Default isFALSE
.- counts_to_CPM
logical. This argument only applies if the
input_type
is a counts assay. IfTRUE
, then the output assays will include a normalized CPM assay. Iflog = TRUE
as well, then a log CPM assay will also be created. Default isTRUE
.
Examples
in_dat <- system.file("extdata/MAE_small.RDS", package = "LegATo") |> readRDS()
out <- get_long_data(in_dat, "genus", log = TRUE, counts_to_CPM = TRUE)
head(out)
#> taxon Sample Subject Sex Month Group Pairing HairLength Age
#> 1 Acinetobacter X-1 S1 Male 1 A 1 48.62753 21.9
#> 2 Acinetobacter X-2 S2 Male 1 B 1 53.53195 67.7
#> 3 Acinetobacter X-3 S3 Female 1 A 2 47.61090 78.9
#> 4 Acinetobacter X-4 S4 Female 1 B 2 49.72870 48.6
#> 5 Acinetobacter X-5 S5 Female 1 A 3 59.04509 48.4
#> 6 Acinetobacter X-6 S6 Female 1 B 3 27.82404 29.6
#> Sample_id Abundance
#> 1 X-1 4518
#> 2 X-2 20029
#> 3 X-3 150813
#> 4 X-4 920
#> 5 X-5 1185
#> 6 X-6 2311