Get significant (Pearson) correlations between nearby SNPs of the same chromosome (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 = 1,
thr_r2 = 0,
fill.diag = TRUE,
infos.pos = NULL,
ncores = 1
)
bed_cor(
obj.bed,
ind.row = rows_along(obj.bed),
ind.col = cols_along(obj.bed),
size = 500,
alpha = 1,
thr_r2 = 0,
fill.diag = TRUE,
infos.pos = NULL,
ncores = 1
)
A FBM.code256
(typically <bigSNP>$genotypes
).
You can have missing values in these data.
An optional vector of the row indices (individuals) that
are used. If not specified, all rows are used.
Don't use negative indices.
An optional vector of the column indices (SNPs) that are used.
If not specified, all columns are used.
Don't use negative indices.
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).
Type-I error for testing correlations.
Default is 1
(no threshold is applied).
Threshold to apply on squared correlations. Default is 0
.
Whether to fill the diagonal with 1s (the default) or to keep it as 0s.
Vector of integers specifying the physical position
on a chromosome (in base pairs) of each SNP.
Typically <bigSNP>$map$physical.pos
.
Number of cores used. Default doesn't use parallelism.
You may use bigstatsr::nb_cores()
.
Object of type bed, which is the mapping of some bed file.
Use obj.bed <- bed(bedfile)
to get this object.
The (Pearson) correlation matrix. This is a sparse symmetric matrix.
test <- snp_attachExtdata()
G <- test$genotypes
corr <- snp_cor(G, ind.col = 1:1000)
corr[1:10, 1:10]
#> 10 x 10 sparse Matrix of class "dsCMatrix"
#>
#> [1,] 1.000000000 -0.059420393 0.005664354 -0.024489153 0.07467733
#> [2,] -0.059420393 1.000000000 0.011193114 0.069041892 0.01201638
#> [3,] 0.005664354 0.011193114 1.000000000 -0.102606763 0.03146612
#> [4,] -0.024489153 0.069041892 -0.102606763 1.000000000 0.06581927
#> [5,] 0.074677326 0.012016376 0.031466118 0.065819274 1.00000000
#> [6,] -0.016720892 0.006950400 0.075573785 -0.009996247 0.01995194
#> [7,] 0.003680272 -0.073816948 0.015793311 0.067027181 0.03088233
#> [8,] -0.017764606 -0.033245425 -0.087165386 0.052163271 -0.04179906
#> [9,] 0.111349765 0.008661176 -0.060211948 0.062986807 -0.03244854
#> [10,] -0.051804449 -0.065532091 0.017048961 -0.093032007 -0.01146874
#>
#> [1,] -0.016720892 0.003680272 -0.01776461 0.111349765 -0.051804449
#> [2,] 0.006950400 -0.073816948 -0.03324542 0.008661176 -0.065532091
#> [3,] 0.075573785 0.015793311 -0.08716539 -0.060211948 0.017048961
#> [4,] -0.009996247 0.067027181 0.05216327 0.062986807 -0.093032007
#> [5,] 0.019951940 0.030882334 -0.04179906 -0.032448541 -0.011468736
#> [6,] 1.000000000 0.053884169 -0.04024761 -0.045578013 0.052820407
#> [7,] 0.053884169 1.000000000 -0.06369954 -0.012107321 0.006552636
#> [8,] -0.040247606 -0.063699540 1.00000000 -0.022351147 -0.058557214
#> [9,] -0.045578013 -0.012107321 -0.02235115 1.000000000 -0.041503959
#> [10,] 0.052820407 0.006552636 -0.05855721 -0.041503959 1.000000000
# Sparsity
length(corr@x) / length(corr)
#> [1] 0.375676