Last data update: 2014.03.03

R: Draw a dendrogram
snpgdsDrawTreeR Documentation

Draw a dendrogram

Description

To draw a dendrogram or the distribution of Z scores

Usage

snpgdsDrawTree(obj, clust.count=NULL, dend.idx=NULL,
    type=c("dendrogram", "z-score"), yaxis.height=TRUE, yaxis.kinship=TRUE,
    y.kinship.baseline=NaN, y.label.kinship=FALSE, outlier.n=NULL,
    shadow.col=c(rgb(0.5, 0.5, 0.5, 0.25), rgb(0.5, 0.5, 0.5, 0.05)),
    outlier.col=rgb(1, 0.50, 0.50, 0.5), leaflab="none",
    labels=NULL, y.label=0.2, ...)

Arguments

obj

an object returned by snpgdsCutTree

clust.count

the counts for clusters, drawing shadows

dend.idx

the index of sub tree, plot obj$dendrogram[[dend.idx]], or NULL for the whole tree

type

"dendrogram", draw a dendrogram; or "z-score", draw the distribution of Z score

yaxis.height

if TRUE, draw the left Y axis: height of tree

yaxis.kinship

if TRUE, draw the right Y axis: kinship coefficient

y.kinship.baseline

the baseline value of kinship; if NaN, it is the height of the first split from top in a dendrogram; only works when yaxis.kinship = TRUE

y.label.kinship

if TRUE, show 'PO/FS' etc on the right axis

outlier.n

the cluster with size less than or equal to outlier.n is considered as outliers; if NULL, let outlier.n = obj$outlier.n

shadow.col

two colors for shadow

outlier.col

the colors for outliers

leaflab

a string specifying how leaves are labeled. The default "perpendicular" write text vertically (by default). "textlike" writes text horizontally (in a rectangle), and "none" suppresses leaf labels.

labels

the legend for different regions

y.label

y positions of labels

...

Arguments to be passed to the method "plot(, ...)", such as graphical parameters.

Details

The details will be described in future.

Value

None.

Author(s)

Xiuwen Zheng

See Also

snpgdsCutTree

Examples

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

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

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

# close the genotype file
snpgdsClose(genofile)


# split
set.seed(100)
rv <- snpgdsCutTree(hc, label.H=TRUE, label.Z=TRUE)

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

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(SNPRelate)
Loading required package: gdsfmt
SNPRelate -- supported by Streaming SIMD Extensions 2 (SSE2)
> png(filename="/home/ddbj/snapshot/RGM3/R_BC/result/SNPRelate/snpgdsDrawTree.Rd_%03d_medium.png", width=480, height=480)
> ### Name: snpgdsDrawTree
> ### Title: Draw a dendrogram
> ### Aliases: snpgdsDrawTree
> ### Keywords: GDS GWAS
> 
> ### ** Examples
> 
> # open an example dataset (HapMap)
> genofile <- snpgdsOpen(snpgdsExampleFileName())
> 
> pop.group <- as.factor(read.gdsn(index.gdsn(
+     genofile, "sample.annot/pop.group")))
> pop.level <- levels(pop.group)
> 
> diss <- snpgdsDiss(genofile)
Individual dissimilarity analysis on SNP genotypes:
Excluding 365 SNPs on non-autosomes
Excluding 1 SNP (monomorphic: TRUE, < MAF: NaN, or > missing rate: NaN)
Working space: 279 samples, 8722 SNPs
	using 1 (CPU) core
Dissimilarity:	the sum of all selected genotypes (0, 1 and 2) = 2446510
Dissimilarity:	Wed Jul  6 05:34:35 2016	0%
Dissimilarity:	Wed Jul  6 05:34:36 2016	100%
> hc <- snpgdsHCluster(diss)
> 
> # close the genotype file
> snpgdsClose(genofile)
> 
> 
> # split
> set.seed(100)
> rv <- snpgdsCutTree(hc, label.H=TRUE, label.Z=TRUE)
Determine groups by permutation (Z threshold: 15, outlier threshold: 5):
Create 3 groups.
> 
> # draw dendrogram
> snpgdsDrawTree(rv, main="HapMap Phase II",
+     edgePar=list(col=rgb(0.5,0.5,0.5, 0.75), t.col="black"))
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>