Get significant correlations between nearby SNPs (p-values are computed using a two-sided t-test).

snp_cor(
  Gna,
  ind.row = rows_along(Gna),
  ind.col = cols_along(Gna),
  size = 500,
  alpha = 0.05,
  fill.diag = TRUE,
  infos.pos = NULL
)

Arguments

Gna

A FBM.code256 (typically <bigSNP>$genotypes).
You can have missing values in these data.

ind.row

An optional vector of the row indices (individuals) that are used. If not specified, all rows are used.
Don't use negative indices.

ind.col

An optional vector of the column indices (SNPs) that are used. If not specified, all columns are used.
Don't use negative indices.

size

For one SNP, window size around this SNP to compute correlations. Default is 500. If not providing infos.pos (NULL, the default), this is a window in number of SNPs, otherwise it is a window in kb (genetic distance).

alpha

Type-I error for testing correlations.

fill.diag

Whether to fill the diagonal with 1s (the default) or to keep it as 0s.

infos.pos

Vector of integers specifying the physical position on a chromosome (in base pairs) of each SNP.
Typically <bigSNP>$map$physical.pos.

Value

The correlation matrix. This is a sparse symmetric matrix.

Examples

test <- snp_attachExtdata() corr <- snp_cor(test$genotypes, ind.col = 1:1000) corr[1:10, 1:10]
#> 10 x 10 sparse Matrix of class "dsCMatrix" #> #> [1,] 1.0000000 . . . . . . . 0.1113498 #> [2,] . 1 . . . . . . . #> [3,] . . 1.00000000 -0.10260676 . . . -0.08716539 . #> [4,] . . -0.10260676 1.00000000 . . . . . #> [5,] . . . . 1 . . . . #> [6,] . . . . . 1 . . . #> [7,] . . . . . . 1 . . #> [8,] . . -0.08716539 . . . . 1.00000000 . #> [9,] 0.1113498 . . . . . . . 1.0000000 #> [10,] . . . -0.09303201 . . . . . #> #> [1,] . #> [2,] . #> [3,] . #> [4,] -0.09303201 #> [5,] . #> [6,] . #> [7,] . #> [8,] . #> [9,] . #> [10,] 1.00000000
# Sparsity length(corr@x) / length(corr)
#> [1] 0.034402