There are a few very popular external tools for microbiome analysis, including QIIME2 and mothur. However, R does not currently provide any class to accommodate those data formats. When exporting data from mia to external tools, the best approach is therefore to break a data container into its building blocks (assays, side information, trees, etc.).

Thanks to exportRaw, exportQIIME2 and exportMothur, it is now possible to export a TreeSummarizedExperiment object as raw elements or near-ready QIIME2 and mothur formats, respectively. This way, migrating from mia to an external system is still a bad idea, but at least it is fairly straightforward.

exportRaw(x, ...)

exportQIIME2(x, ...)

exportMothur(x, ...)

# S4 method for class 'TreeSummarizedExperiment'
exportRaw(
  x,
  dpath,
  rowdata.file = "rowdata",
  coldata.file = "coldata",
  assay.dir = "assays",
  rowtree.dir = "row_trees",
  coltree.dir = "col_trees",
  dimred.dir = "dim_reds",
  altexp.dir = "alt_exps"
)

# S4 method for class 'TreeSummarizedExperiment'
exportQIIME2(x, dpath, assay.type = "counts", tree.name = "phylo")

# S4 method for class 'TreeSummarizedExperiment'
exportMothur(
  x,
  dpath,
  assay.type = "counts",
  tree.name = "phylo",
  group.var = NULL
)

Arguments

x

a TreeSummarizedExperiment object.

...

Unused.

dpath

Character scalar.

rowdata.file

Character scalar. (Default: "rowdata")

coldata.file

Character scalar. (Default: "coldata")

assay.dir

Character scalar. (Default: "assays")

rowtree.dir

Character scalar. (Default: "row_trees")

coltree.dir

Character scalar. (Default: "col_trees")

dimred.dir

Character scalar. (Default: "dim_reds")

altexp.dir

Character scalar. (Default: "alt_exps")

assay.type

Character scalar. (Default: "counts")

tree.name

Character scalar. (Default: "phylo")

group.var

Character scalar. (Default: NULL)

Value

Directory at dpath with components of x each stored as a file in the proper format.

Details

The output directory contains the elements of x. For exportQIIME2 and exportMothur, data will need some more processing using the target tool. For some tips, check the rbiom package vignettes on converting data: https://cmmr.github.io/rbiom/articles/convert.html

Examples

library(TreeSummarizedExperiment)

tse <- makeTSE()
assayNames(tse) <- "counts"
names(rowData(tse))[1] <- "Genus"

# Export raw TreeSE components in custom directory
exportRaw(tse, "out")

# Export TreeSE components in near-ready QIIME2 format
exportQIIME2(tse, "qiime2_dir")

# Export TreeSE components in near-ready mothur format
exportMothur(tse, "mothur_dir")