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

Description Usage Arguments Details Value Note Author(s) See Also Examples

View source: R/structure.R

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

1
snp.cor(x, y)

Arguments

x

An N by M snp.matrix

y

An N by P general matrix

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 david.clayton@cimr.cam.ac.uk

See Also

xxt

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# 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])

Example output

Loading required package: survival
Warning message:
In methods:::bind_activation(TRUE) :
  methods:::bind_activation(TRUE) is deprecated;
 you should rather provide methods for cbind2() / rbind2()
Warning message:
In xxt(small, correct.for.missing = TRUE) :
  With correct.for.missing option set, result may not be a positive semi-definite matrix

chopsticks documentation built on Nov. 8, 2020, 7:51 p.m.