metacoder v0.3.4


Monthly downloads



Tools for Parsing, Manipulating, and Graphing Taxonomic Abundance Data

A set of tools for parsing, manipulating, and graphing data classified by a hierarchy (e.g. a taxonomy).


Build Status Downloads from Rstudio mirror per month Downloads from Rstudio mirror CRAN version

An R package for metabarcoding research planning and analysis

Metacoder is an R package for reading, plotting, and manipulating large taxonomic data sets, like those generated from modern high-throughput sequencing, like metabarcoding (i.e. amplification metagenomics, 16S metagenomics, etc). It provides a tree-based visualization called "heat trees" used to depict statistics for every taxon in a taxonomy using color and size. It also provides various functions to do common tasks in microbiome bioinformatics on data in the taxmap format defined by the taxa package, such as:

  • Summing read counts/abundance per taxon
  • Converting counts to proportions and rarefaction of counts using vegan
  • Comparing the abundance (or other characteristics) of groups of samples (e.g., experimental treatments) per taxon
  • Combining data for groups of samples
  • Simulated PCR, via EMBOSS primersearch, for testing primer specificity and coverage of taxonomic groups
  • Converting common microbiome formats for data and reference databases into the objects defined by the taxa package.
  • Converting to and from the phyloseq format and the taxa format


This project is available on CRAN and can be installed like so:


You can also install the development version for the newest features, bugs, and bug fixes:



All the documentation for metacoder can be found on our website here:


The function that simulates PCR requires primersearch from the EMBOSS tool kit to be installed. This is not an R package, so it is not automatically installed. Type ?primersearch after installing and loading metacoder for installation instructions.

Relationship with other packages

Many of these operations can be done using other packages like phyloseq, which also provides tools for diversity analysis. The main strength of metacoder is that its functions use the flexible data types defined by taxa, which has powerful parsing and subsetting abilities that take into account the hierarchical relationship between taxa and user-defined data. In general, metacoder and taxa are more of an abstracted tool kit, whereas phyloseq has more specialized functions for community diversity data, but they both can do similar things. I encourage you to try both to see which fits your needs and style best. You can also combine the two in a single analysis by converting between the two data types when needed.


If you use metacoder in a publication, please cite our article in PLOS Computational Biology:

Foster ZSL, Sharpton TJ, Grünwald NJ (2017) Metacoder: An R package for visualization and manipulation of community taxonomic diversity data. PLOS Computational Biology 13(2): e1005404.

Future development

Metacoder is under active development and many new features are planned. Some improvements that are being explored include:

  • Barcoding gap analysis and associated plotting functions
  • A function to aid in retrieving appropriate sequence data from NCBI for in silico PCR from whole genome sequences
  • Graphing of different node shapes in heat trees, possibly including pie graphs or PhyloPics.
  • Adding the ability to plot specific edge lengths in the heat trees so they can be used for phylogenetic trees.
  • Adding more data import and export functions to make parsing and writing common formats easier.

To see the details of what is being worked on, check out the issues tab of the Metacoder Github site.


This work is subject to the MIT License.


Metacoder's major dependencies are taxa, taxize, vegan, igraph, dplyr, and ggplot2.

This package includes code from the R package ggrepel to handle label overlap avoidance with permission from the author of ggrepel Kamil Slowikowski. We included the code instead of depending on ggrepel because we are using functions internal to ggrepel that might change in the future. We thank Kamil Slowikowski for letting us use his code and would like to acknowledge his implementation of the label overlap avoidance used in metacoder.

Feedback and contributions

We would like to hear about users' thoughts on the package and any errors they run into. Please report errors, questions or suggestions on the issues tab of the Metacoder Github site. We also welcome contributions via a Github pull request. You can also talk with us using our Google groups site.

Functions in metacoder

Name Description
calc_group_rsd Relative standard deviations of groups of columns
compare_groups Compare groups of samples
as_phyloseq Convert taxmap to phyloseq
apply_color_scale Covert numbers to colors
counts_to_presence Apply a function to groups of columns
calc_n_samples Count the number of samples
calc_obs_props Calculate proportions from observation counts
calc_group_mean Calculate means of groups of columns
calc_group_median Calculate medians of groups of columns
convert_base Converts decimal numbers to other bases
diverging_palette The default diverging color palette
get_numeric_cols Get numeric columns from taxmap table
get_node_children get_node_children
check_for_pkg check for packages
heat_tree Plot a taxonomic tree
ends_with dplyr select_helpers
do_calc_on_num_cols Run some function to produce new columns.
check_element_length Check length of graph attributes
heat_tree_matrix Plot a matrix of heat trees
everything dplyr select_helpers
get_numerics Return numeric values in a character
get_class_from_el Get classification for taxa in edge list
get_optimal_range Find optimal range
hmp_samples Sample information for HMP subset
hmp_otus A HMP subset
inverse Generate the inverse of a function
make_dada2_asv_table Make a imitation of the dada2 ASV abundance matrix
make_dada2_tax_table Make a imitation of the dada2 taxonomy matrix
map_unique Run a function on unique values of a iterable
get_taxmap_table Get a table from a taxmap object
parse_dada2 Convert the output of dada2 to a taxmap object
is_ambiguous Find ambiguous taxon names
inter_circle_gap Finds the gap/overlap of circle coordinates
DNAbin_to_char Converts DNAbin to a named character vector
metacoder Metacoder
parse_mothur_tax_summary Parse mothur *.tax.summary Classify.seqs output
get_taxmap_other_cols Parse the other_cols option
primersearch Use EMBOSS primersearch for in silico PCR
matches dplyr select_helpers
ncbi_taxon_sample Download representative sequences for a taxon
one_of dplyr select_helpers
get_edge_children get_edge_children
add_alpha add_alpha
label_bounds Bounding box coords for labels
parse_mothur_taxonomy Parse mothur Classify.seqs *.taxonomy output
can_be_num Test if characters can be converted to numbers
molten_dist Get all distances between points
parse_unite_general Parse UNITE general release FASTA
ambiguous_synonyms Get patterns for ambiguous taxa
primersearch_is_installed Test if primersearch is installed
parse_greengenes Parse Greengenes release
calc_prop_samples Calculate the proportion of samples
num_range dplyr select_helpers
parse_edge_list Convert a table with an edge list to taxmap
rev_comp Revere complement sequences
.onAttach Run when package loads
edge_list_depth Get distance from root of edgelist observations
reverse Reverse sequences
complement Find complement of sequences
calc_taxon_abund Sum observation values for each taxon
ambiguous_patterns Get patterns for ambiguous taxa
quantative_palette The default quantative color palette
select_labels Pick labels to show
capitalize Capitalize
polygon_coords Makes coordinates for a regular polygon
parse_silva_fasta Parse SILVA FASTA release
rarefy_obs Calculate rarefied observation counts
read_fasta Read a FASTA file
parse_seq_input Read sequences in an unknown format
get_edge_parents get_edge_parents
starts_with dplyr select_helpers
contains dplyr select_helpers
startup_msg Return startup message
read_lines_apply Apply a function to chunks of a file
filter_ambiguous_taxa Filter ambiguous taxon names
write_greengenes Write an imitation of the Greengenes database
fasta_headers Get line numbers of FASTA headers
verify_size Verify size parameters
get_expected_data Get a data set in as_phyloseq
get_taxmap_cols Get a column subset
text_grob_length Estimate text grob length
verify_trans Verify transformation function parameters
layout_functions Layout functions
write_silva_fasta Write an imitation of the SILVA FASTA database
transform_data Transformation functions
get_taxonomy_levels Get taxonomy levels
zero_low_counts Replace low counts with zero
%>% magrittr forward-pipe operator
write_unite_general Write an imitation of the UNITE general FASTA database
my_print Print something
look_for_na Look for NAs in parameters
make_fasta_with_u_replaced Make a temporary file U's replaced with T
limited_print Print a subset of a character vector
get_taxmap_data Get a data set from a taxmap object
verify_label_count Verify label count
ncbi_sequence Downloads sequences from ids
parse_phyloseq Convert a phyloseq to taxmap
make_plot_legend Make color/size legend
line_coords Makes coordinates for a line
parse_primersearch Parse EMBOSS primersearch output
parse_summary_seqs Parse summary.seqs output
split_by_level Splits a taxonomy at a specific level or rank
parse_ubiome Converts the uBiome file format to taxmap
qualitative_palette The default qualitative color palette
primersearch_raw Use EMBOSS primersearch for in silico PCR
parse_newick Parse a Newick file
parse_phylo Parse a phylo object
unique_mapping get indexes of a unique set of the input
write_mothur_taxonomy Write an imitation of the Mothur taxonomy file
write_rdp Write an imitation of the RDP FASTA database
parse_qiime_biom Parse a BIOM output from QIIME
verify_color_range Verify color range parameters
parse_rdp Parse RDP FASTA release
repo_url Return github url
rescale Rescale numeric vector to have specified minimum and maximum.
run_primersearch Execute EMBOSS Primersearch
scale_bar_coords Make scale bar division
verify_size_range Verify size range parameters
verify_taxmap Check that an object is a taxmap
check_option_groups Check option: groups
calc_group_stat Apply a function to groups of columns
No Results!

Vignettes of metacoder

No Results!

Last month downloads


License GPL-2 | GPL-3
LazyData true
VignetteBuilder knitr
RoxygenNote 7.1.0
Date 2020-04-28
Encoding UTF-8
LinkingTo Rcpp
NeedsCompilation yes
Packaged 2020-04-29 19:16:09 UTC; fosterz
Repository CRAN
Date/Publication 2020-04-29 19:40:03 UTC

Include our badge in your README