metacoder (version 0.2.1)

heat_tree_matrix: Plot a matrix of heat trees

Description

Plot a matrix of heat trees for showing parwise comparisons. A larger, labelled tree serves as a key for the matrix of smaller unlabelled trees. The data for this function is typically created with compare_groups,

Usage

heat_tree_matrix(obj, dataset, label_small_trees = FALSE, key_size = 0.6,
  seed = 1, output_file = NULL, ...)

Arguments

obj

A taxmap object

dataset

The name of a table in obj$data that is the output of compare_groups or in the same format.

label_small_trees

If TRUE add labels to small trees as well as the key tree. Otherwise, only the key tree will be labeled.

key_size

The size of the key tree relative to the whole graph. For example, 0.5 means half the width/height of the graph.

seed

That random seed used to make the graphs.

output_file

The path to one or more files to save the plot in using ggsave. The type of the file will be determined by the extension given. Default: Do not save plot.

...

Passed to heat_tree. Some options will be overwritten.

Examples

Run this code
# NOT RUN {
# Parse dataset for plotting
x <- parse_tax_data(hmp_otus, class_cols = "lineage", class_sep = ";",
                    class_key = c(tax_rank = "info", tax_name = "taxon_name"),
                    class_regex = "^(.+)__(.+)$")

# Convert counts to proportions
x$data$otu_table <- calc_obs_props(x, dataset = "tax_data", cols = hmp_samples$sample_id)

# Get per-taxon counts
x$data$tax_table <- calc_taxon_abund(x, dataset = "otu_table", cols = hmp_samples$sample_id)

# Calculate difference between treatments
x$data$diff_table <- compare_groups(x, dataset = "tax_table",
                                    cols = hmp_samples$sample_id,
                                    groups = hmp_samples$body_site)

# Plot results (might take a few minutes)
heat_tree_matrix(x,
                 dataset = "diff_table",
                 node_size = n_obs,
                 node_label = taxon_names,
                 node_color = log2_median_ratio,
                 node_color_range = diverging_palette(),
                 node_color_trans = "linear",
                 node_color_interval = c(-3, 3),
                 edge_color_interval = c(-3, 3),
                 node_size_axis_label = "Number of OTUs",
                 node_color_axis_label = "Log2 ratio median proportions")

# }
# NOT RUN {
# }

Run the code above in your browser using DataCamp Workspace