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, ...)

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

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

Arguments

x

a TreeSummarizedExperiment object.

...

additional arguments:

  • rowdata.file: Character scalar. Specifies the file where rowData should be written. (Default: "rowData")

  • coldata.file: Character scalar. Specifies the file where colData should be written. (Default: "colData")

  • assay.dir: Character scalar. Specifies the file where assays should be written. (Default: "assays")

  • refseq.file: Character scalar. Specifies the file where referenceSeq should be written. (Default: "referenceSeq")

  • rowtree.dir: Character scalar. Specifies the file where rowTrees should be written. (Default: "rowTrees")

  • coltree.dir: Character scalar. Specifies the file where colTrees should be written. (Default: "colTrees")

  • dimred.dir: Character scalar. Specifies the file where reducedDims should be written. (Default: "reducedDims")

  • altexp.dir: Character scalar. Specifies the file where altExps should be written. (Default: "altExps")

dpath

Character scalar. String specifying the directory where x should be exported. If non-existent, it is created recursively.

assay.type

Character scalar. String specifying which assay should be exported. Only for exportQIIME2 and exportMothur. (Default: "counts")

tree.name

Character scalar. String specifying which row tree should be exported. Only for exportQIIME2 and exportMothur. (Default: "phylo")

group.var

Character scalar. String specifying one variable of rowData to export as a custom grouping file. Only for exportQIIME2 and exportMothur. (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

# Generate example TreeSE object
tse <- makeTSE()
# Give name to counts assay
assayNames(tse) <- "counts"
# Give name to taxonomy variable
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")
#> Warning: 'group' is a reserved name in Mothur. colData variables with that name were made unique.