Learn R Programming

chopsticks (version 1.36.0)

ld.snp: Function to calculate pairwise D', $r^2$

Description

ld.snp takes an object of snp.matrix class and suitable range and depth and calculation the pairwise D', $r^2$, LOD and return the result as a snp.dprime object.

Usage

ld.snp(snpdata, depth = 100, start = 1, end = dim(snpdata)[2], signed.r=FALSE)

Arguments

snpdata
An object of snp.matrix class with M samples of N snps
depth
The depth or lag of pair-wise calculation. Should be between 1 and N-1; default 100. Using 0 (an invalid value) is the same as picking the maximum
start
The index of the start of the range of interest. Should be between 1 and (N-1); default 1
end
The index of the end of the range of interest. Should be between 2 and N. default N.
signed.r
Boolean for whether to returned signed $r$ values instead of $r^2$

Value

return a snp.dprime object, which is a list of 3 named matrices dprime, rsq2 (or r depending on the input), lod, and an attribute snp.names for the list of snps involved. (Note that if $x$ snps are involved, the row numbers of the 3 matrices are $(x-1)$). Only one of rsq2 or r is present.
dprime
D'
rsq2
$r^2$
r
signed $r$
lod
Log of Odd's
All the matrices are defined such that the ($n, m$)th entry is the pair-wise value between the ($n$)th snp and the $(n+m)$th snp. Hence the lower right triangles are always filled with zeros. (See example section for the actual layout)Invalid values are represented by an out-of-range value - currently we use -1 for D', $r^2$ (both of which are between 0 and 1), and -2 for $r$ (valid values are between -1 and +1). lod is set to zero in most of these invalid cases. (lod can be any value so it is not indicative).

Details

The cubic equation and quadratic equation solver code is borrowed from GSL (GNU Scientific Library).

References

Clayton, D.G. and Leung, Hin-Tak (2007) An R package for analysis of whole-genome association studies. Human Heredity 64:45-51. GSL (GNU Scientific Library) http://www.gnu.org/software/gsl/

See Also

snp.dprime-class, plot.snp.dprime, ld.with

Examples

Run this code
# LD stats between 500 SNPs at a depth of 50
data(testdata)
ldinfo <- ld.snp(Autosomes, start=1, end=500, depth=50)

Run the code above in your browser using DataLab