plot_clusgap {phyloseq} | R Documentation

## Create a ggplot summary of gap statistic results

### Description

Create a ggplot summary of gap statistic results

### Usage

    plot_clusgap(clusgap, title = "Gap Statistic results")

### Arguments

`clusgap` | (Required). An object of S3 class `"clusGap"`, basically a list with components. See the `clusGap` documentation for more details. In most cases this will be the output of `gapstat_ord`, or `clusGap` if you called it directly.
`title` | (Optional). Character string. The main title for the graphic. Default is `"Gap Statistic results"`.

### Value

A `ggplot` plot object. The rendered graphic should be a plot of the gap statistic score versus values for `k`, the number of clusters.

### See Also

`gapstat_ord`

`clusGap`

`ggplot`

### Examples

    # Load and process data
    data("soilrep")
    soilr = rarefy_even_depth(soilrep, rngseed=888)
    print(soilr)
    sample_variables(soilr)
    # Ordination
    sord  = ordinate(soilr, "DCA")
    # Gap Statistic
    gs = gapstat_ord(sord, axes=1:4, verbose=FALSE)
    # Evaluate results with plots, etc.
    plot_scree(sord)
    plot_ordination(soilr, sord,  color="Treatment")
    plot_clusgap(gs)
    print(gs, method="Tibs2001SEmax")
    # Non-ordination example, use cluster::clusGap function directly
    library("cluster")
    pam1 = function(x, k){list(cluster = pam(x, k, cluster.only=TRUE))}
    gs.pam.RU = clusGap(ruspini, FUN = pam1, K.max = 8, B = 60)
    gs.pam.RU
    plot(gs.pam.RU, main = "Gap statistic for the 'ruspini' data")
    mtext("k = 4 is best .. and  k = 5  pretty close")
    plot_clusgap(gs.pam.RU)

[Package phyloseq version 1.26.1 Index]