Learn R Programming

chopsticks (version 1.36.0)

snp.cor: Correlations with columns of a snp.matrix

Description

This function calculates Pearson correlation coefficients between columns of a snp.matrix and columns of an ordinary matrix. The two matrices must have the same number of rows. All valid pairs are used in the computation of each correlation coefficient.

Usage

snp.cor(x, y)

Arguments

x
An N by M snp.matrix
y
An N by P general matrix

Value

An M by P matrix of correlation coefficients

Details

This can be used together with xxt and eigen to calculate standardized loadings in the principal components

See Also

xxt

Examples

Run this code
# make a snp.matrix with a small number of rows
data(testdata)
small <- Autosomes[1:100,]
# Calculate the X.X-transpose matrix
xx <- xxt(small, correct.for.missing=TRUE)
# Calculate the principal components
pc <- eigen(xx, symmetric=TRUE)$vectors
# Calculate the loadings in first 10 components,
# for eaxample to plot against chromosome position
loadings <- snp.cor(small, pc[,1:10])

Run the code above in your browser using DataLab