Learn R Programming

SNPRelate (version 1.6.4)

snpgdsPairScore: Genotype Score for Pairs of Individuals

Description

Calculate the genotype score for pairs of individuals based on identity-by-state (IBS) measure

Usage

snpgdsPairScore(gdsobj, sample1.id, sample2.id, snp.id=NULL, method=c("IBS", "GVH", "HVG"), type=c("per.pair", "per.snp", "matrix", "gds.file"), with.id=TRUE, output=NULL, verbose=TRUE)

Arguments

gdsobj
an object of class SNPGDSFileClass, a SNP GDS file
sample1.id
a vector of sample id specifying selected samples; if NULL, all samples are used
sample2.id
a vector of sample id specifying selected samples; if NULL, all samples are used
snp.id
a vector of snp id specifying selected SNPs; if NULL, all SNPs are used
method
"IBS" -- identity-by-state score, "GVH" or "HVG", see Details
type
"per.pair", "per.snp" or "matrix", see Value
with.id
if TRUE, returns "sample.id" and "snp.id"; see Value
output
if type="gds.file", the file name
verbose
if TRUE, show information

Value

Return a list:
sample.id
the sample ids used in the analysis, if with.id=TRUE
snp.id
the SNP ids used in the analysis, if with.id=TRUE
score
a matrix of genotype score: if type="per.pair", a # of pairs-by-3 matrix with the first column for average scores, the second column for standard deviation and the third column for the valid number of SNPs; if type="per.snp", a 3-by-# of SNPs matrix with the first row for average scores, the second row for standard deviation and the third row for the valid number of individual pairs; if type="matrix", a # of pairs-by-# of SNPs matrix with rows for pairs of individuals

Details

Patient (sample1.id) Coded Genotype Donor (sample2.id) Coded Genotype IBS GVH
HVG

AA

0 AA 0 2
0 0 AA 0 AB 1
1 0 1 AA 0 BB
2 0 2 2 AB 1
AA 0 1 1 0 AB
1 AB 1 2 0 0
AB 1 BB 2 1 1
0 BB 2 AA 0 0
2 2 BB 2 AB 1
1 0 1 BB 2 BB
2 2 0 0 Patient (sample1.id) Coded Genotype

References

Warren, E. H., Zhang, X. C., Li, S., Fan, W., Storer, B. E., Chien, J. W., Boeckh, M. J., et al. (2012). Effect of MHC and non-MHC donor/recipient genetic disparity on the outcome of allogeneic HCT. Blood, 120(14), 2796-806. doi:10.1182/blood-2012-04-347286

See Also

snpgdsIBS

Examples

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

# autosomal SNPs
selsnp <- snpgdsSelectSNP(genofile, autosome.only=TRUE, remove.monosnp=FALSE)

# sample ID
sample.id <- read.gdsn(index.gdsn(genofile, "sample.id"))
father.id <- read.gdsn(index.gdsn(genofile, "sample.annot/father.id"))

offspring.id <- sample.id[father.id != ""]
father.id <- father.id[father.id != ""]


# calculate average genotype scores
z1 <- snpgdsPairScore(genofile, offspring.id, father.id, snp.id=selsnp,
    method="IBS", type="per.pair")
names(z1)
z1$score


# calculate average genotype scores
z2 <- snpgdsPairScore(genofile, offspring.id, father.id, snp.id=selsnp,
    method="IBS", type="per.snp")
names(z2)
mean(z2$score["Avg",])
mean(z2$score["SD",])

plot(z2$score["Avg",], pch=20, cex=0.75, xlab="SNP Index", ylab="IBS score")


# calculate a matrix of genotype scores over samples and SNPs
z3 <- snpgdsPairScore(genofile, offspring.id, father.id, snp.id=selsnp,
    method="IBS", type="matrix")
dim(z3$score)


# output the score matrix to a GDS file
snpgdsPairScore(genofile, offspring.id, father.id, snp.id=selsnp,
    method="IBS", type="gds.file", output="tmp.gds")
(f <- snpgdsOpen("tmp.gds"))
snpgdsClose(f)


# close the file
snpgdsClose(genofile)

unlink("tmp.gds", force=TRUE)

Run the code above in your browser using DataLab