R/veganotu.R

Defines functions veganotu

Documented in veganotu

#' Extract Vegan OTU Table
#'
#' Extracts a vegan compatible OTU table from a phyloseq object.
#'
#' @param physeq A phyloseq object contaning at least an OTU table.
#'
#' @return A matrix with samples in rows and OTUs in columns.
#' @export
#'
#' @examples
#'
#' @importFrom phyloseq otu_table
#' @importFrom phyloseq taxa_are_rows
#'
veganotu <-
function(physeq) {
    OTU <- otu_table(physeq)
    if (taxa_are_rows(OTU)) {
        OTU <- t(OTU)
    }
    OTU <- as(OTU, "matrix")
    return(OTU)
}
jfq3/QsRutils documentation built on Jan. 18, 2021, 12:40 a.m.