snpgdsHCluster {SNPRelate} | R Documentation

## Hierarchical cluster analysis

### Description

Perform hierarchical cluster analysis on the dissimilarity matrix.

### Usage

    snpgdsHCluster(dist, sample.id=NULL, need.mat=TRUE, hang=0.25)

### Arguments

`dist` | an object of "snpgdsDissClass" from `snpgdsDiss`, an object of "snpgdsIBSClass" from `snpgdsIBS`, or a square matrix for dissimilarity
`sample.id` | to specify sample id, only work if dist is a matrix
`need.mat` | if TRUE, store the dissimilarity matrix in the result
`hang` | The fraction of the plot height by which labels should hang below the rest of the plot. A negative value will cause the labels to hang down from 0.

### Details

Call the function `hclust` to perform hierarchical cluster analysis, using `method="average"`.

### Value

Return a list (class "snpgdsHCClass"):

`sample.id` | the sample ids used in the analysis
`hclust` | an object returned from `hclust`
`dendrogram` |
`dist` | the dissimilarity matrix, if `need.mat = TRUE`

### Author(s)

Xiuwen Zheng

### See Also

`snpgdsIBS`, `snpgdsDiss`, `snpgdsCutTree`

### Examples

    # open an example dataset (HapMap)
    genofile <- snpgdsOpen(snpgdsExampleFileName())

    pop.group <- read.gdsn(index.gdsn(genofile, "sample.annot/pop.group"))
    pop.group <- as.factor(pop.group)
    pop.level <- levels(pop.group)

    diss <- snpgdsDiss(genofile)
    hc <- snpgdsHCluster(diss)
    rv <- snpgdsCutTree(hc)
    rv

    # call 'plot' to draw a dendrogram
    plot(rv$dendrogram, leaflab="none", main="HapMap Phase II")

    # the distribution of Z scores
    snpgdsDrawTree(rv, type="z-score", main="HapMap Phase II")

    # draw dendrogram
    snpgdsDrawTree(rv, main="HapMap Phase II",
        edgePar=list(col=rgb(0.5,0.5,0.5, 0.75), t.col="black"))

    # close the file
    snpgdsClose(genofile)

[Package SNPRelate version 1.24.0 Index]