bed_tcrossprodSelf {bigsnpr} | R Documentation |
tcrossprod / GRM
Description
Compute G G^T
from a bed object, with possible filtering and scaling
of G
. For example, this can be used to compute GRMs.
Usage
bed_tcrossprodSelf(
obj.bed,
fun.scaling = bed_scaleBinom,
ind.row = rows_along(obj.bed),
ind.col = cols_along(obj.bed),
block.size = block_size(length(ind.row))
)
Arguments
obj.bed |
Object of type bed, which is the mapping of some bed file.
Use |
fun.scaling |
A function with parameters
Default uses binomial scaling.
You can also provide your own |
ind.row |
An optional vector of the row indices (individuals) that
are used. If not specified, all rows are used. |
ind.col |
An optional vector of the column indices (SNPs) that are used.
If not specified, all columns are used. |
block.size |
Maximum number of columns read at once. Default uses block_size. |
Value
A temporary FBM, with the following two attributes:
a numeric vector
center
of column scaling,a numeric vector
scale
of column scaling.
Matrix parallelization
Large matrix computations are made block-wise and won't be parallelized
in order to not have to reduce the size of these blocks.
Instead, you may use Microsoft R Open
or OpenBLAS in order to accelerate these block matrix computations.
You can also control the number of cores used with
bigparallelr::set_blas_ncores()
.
Examples
bedfile <- system.file("extdata", "example.bed", package = "bigsnpr")
obj.bed <- bed(bedfile)
K <- bed_tcrossprodSelf(obj.bed)
K[1:4, 1:6] / ncol(obj.bed)