ld.with {chopsticks} | R Documentation

## function to calculate the LD measures of specific SNPs against other SNPs

### Description

This function calculates the LD measures ($r^2$, D', LOD) of specific SNPs against other SNPs.

### Usage

    ld.with(data, snps, include.itself = as.logical(length(snps) - 1), signed.r = NULL)

### Arguments

`data` | either a `snp.dprime-class` object or a `snp.matrix-class` object
`snps` | A list of snps, some of which are found in `data`
`include.itself` | Whether to include LD measures of SNPs against itself - it is FALSE for one SNP, since in that case, the result is known and trivial; but otherwise TRUE
`signed.r` | Logical, whether to output signed r or $r^2$

### Details

Not all combinations of the `include.itself` and `signed.r` make sense, nor fully operational.

### Value

The returned value is somewhat similiar to a `snp.dprime` object, but not the same. It is a list of 3 named matrices `dprime`, `rsq2` (or `r` depending on the input), `lod`.

### Warning

Because this is really two functions rolled into one, depending on the class of `data`, not all combinations of the `include.itself` and `signed.r` make sense, nor fully operational.

Also, the two versions have slightly different idea about invalid values, e.g. the LOD value for a SNPs against itself, or $r^2$ for two monomorphic snps (such as one against itself).

### Note

The `ld.with` function started its life as an extractor function to take the output of `ld.snp`, a `snp.dprime-class` object, to rearrange it in a more convenient form to focus on the LD's against specific SNPs, but then evolved to take a `snp.matrix-class` object alternatively and perform the same task directly and more efficiently.

### Author(s)

Hin-Tak Leung htl10@users.sourceforge.net

### See Also

`ld.snp`, `snp.dprime-class`

### Examples

    data(testdata)
    snps10 <- Autosomes[1:10,1:10]
    obj.snp.dprime <- ld.snp(snps10)

    # result1 and result2 should be almost identical
    # except where noted in the warning section above:
    result1 <- ld.with(obj.snp.dprime, colnames(snps10))
    result2 <- ld.with(snps10, colnames(snps10))

[Package chopsticks version 1.60.0 Index]