Calculate chemical metrics of community reference proteomes from taxonomic abundances in phyloseq-class
objects and make plots of individual metrics or two metrics against each other.
ps_taxacounts(physeq, split = TRUE)
ps_metrics(physeq, split = TRUE, refdb = "GTDB", quiet = FALSE, ...)
plot_ps_metrics(physeq, x = "samples", color = NULL, shape = NULL,
title = NULL, scales = "free_y", nrow = 1,
metrics = c("Zc", "nO2", "nH2O"), sortby = NULL, refdb = "GTDB",
quiet = FALSE)
plot_ps_metrics2(physeq, x = "Zc", y = "nH2O", color = NULL,
shape = NULL, title = NULL, refdb = "GTDB", quiet = FALSE)
For ps_taxacounts
, a data frame with samples in rows, and columns taxid
(sample name taken from the OTU table obtained from otu_table(physeq)
), lineage
(all taxonomic names from the taxonomy table obtained from tax_table(physeq)
, separated by semicolons), name
(lowest-level taxonomic name), rank
(rank of lowest-level taxon), followed by the abundances from the OTU table.
For ps_metrics
, a data frame with samples in rows, and columns corresponding to each of the metrics
.
For plot_ps_metrics
and plot_ps_metrics2
, ggplot objects.
`phyloseq-class`, a phyloseq object containing an `otu_table` and `tax_table`
logical, calculate metrics for each sample (TRUE) or the entire set (FALSE)
character, name of reference database (GTDB or RefSeq; passed to get_metrics
)
logical, suppress printed messages? (passed to map_taxa
)
additional arguments for get_metrics
map this variable to the horizontal axis
map this variable to colors
map this variable to shapes
main title for the plot
free_y or fixed for different vertical scales or same scale in each panel
number of rows of panels (passed to facet_wrap
)
character, chemical metrics to calculate
subset of metrics
argument, sort x-index by the mean values of these metrics
map this variable to the vertical axis
The author of this Rd file and the ps_taxacounts
and ps_metrics
functions is Jeffrey Dick.
plot_ps_metrics
is based on the plot_richness
function by Paul J. McMurdie and was modified from that function by Jeffrey Dick.
ps_taxacounts
returns a data frame with lowest-level classifications (from genus to phylum) and abundances for each OTU in the physeq
object.
ps_metrics
calculates chemical metrics of community reference proteomes from the lowest-level classifications after taxonomic mapping with map_taxa
.
To choose the metrics to calculate, use the metrics
argument, which is passed via ...
to get_metrics
.
plot_ps_metrics
plots individual chemical metrics or multiple chemical metrics, each in their own panel.
This function is modified from plot_richness
; see that help page for further details about graphics-related arguments.
plot_ps_metrics2
plot two chemical metrics against each other.
# Example 1: Humboldt Sulfuretum (Fonseca et al., 2022)
file <- system.file("extdata/DADA2/FEN+22/ps_FEN+22.rds", package = "chem16S")
physeq <- readRDS(file)
# Get lowest-level (to genus) classification for each OTU
taxacounts <- ps_taxacounts(physeq)
# Show numbers of assignments at each taxonomic level
table(taxacounts$rank)
# Map taxonomic names
map <- map_taxa(taxacounts)
# Taxonomy and reference proteomes are both from GTDB,
# so there are no unmapped classifications
sum(attr(map, "unmapped_percent")) # == 0
# Calculate chemical metrics
ps_metrics(physeq)
# Example 2: GlobalPatterns dataset from phyloseq
data(GlobalPatterns, package = "phyloseq")
# Plot metrics grouped by sample type and sorted by mean Zc;
# refdb = "RefSeq" uses manual mappings from the RDP to NCBI taxonomy
p <- plot_ps_metrics(GlobalPatterns, x = "SampleType",
sortby = "Zc", refdb = "RefSeq")
# Change orientation of x-axis labels
p + ggplot2::theme(axis.text.x = ggplot2::element_text(
angle = 45, vjust = 1, hjust = 1))
Run the code above in your browser using DataLab