R/function_fungal_abundance_tree.R

Defines functions fung_abund_tree

Documented in fung_abund_tree

#' Visualize fungal abundance from all samples in taxmap object
#'
#' @param obj_complete taxmap object containing tax_data, class_data, taxon_abundance, and tax_sample tibbles
#' @importFrom assertthat assert_that
#' @importFrom magrittr %>%
#' @importFrom phyloseq filter_taxa
#' @importFrom taxa filter_taxa
#' @importFrom metacoder heat_tree
#'
#' @export
#'


fung_abund_tree <- function(obj_complete) {
  assertthat::assert_that(is.object(obj_complete))
  obj_complete %>%
    filter_taxa(grepl(pattern = "^[a-zA-Z]+$", taxon_names)) %>%
    filter_taxa(taxon_names %in% ("Fungi"), subtaxa = TRUE) %>%
    taxa::filter_taxa(n_obs > 1) %>%
    heat_tree(node_label = taxon_names,
              node_size = n_obs,
              node_color = n_obs,
              title = "Sample read depth",
              title_size = 0.05,
              node_size_range = c(0.01, 0.05),
              edge_size_range = c(0.005, 0.005),
              node_size_axis_label = "OTU count",
              initial_layout = "re", layout = "da")
}
arielebanks/ebanks.package documentation built on Dec. 31, 2020, 7:50 p.m.