snpgdsAdmixPlot: Plot Ancestry Proportions

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/PCA.R

Description

Plot the admixture proportions according to their ancestries.

Usage

1
2
3
snpgdsAdmixPlot(propmat, group=NULL, col=NULL, multiplot=TRUE, showgrp=TRUE,
    shownum=TRUE, ylim=TRUE, na.rm=TRUE)
snpgdsAdmixTable(propmat, group, sort=FALSE)

Arguments

propmat

a sample-by-ancestry matrix of proportion estimates, returned from snpgdsAdmixProp()

group

a character vector of a factor according to the samples in propmat

col

specify colors

multiplot

single plot or multiple plots

showgrp

show group names in the plot

shownum

TRUE: show the number of each group in the figure

ylim

TRUE: y-axis is limited to [0, 1]; FALSE: ylim <- range(propmat); a 2-length numeric vector: ylim used in plot()

na.rm

TRUE: remove the sample(s) according to the missing value(s) in group

sort

TRUE: rearranges the rows of proportion matrices into descending order

Details

The minor allele frequency and missing rate for each SNP passed in snp.id are calculated over all the samples in sample.id.

Value

snpgdsAdmixPlot(): none.

snpgdsAdmixTable(): a list of data.frame consisting of group, num, mean, sd, min, max

Author(s)

Xiuwen Zheng

References

Zheng X, Weir BS. Eigenanalysis on SNP Data with an Interpretation of Identity by Descent. Theoretical Population Biology. 2015 Oct 23. pii: S0040-5809(15)00089-1. doi: 10.1016/j.tpb.2015.09.004.

See Also

snpgdsEIGMIX, snpgdsAdmixProp

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# open an example dataset (HapMap)
genofile <- snpgdsOpen(snpgdsExampleFileName())

# get population information
#   or pop_code <- scan("pop.txt", what=character())
#   if it is stored in a text file "pop.txt"
pop_code <- read.gdsn(index.gdsn(genofile, "sample.annot/pop.group"))

# get sample id
samp.id <- read.gdsn(index.gdsn(genofile, "sample.id"))

# run eigen-analysis
RV <- snpgdsEIGMIX(genofile)

# define groups
groups <- list(CEU = samp.id[pop_code == "CEU"],
    YRI = samp.id[pop_code == "YRI"],
    CHB = samp.id[is.element(pop_code, c("HCB", "JPT"))])

prop <- snpgdsAdmixProp(RV, groups=groups)

# draw
snpgdsAdmixPlot(prop, group=pop_code)

# close the genotype file
snpgdsClose(genofile)

Example output

Loading required package: gdsfmt
SNPRelate -- supported by Streaming SIMD Extensions 2 (SSE2)
Eigen-analysis on genotypes:
Excluding 365 SNPs on non-autosomes
Excluding 1 SNP (monomorphic: TRUE, MAF: NaN, missing rate: NaN)
Working space: 279 samples, 8,722 SNPs
    using 1 (CPU) core
Eigen-analysis:    the sum of all selected genotypes (0,1,2) = 2446510
CPU capabilities: Double-Precision SSE2
Mon Jan 22 16:02:19 2018    (internal increment: 408)

[..................................................]  0%, ETC: ---    
[==================================================] 100%, completed in 0s
Mon Jan 22 16:02:19 2018    Begin (eigenvalues and eigenvectors)
Mon Jan 22 16:02:19 2018    Done.

SNPRelate documentation built on Nov. 8, 2020, 5:31 p.m.