Skip to contents

Convert a microbiome_dataset into a taxonomic-rank long table by aggregating abundance at a chosen rank and attaching sample_info.

Usage

psmelt_taxa(
  object,
  taxonomic_rank = c("Kingdom", "Phylum", "Class", "Order", "Family", "Genus", "Species"),
  relative = TRUE,
  what = c("sum_intensity", "mean_intensity", "median_intensity"),
  na.rm = TRUE,
  value_name = "abundance"
)

Arguments

object

A microbiome_dataset object.

taxonomic_rank

Taxonomic rank used for aggregation.

relative

Should abundance be expressed as relative abundance?

what

Aggregation method used within each rank.

na.rm

Should missing values be removed before aggregation?

value_name

Name of the abundance column in the output.

Value

A data frame in long format.

Examples

data("global_patterns", package = "microbiomedataset")

x <- psmelt_taxa(global_patterns, taxonomic_rank = "Genus")
head(x[, c("sample_id", "Genus", "abundance")])
#>   sample_id         Genus    abundance
#> 1    AQC1cm          4-29 0.5340725502
#> 2    AQC1cm      4041AA30 0.0000000000
#> 3    AQC1cm           A17 0.8746237084
#> 4    AQC1cm   Abiotrophia 0.0000000000
#> 5    AQC1cm Acaryochloris 0.0052303079
#> 6    AQC1cm   Acetivibrio 0.0005811453

y <- psmelt_taxa(global_patterns, taxonomic_rank = "Phylum", relative = TRUE)
head(y[, c("sample_id", "Phylum", "abundance")])
#>   sample_id          Phylum    abundance
#> 1    AQC1cm        ABY1_OD1 0.0005138174
#> 2    AQC1cm             AC1 0.0021409059
#> 3    AQC1cm             AD3 0.0002569087
#> 4    AQC1cm   Acidobacteria 1.2521730194
#> 5    AQC1cm  Actinobacteria 2.2601114984
#> 6    AQC1cm Armatimonadetes 0.0690228049