convert | R Documentation |
For convenience, a few functions are available to convert BIOM, DADA2 and
phyloseq objects to
TreeSummarizedExperiment
objects, and
TreeSummarizedExperiment
objects to phyloseq objects.
convertFromBIOM(
x,
prefix.rm = removeTaxaPrefixes,
removeTaxaPrefixes = FALSE,
rank.from.prefix = rankFromPrefix,
rankFromPrefix = FALSE,
artifact.rm = remove.artifacts,
remove.artifacts = FALSE,
...
)
convertToBIOM(x, assay.type = "counts", ...)
## S4 method for signature 'SummarizedExperiment'
convertToBIOM(x, assay.type = "counts", ...)
convertFromDADA2(...)
convertFromPhyloseq(x)
convertToPhyloseq(x, ...)
## S4 method for signature 'SummarizedExperiment'
convertToPhyloseq(x, assay.type = "counts", assay_name = NULL, ...)
## S4 method for signature 'TreeSummarizedExperiment'
convertToPhyloseq(x, tree.name = tree_name, tree_name = "phylo", ...)
x |
a
|
prefix.rm |
|
removeTaxaPrefixes |
Deprecated. Use |
rank.from.prefix |
|
rankFromPrefix |
Deprecated.Use |
artifact.rm |
|
remove.artifacts |
Deprecated. Use |
... |
Additional arguments. For |
assay.type |
A single character value for selecting the
|
assay_name |
a single |
tree.name |
a single |
tree_name |
Deprecated. Use |
convertFromBIOM
coerces a BIOM object to a
TreeSummarizedExperiment
object.
convertFromBIOM
coerces a
TreeSummarizedExperiment
object to a biom
object.
convertFromDADA2
is a wrapper for the
mergePairs
function from the dada2
package.
A count matrix is constructed via
makeSequenceTable(mergePairs(...))
and rownames are dynamically
created as ASV(N)
with N
from 1 to nrow
of the count
tables. The colnames and rownames from the output of makeSequenceTable
are stored as colnames
and in the referenceSeq
slot of the
TreeSummarizedExperiment
, respectively.
convertFromPhyloseq
converts phyloseq
objects into
TreeSummarizedExperiment
objects.
All data stored in a phyloseq
object is transferred.
convertToPhyloseq
creates a phyloseq object from a
TreeSummarizedExperiment
object. By using assay.type
, it is possible to specify which table
from assay
is added to the phyloseq object.
convertFromBIOM
returns an object of class
TreeSummarizedExperiment
convertFromDADA2
returns an object of class
TreeSummarizedExperiment
convertFromPhyloseq
returns an object of class
TreeSummarizedExperiment
convertToPhyloseq
returns an object of class
phyloseq
Leo Lahti and Tuomas Borman. Contact: microbiome.github.io
importQIIME2
importMothur
# Convert BIOM results to a TreeSE
# Load biom file
library(biomformat)
biom_file <- system.file("extdata", "rich_dense_otu_table.biom",
package = "biomformat")
# Make TreeSE from BIOM object
biom_object <- biomformat::read_biom(biom_file)
tse <- convertFromBIOM(biom_object)
# Convert TreeSE object to BIOM
biom <- convertToBIOM(tse)
### Coerce DADA2 results to a TreeSE object
if(requireNamespace("dada2")) {
fnF <- system.file("extdata", "sam1F.fastq.gz", package="dada2")
fnR = system.file("extdata", "sam1R.fastq.gz", package="dada2")
dadaF <- dada2::dada(fnF, selfConsist=TRUE)
dadaR <- dada2::dada(fnR, selfConsist=TRUE)
tse <- convertFromDADA2(dadaF, fnF, dadaR, fnR)
tse
}
### Coerce a phyloseq object to a TreeSE object
if (requireNamespace("phyloseq")) {
data(GlobalPatterns, package="phyloseq")
convertFromPhyloseq(GlobalPatterns)
data(enterotype, package="phyloseq")
convertFromPhyloseq(enterotype)
data(esophagus, package="phyloseq")
convertFromPhyloseq(esophagus)
}
### Coerce a TreeSE object to a phyloseq object
# Get tse object
data(GlobalPatterns)
tse <- GlobalPatterns
# Create a phyloseq object from it
phy <- convertToPhyloseq(tse)
phy
# By default the chosen table is counts, but if there are other tables,
# they can be chosen with assay.type.
# Counts relative abundances table
tse <- transformAssay(tse, method = "relabundance")
phy2 <- convertToPhyloseq(tse, assay.type = "relabundance")
phy2
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.