physeq {chem16S} | R Documentation |
Process 'phyloseq-class' objects to calculate chemical metrics
Description
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.
Usage
ps_taxacounts(physeq, split = TRUE)
ps_metrics(physeq, split = TRUE, refdb = "GTDB_220", quiet = FALSE, ...)
plot_ps_metrics(physeq, metrics = c("Zc", "nO2", "nH2O"), x = "samples",
color = NULL, shape = NULL, title = NULL,
scales = "free_y", nrow = 1, sortby = NULL, ...)
plot_ps_metrics2(physeq, metrics = c("Zc", "nH2O"), color = NULL,
shape = NULL, title = NULL, refdb = "GTDB_220", quiet = FALSE)
Arguments
physeq |
'phyloseq-class', a phyloseq object containing an 'otu_table' and 'tax_table' |
split |
logical, calculate metrics for each sample (TRUE) or the entire set (FALSE) |
refdb |
character, name of reference database (passed to |
quiet |
logical, suppress printed messages? (passed to |
... |
additional arguments passed to |
metrics |
character, chemical metrics to calculate |
x |
map this variable to the horizontal axis |
color |
map this variable to colors |
shape |
map this variable to shapes |
title |
main title for the plot |
scales |
‘free_y’ or ‘fixed’ for different vertical scales or same scale in each panel |
nrow |
number of rows of panels (passed to |
sortby |
subset of |
Details
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
.
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.
The metrics
argument is passed to get_metrics
and selects the metrics to calculate.
split
, refdb
, and quiet
can also be used as additional arguments in plot_ps_metrics
and plot_ps_metrics2
.
Value
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.
Author(s)
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.
Examples
# Example 1: Humboldt Sulfuretum (Fonseca et al., 2022)
# This file has the classifications made with DADA2 using 16S rRNA sequences from GTDB r214
file <- system.file("extdata/DADA2-GTDB_214/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 to GTDB r220
# NOTE: for the time being, reference proteomes (r220) are from a later version
# of the GTDB than the 16S rRNA classifications (r214)
map <- map_taxa(taxacounts, refdb = "GTDB_220")
# Taxonomy and reference proteomes are from different versions of GTDB,
# so there is a small percentage of unmapped classifications
sum(attr(map, "unmapped_percent"))
# Calculate chemical metrics
ps_metrics(physeq, refdb = "GTDB_220")
# 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_206")
# Change orientation of x-axis labels
p + ggplot2::theme(axis.text.x = ggplot2::element_text(
angle = 45, vjust = 1, hjust = 1))