Skip to contents

create_tidytacos() returns a tidytacos object given a numeric matrix.

Usage

create_tidytacos(counts_matrix, taxa_are_columns = TRUE)

Arguments

counts_matrix

Numerical matrix containing the count data.

taxa_are_columns

A logical scalar. Are the taxa defined in columns?

Value

A tidytacos object.

Details

This function initiates a tidytacos object based on a numeric matrix. It will automatically create a dummy taxa table and sample table which will need to be updated using the function add_metadata(). When the taxa table is updated, the rank names can be set using the function set_rank_names() to make the tidytacos object aware of the taxonomy levels.

See also

Other import-methods: from_dada(), from_phyloseq(), read_tidytacos()

Examples

# Initiate count matrix
x <- matrix(
  c(1500, 1300, 280, 356),
  ncol = 2
)
rownames(x) <- c("taxon1", "taxon2")
colnames(x) <- c("sample1", "sample2")

# Convert to tidytacos object
data <- create_tidytacos(x,
  taxa_are_columns = FALSE
)
# Add taxonomy information
taxonomy <- tibble::tibble(
  taxon = c("taxon1", "taxon2"),
  domain = c("Bacteria", "Bacteria"),
  phylum = c("Bacillota", "Pseudomonadota"),
  class = c("Bacilli", "Gammaproteobacteria"),
  order = c("Lactobacillales", "Enterobacteriales"),
  family = c("Lactobacillaceae", "Enterobacteriaceae"),
  genus = c("Lactobacillus", "Escherichia"),
  species = c("Lactobacillus crispatus", "Escherichia coli")
)

data <- add_metadata(data, taxonomy, table_type = "taxa")
#> Joining with `by = join_by(taxon)`
#> Warning: Not all default rank names found. Replacing them with:
#>  c("domain","phylum","class","order","family","genus","species")
#> 
#> If these are not the rank names of your taxon table in descending order, 
#> please set them manually using 'set_rank_names()'
# rank names are inferred from the taxa table, but can be set manually
# if we're not happy with the inferred rank names.
data <- set_rank_names(data, c("domain", "phylum", "class", "order", "family", "genus"))