Learn R Programming

chem16S (version 1.0.0)

plot_metrics: Plot chemical metrics of community reference proteomes

Description

Functions to plot chemical metrics of community reference proteomes.

Usage

plot_metrics(mdat, identify = FALSE, title = TRUE,
    xlim = NULL, ylim = NULL, plot.it = TRUE, points = TRUE, lines = FALSE,
    cex = 1, pch1 = 1, pch2 = 21, return = "data",
    extracolumn = NULL, add = FALSE, pt.open.col = 1,
    xlab = chemlab("Zc"), ylab = chemlab("nH2O"))
  add_hull(x, y, basecol, outline = FALSE, ...)

Value

For plot_metrics, a data frame with columns with study name and Run IDs (name, Run), plotting values (nH2O, Zc), and plotting symbols and colors (pch, col). For add_hull, no return value (called for side effects).

Arguments

mdat

list, output by get_metadata

identify

logical, run identify for interactive identification of points?

title

character, plot title

xlim

numeric, x axis limits

ylim

numeric, y axis limits

plot.it

logical, make a plot?

points

logical, plot points?

lines

logical, plot lines?

cex

numeric, point size

pch1

numeric, symbol for samples in group 1

pch2

numeric, symbol for samples in group 2

return

character, indicates whether to return data values or group means

extracolumn

character, the name of one or more extra columns (from get_metadata) to include in the output

add

logical, add to existing plot?

pt.open.col

color of border for open point symbols (pch > 20)

xlab

x axis label

ylab

y axis label

x

x values

y

y values

basecol

color used for hull lines

outline

logical, draw hull lines?

...

arguments passed to polygon

Details

plot_metrics plots the ZC and nH2O values provided in mdat$metrics. Symbol shape and color (pch and col) are taken from mdat$metadata.

If pch1 and pch2 are provided, then samples are classified into two groups according to the value of mdat$metadata$pch. Mean values of the chemical metrics for each group are plotted with star-shaped symbols.

add_hull uses polygon to draw a convex hull around the points given in x, y. The lines are drawn only if outline is TRUE; otherwise, the area of the hull is filled. The fill color is a semi-transparent version of the color given in basecol.

References

Herlemann, D. P. R., Lundin, D., Andersson, A. F., Labrenz, M. and Jürgens, K. (2016) Phylogenetic signals of salinity and season in bacterial community composition across the salinity gradient of the Baltic Sea. Front. Microbiol. 7, 1883. tools:::Rd_expr_doi("10.3389/fmicb.2016.01883")

Examples

Run this code
# Make a plot for the Baltic Sea salinity gradient
# (data from Herlemann et al., 2016)
RDPfile <- system.file("extdata/RDP/HLA+16.tab.xz", package = "chem16S")
RDP <- read_RDP(RDPfile)
map <- map_taxa(RDP, refdb = "RefSeq")
metrics <- get_metrics(RDP, map, refdb = "RefSeq")
mdatfile <- system.file("extdata/metadata/HLA+16.csv", package = "chem16S")
mdat <- get_metadata(mdatfile, metrics)
pm <- plot_metrics(mdat)
# Add a legend
legend <- c("< 6 PSU", "6-20 PSU", "> 20 PSU")
pch <- c(24, 20, 21)
pt.bg <- c(3, NA, 4)
legend("bottomright", legend, pch = pch, col = 1, pt.bg = pt.bg, bg = "white")
# Classify samples with low and high salinity
ilo <- mdat$metadata$salinity < 6
ihi <- mdat$metadata$salinity > 20
# Add convex hulls
add_hull(pm$Zc[ilo], pm$nH2O[ilo], "green3")
add_hull(pm$Zc[ihi], pm$nH2O[ihi], "blue")

# Show points for all samples and larger star-shaped points
# for mean values of high- and low-salinity samples
plot_metrics(mdat, pch1 = 21, pch2 = 24)

# Make a plot for only Proteobacteria
RDP <- read_RDP(RDPfile, lineage = "Proteobacteria")
map <- map_taxa(RDP, refdb = "RefSeq")
metrics <- get_metrics(RDP, map, refdb = "RefSeq")
mdatfile <- system.file("extdata/metadata/HLA+16.csv", package = "chem16S")
mdat <- get_metadata(mdatfile, metrics)
mdat$metadata$name <- paste(mdat$metadata$name, "(Proteobacteria)")
plot_metrics(mdat)

Run the code above in your browser using DataLab