Learn R Programming

ldsep (version 2.1.5)

format_lddf: Format an element of mldest() or sldest() into an upper-triangular matrix.

Description

Formats the LD estimates and standard errors output from running mldest() or sldest() into a more conventional upper-triangular matrix.

Usage

format_lddf(obj, element = "r2")

Value

A matrix of the selected elements. Only the upper-triangle of the matrix is filled. The lower-triangle and the diagonal are NA's.

Arguments

obj

An object of class lddf, usually output from running either mldest() or sldest().

element

Which element in obj should we format into an upper-triangular matrix?

Author

David Gerard

Examples

Run this code
set.seed(1)

## Simulate genotypes when true correlation is 0
nloci <- 5
nind  <- 100
K <- 6
nc <- 1
genomat <- matrix(sample(0:K, nind * nloci, TRUE), nrow = nloci)

## Haplotypic LD estimates
lddf <- mldest(geno = genomat,
               K = K,
               nc = nc,
               type = "hap")

## Obtain the D estimates in matrix form
Dmat <- format_lddf(obj = lddf, element = "D")
Dmat

Run the code above in your browser using DataLab