% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/SE-methods.R
\name{biom_to_SummarizedExperiment}
\alias{biom_to_SummarizedExperiment}
\title{Convert a biom object to a SummarizedExperiment}
\usage{
biom_to_SummarizedExperiment(x)
}
\arguments{
\item{x}{A \code{\link{biom-class}} object.}
}
\value{
A \code{\link[SummarizedExperiment]{SummarizedExperiment}} with:
\describe{
  \item{\code{assay("counts")}}{The feature-by-sample count (or value)
    matrix returned by \code{\link{biom_data}}.}
  \item{\code{colData()}}{Per-sample metadata from
    \code{\link{sample_metadata}}, or an empty \code{DataFrame}.}
  \item{\code{rowData()}}{Per-feature metadata from
    \code{\link{observation_metadata}}, or an empty \code{DataFrame}.}
}
}
\description{
Converts a \code{\link{biom-class}} object into a
\code{\link[SummarizedExperiment]{SummarizedExperiment}}, placing the
count/value matrix in \code{assay(., "counts")}, sample metadata in
\code{colData()}, and observation/feature metadata in \code{rowData()}.
}
\details{
Both \code{colData} and \code{rowData} are coerced to
\code{\link[S4Vectors]{DataFrame}}.  When a biom object carries no sample or
observation metadata (i.e. the corresponding accessor returns \code{NULL}),
an empty \code{DataFrame} with the correct row names is substituted so that
the resulting \code{SummarizedExperiment} is always fully valid.
}
\examples{
biom_file <- system.file("extdata", "rich_sparse_otu_table.biom",
                         package = "biomformat")
x <- read_biom(biom_file)
if (requireNamespace("SummarizedExperiment", quietly = TRUE)) {
  se <- biom_to_SummarizedExperiment(x)
  se
  # S4 coercion syntax also works:
  se2 <- as(x, "SummarizedExperiment")
  identical(SummarizedExperiment::assay(se), SummarizedExperiment::assay(se2))
}
}
\seealso{
\code{\link{read_biom}}, \code{\link{biom_data}},
\code{\link{sample_metadata}}, \code{\link{observation_metadata}}
}
