Last data update: 2014.03.03

R: General ordination eigenvalue plotter using ggplot2.
plot_screeR Documentation

General ordination eigenvalue plotter using ggplot2.

Description

Convenience wrapper for plotting ordination eigenvalues (if available) using a ggplot2-graphic.

Usage

plot_scree(ordination, title = NULL)

Arguments

ordination

(Required). An ordination object. Many different classes of ordination are defined by R packages. Ordination classes currently supported/created by the ordinate function are supported here. There is no default, as the expectation is that the ordination will be performed and saved prior to calling this plot function.

title

(Optional). Default NULL. Character string. The main title for the graphic.

Value

A ggplot plot object, graphically summarizing the ordination result for the specified axes.

See Also

plot_ordination

ordinate

distance

phyloseq online tutorials

Examples

# First load and trim a dataset
data("GlobalPatterns")
GP = prune_taxa(names(sort(taxa_sums(GlobalPatterns), TRUE)[1:50]), GlobalPatterns)
# Test plots (preforms ordination in-line, then makes scree plot)
plot_scree(ordinate(GP, "DPCoA", "bray"))
plot_scree(ordinate(GP, "PCoA", "bray"))
# Empty return with message
plot_scree(ordinate(GP, "NMDS", "bray"))
# Constrained ordinations
plot_scree(ordinate(GP, "CCA", formula=~SampleType))
plot_scree(ordinate(GP, "RDA", formula=~SampleType)) 
plot_scree(ordinate(GP, "CAP", formula=~SampleType)) 
# Deprecated example of constrained ordination (emits a warning)
#plot_scree(ordinate(GP ~ SampleType, "RDA")) 
plot_scree(ordinate(GP, "DCA"))
plot_ordination(GP, ordinate(GP, "DCA"), type="scree")

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(phyloseq)
> png(filename="/home/ddbj/snapshot/RGM3/R_BC/result/phyloseq/plot_scree.Rd_%03d_medium.png", width=480, height=480)
> ### Name: plot_scree
> ### Title: General ordination eigenvalue plotter using ggplot2.
> ### Aliases: plot_scree
> 
> ### ** Examples
> 
> # First load and trim a dataset
> data("GlobalPatterns")
> GP = prune_taxa(names(sort(taxa_sums(GlobalPatterns), TRUE)[1:50]), GlobalPatterns)
> # Test plots (preforms ordination in-line, then makes scree plot)
> plot_scree(ordinate(GP, "DPCoA", "bray"))
> plot_scree(ordinate(GP, "PCoA", "bray"))
> # Empty return with message
> plot_scree(ordinate(GP, "NMDS", "bray"))
Square root transformation
Wisconsin double standardization
Run 0 stress 0.1537981 
Run 1 stress 0.1462588 
... New best solution
... Procrustes: rmse 0.04440704  max resid 0.1288087 
Run 2 stress 0.1523162 
Run 3 stress 0.1683594 
Run 4 stress 0.1523162 
Run 5 stress 0.1462589 
... Procrustes: rmse 0.001099986  max resid 0.003975171 
... Similar to previous best
Run 6 stress 0.1462185 
... New best solution
... Procrustes: rmse 0.08718262  max resid 0.2315475 
Run 7 stress 0.2018559 
Run 8 stress 0.1988812 
Run 9 stress 0.1698184 
Run 10 stress 0.1462593 
... Procrustes: rmse 0.08721357  max resid 0.230347 
Run 11 stress 0.1495273 
Run 12 stress 0.1459991 
... New best solution
... Procrustes: rmse 0.006495714  max resid 0.0233421 
Run 13 stress 0.1462596 
... Procrustes: rmse 0.08666944  max resid 0.2302335 
Run 14 stress 0.2068203 
Run 15 stress 0.2076036 
Run 16 stress 0.1599945 
Run 17 stress 0.1576129 
Run 18 stress 0.2022227 
Run 19 stress 0.1459991 
... Procrustes: rmse 0.001163553  max resid 0.004196032 
... Similar to previous best
Run 20 stress 0.1459991 
... Procrustes: rmse 0.001163418  max resid 0.004197367 
... Similar to previous best
*** Solution reached
No eigenvalues found in ordination
NULL
> # Constrained ordinations
> plot_scree(ordinate(GP, "CCA", formula=~SampleType))
> plot_scree(ordinate(GP, "RDA", formula=~SampleType)) 
> plot_scree(ordinate(GP, "CAP", formula=~SampleType)) 
> # Deprecated example of constrained ordination (emits a warning)
> #plot_scree(ordinate(GP ~ SampleType, "RDA")) 
> plot_scree(ordinate(GP, "DCA"))
> plot_ordination(GP, ordinate(GP, "DCA"), type="scree")
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>