Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

snp.cor

Correlations with columns of a SnpMatrix


Description

This function calculates Pearson correlation coefficients between columns of a SnpMatrix 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, uncertain = FALSE)

Arguments

x

An N by M SnpMatrix

y

An N by P general matrix

uncertain

If TRUE, uncertain genotypes are replaced by posterior expectations. Otherwise these are treated as missing values

Details

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

Value

An M by P matrix of correlation coefficients

Note

This version cannot handle X chromosomes

Author(s)

David Clayton dc208@cam.ac.uk

See Also

Examples

# make a SnpMatrix 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 */
loadings <- snp.cor(small, pc[,1:10])

snpStats

SnpMatrix and XSnpMatrix classes and methods

v1.40.0
GPL-3
Authors
David Clayton <dc208@cam.ac.uk>
Initial release
2019-10-08

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.