Learn R Programming

RAM (version 1.2.1.3)

group.diversity: Boxplot To Compare Diversity Indices Among Groups

Description

This function first use OTU.diversity to calculate the diversity indices for each sample and then do a boxplot to compare the selected indices among different groups.

Usage

group.diversity(data, meta, factors="", indices="", diversity.info=FALSE, x.axis=NULL, compare=NULL, facet=NULL, facet.y=TRUE, facet.x.cex=NULL, facet.y.cex=NULL, scale.free=NULL, xlab=NULL, ylab=NULL, legend.title=NULL, legend.labels=NULL, file=NULL, ext=NULL, width=8, height=8)

Arguments

data
a list, containing otu tables. See also RAM.input.formatting
meta
the metadata table to be used (must have same samples as data.
factors
a character vector. Must be variables in the metadata
indices
a character vector. Must be one or more of the following: "spec", "sim", "invsim", "shan", "sim_even", "shan_even", "sim_trudiv", "shan_trudiv", "chao", "ACE". See also OTU.diversity, true.diversity, evenness, and diversity.
diversity.info
logical. Whether the diversity indices have calculated and included in the metadata table. The diversity indices should be processed by OTU.diversity for the same otu tables and metadata table.
x.axis
optional. If NULL, will use the first variable in factors; otherwise, must be one factor in the metadata or 'SampleID'
compare
optional. If NULL, will use the first variable in factors; otherwise, must be one factor in the metadata
facet
optional. If provided, must be one factor in the metadata or 'SampleID'
facet.y
logical, whether the facet being used as strip text of y axis or x axis.
facet.x.cex
optional, an integer, the font size of the stip.text.x in ggplot
facet.y.cex
optional, an integer, the font size of the strip.text.y in ggplot.
scale.free
optional. Whether use free scale for y axis.
xlab
optional. If not provided, the x.axis will be used as the title of the x axis, otherwise, will use the provided string.
ylab
optional. If not provided, "value" will be used as the title of the y axis, otherwise, will use the provided string.
legend.title
optional. If not provided, compare will be used as the title of the legend, otherwise, will use the provided string.
legend.labels
optional. If not provided, will use the levels of compare for the legends, otherwise, will use the provided vector of strings. The length of the provided vector of strings must equals to the levels of compare.
file
the filename to save the plot.
ext
the extention (file type) of the plot to saved.
width
the width of the plot to be saved.
height
the heigth of the plot to be saved.

Value

This function returns a boxplot to compared selected diversity indices among different groups.

See Also

OTU.diversity, true.diversity, evenness and diversity

Examples

Run this code
data(ITS1, ITS2, meta)
## Not run: 
# RAM.theme<-RAM.color()
# group.diversity(data=list(ITS1=ITS1, ITS2=ITS2), meta=meta,
#                 factors=c("Crop", "City"),
#                 indices=c("sim_trudiv", "shan_trudiv"),
#                 x.axis="Crop", compare="Harvestmethod",
#                 facet="City", facet.y=FALSE) + RAM.theme
# ## End(Not run)

Run the code above in your browser using DataLab