Learn R Programming

RAM (version 1.2.1.3)

correlation: Plot Of Correlation Coefficient

Description

This function plot correlation relationship among taxa at a give rank and / or numeric variables of metadata.

Usage

correlation(data=NULL, is.OTU=TRUE, meta=NULL, rank="g", sel=NULL, sel.OTU=TRUE, data.trans=NULL, method="pearson", main=NULL, file=NULL, ext=NULL, width=8, height=8)

Arguments

data
a data frame that either an OTU table or taxonomy abundance matrix, can be missing but if metadata is also missing, an error message will be raised.
is.OTU
logical. Whether or not the data is an OTU table.
meta
the metadata table to be used.
rank
the taxonomic rank to use (see ?RAM.rank.formatting for formatting details).
sel
optional. It is a character vector of selected otuIDs or taxa names at a given taxonomic rank. If provided, sel.OTU should be set to decribe the type of IDs, i.e. TRUE means otuIDs, FALSE means taxa names. If provide, only the selected taxa will be ploted; otherwise, all taxa will be ploted.
sel.OTU
logical. Whether or not the selected items from data are otuIDs. If FALSE, sel should be a string vector of taxa names at a given rank.
data.trans
a character string of one of the following, "total", "log", "hellinger" etc, see ?vegan::decostand for details and other data transformation methods.
method
a character string, can be one of the following, "pearson", "kendall", "spearman" for the calculation of correlation coefficient (or covariance) is to be computed (see ?stats::cor for details)
main
a character string. The title of the plot.
file
the file path where the image should be created (see ?RAM.plotting).
ext
filename extension, the type of image to be saved to. (see ?RAM.plotting).
height
the height of the image to be created (in inches).
width
the width of the image to be created (in inches).

Value

This function generates a graph showing correlation relationship among OTUs or taxa at a given rank, and numeric variables of metadata

Details

This function uses stats::cor to calculate correlation coefficient (or covariance), and uses lattice::levelplot to generate the graph. (see References) Option sel is optional, however, it raises an error if the total number of variables to be plotted was too big, and no plot will be generated.

References

Sarkar, Deepayan (2008) _Lattice: Multivariate Data Visualization with R_, Springer.

Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) _The New S Language_. Wadsworth & Brooks/Cole.

See Also

cor levelplot

Examples

Run this code
data(ITS1, meta)
# only plot the first 10 OTUs
sel <- rownames(ITS1)[1:10]
correlation(data=ITS1, meta=meta, is.OTU=TRUE, sel.OTU=TRUE,
            sel=sel)
## Not run: 
# sel <- c("Fusarium", "Cladosporium", "Alternaria")
# correlation(data=ITS1, meta=meta, is.OTU=TRUE, sel.OTU=FALSE,
#             sel=sel, rank="g", data.trans="total",
#             file="test.pdf", ext="pdf")
# ## End(Not run)

Run the code above in your browser using DataLab