snpgdsApartSelection: Select SNPs with a basepair distance

Description Usage Arguments Value Author(s) See Also Examples

View source: R/LD.R

Description

Randomly selects SNPs for which each pair is at least as far apart as the specified basepair distance.

Usage

1
2
snpgdsApartSelection(chromosome, position, min.dist=100000,
    max.n.snp.perchr=-1, verbose=TRUE) 

Arguments

chromosome

chromosome codes

position

SNP positions in base pair

min.dist

A numeric value to specify minimum distance required (in basepairs)

max.n.snp.perchr

A numeric value specifying the maximum number of SNPs to return per chromosome, "-1" means no number limit

verbose

if TRUE, show information

Value

A logical vector indicating which SNPs were selected.

Author(s)

Xiuwen Zheng

See Also

snpgdsLDpruning

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# open an example dataset (HapMap)
genofile <- snpgdsOpen(snpgdsExampleFileName())
genofile

chr <- read.gdsn(index.gdsn(genofile, "snp.chromosome"))
pos <- read.gdsn(index.gdsn(genofile, "snp.position"))

set.seed(1000)
flag <- snpgdsApartSelection(chr, pos, min.dist=250000, verbose=TRUE)
table(flag)

# close the genotype file
snpgdsClose(genofile)

Example output

Loading required package: gdsfmt
SNPRelate -- supported by Streaming SIMD Extensions 2 (SSE2)
File: /usr/local/lib/R/site-library/SNPRelate/extdata/hapmap_geno.gds (709.6K)
+    [  ] *
|--+ sample.id   { VStr8 279 ZIP(29.9%), 679B }
|--+ snp.id   { Int32 9088 ZIP(34.8%), 12.3K }
|--+ snp.rs.id   { VStr8 9088 ZIP(40.1%), 36.2K }
|--+ snp.position   { Int32 9088 ZIP(94.7%), 33.6K }
|--+ snp.chromosome   { UInt8 9088 ZIP(0.94%), 85B } *
|--+ snp.allele   { VStr8 9088 ZIP(11.3%), 4.0K }
|--+ genotype   { Bit2 279x9088, 619.0K } *
\--+ sample.annot   [ data.frame ] *
   |--+ family.id   { VStr8 279 ZIP(34.4%), 514B }
   |--+ father.id   { VStr8 279 ZIP(31.5%), 220B }
   |--+ mother.id   { VStr8 279 ZIP(30.9%), 214B }
   |--+ sex   { VStr8 279 ZIP(17.0%), 95B }
   \--+ pop.group   { VStr8 279 ZIP(6.18%), 69B }
Thu Jan 17 23:49:13 2019	Chromosome 1, # of SNPs: 365
Thu Jan 17 23:49:13 2019	Chromosome 2, # of SNPs: 370
Thu Jan 17 23:49:13 2019	Chromosome 3, # of SNPs: 314
Thu Jan 17 23:49:13 2019	Chromosome 4, # of SNPs: 294
Thu Jan 17 23:49:13 2019	Chromosome 5, # of SNPs: 291
Thu Jan 17 23:49:13 2019	Chromosome 6, # of SNPs: 280
Thu Jan 17 23:49:13 2019	Chromosome 7, # of SNPs: 245
Thu Jan 17 23:49:13 2019	Chromosome 8, # of SNPs: 232
Thu Jan 17 23:49:13 2019	Chromosome 9, # of SNPs: 203
Thu Jan 17 23:49:13 2019	Chromosome 10, # of SNPs: 224
Thu Jan 17 23:49:13 2019	Chromosome 11, # of SNPs: 227
Thu Jan 17 23:49:13 2019	Chromosome 12, # of SNPs: 215
Thu Jan 17 23:49:13 2019	Chromosome 13, # of SNPs: 175
Thu Jan 17 23:49:13 2019	Chromosome 14, # of SNPs: 147
Thu Jan 17 23:49:13 2019	Chromosome 15, # of SNPs: 127
Thu Jan 17 23:49:13 2019	Chromosome 16, # of SNPs: 128
Thu Jan 17 23:49:13 2019	Chromosome 17, # of SNPs: 112
Thu Jan 17 23:49:13 2019	Chromosome 18, # of SNPs: 127
Thu Jan 17 23:49:13 2019	Chromosome 19, # of SNPs: 76
Thu Jan 17 23:49:13 2019	Chromosome 20, # of SNPs: 107
Thu Jan 17 23:49:13 2019	Chromosome 21, # of SNPs: 63
Thu Jan 17 23:49:13 2019	Chromosome 22, # of SNPs: 54
Thu Jan 17 23:49:13 2019	Chromosome 23, # of SNPs: 215
Total # of SNPs selected:4591
flag
FALSE  TRUE 
 4497  4591 

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