snpgdsSNPListIntersect: Get a common SNP list between/among SNP list objects

Description Usage Arguments Value Author(s) See Also Examples

View source: R/AllUtilities.R

Description

Get a common SNP list by comparing their snp id, chromosome, positions and allele frequency if needed.

Usage

1
2
snpgdsSNPListIntersect(snplist1, snplist2, ..., method=c("position", "exact"),
    na.rm=TRUE, same.strand=FALSE, verbose=TRUE)

Arguments

snplist1

the SNP list object snpgdsSNPListClass

snplist2

the SNP list object snpgdsSNPListClass

...

the other SNP list objects

method

"exact": matching by all snp.id, chromosomes, positions and alleles; "position": matching by chromosomes and positions

na.rm

if TRUE, remove mismatched alleles

same.strand

if TRUE, assuming the alleles on the same strand

verbose

if TRUE, show information

Value

Return a list of snpgdsSNPListClass including the following components:

idx1

the indices of common SNPs in the first GDS file

idx2

the indices of common SNPs in the second GDS file

idx...
idxn

the indices of common SNPs in the n-th GDS file

flag2

an integer vector, flip flag for each common SNP for the second GDS file (assuming a value v): bitwAnd(v, 1): 0 – no flip of allele names, 1 – flip of allele names; bitwAnd(v, 2): 0 – on the same strand, 2 – on the different strands, comparing with the first GDS file; bitwAnd(v, 4): 0 – no strand ambiguity, 4 – ambiguous allele names, determined by allele frequencies; NA – mismatched allele names (there is no NA if na.rm=TRUE)

flag...
flagn

flip flag for each common SNP for the n-th GDS file

Author(s)

Xiuwen Zheng

See Also

snpgdsSNPList

Examples

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

# to get a snp list object
snplist1 <- snpgdsSNPList(genofile)
snplist2 <- snpgdsSNPList(genofile)

# a common snp list, exactly matching
v <- snpgdsSNPListIntersect(snplist1, snplist2)
names(v)
# "idx1" "idx2"

# a common snp list, matching by position
v <- snpgdsSNPListIntersect(snplist1, snplist2, method="pos")
names(v)
# "idx1"  "idx2"  "flag2"

table(v$flag2, exclude=NULL)


# close the file
snpgdsClose(genofile)

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