Description Usage Arguments Details Value Author(s) Examples
vectorGeno
multiplies a vector from the left onto a compressed
SNP matrix.
genoVector
does it from the right.
1 2 | vectorGeno(V, SNPxIndiv, do.centering=FALSE, decode=TRUE)
genoVector(SNPxIndiv, V, do.centering=FALSE)
|
SNPxIndiv |
a compressed SNP (genotype) vector or matrix
obtained from |
do.centering |
not programmed yet. |
decode |
Logical. This option only applies when
|
V |
numerical vector |
Let G be a (SNP\times Indiv) matrix.
vectorGeno
and genoVector
return VG and
GV, respectively.
vector of length nrow(SNPxIndiv)
and
ncol(SNPxIndiv)
for vectorGeno
and genoVector
, respectively.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
require(RandomFieldsUtils)
set.seed(0)
indiv <- 1 + sample(500, 1)
snps <- indiv * 2^sample(7, 1)
snps <- indiv * 100
M <- matrix(ncol=indiv, sample(0:2, indiv * snps, replace=TRUE))
print(system.time(CM <- genomicmatrix(M)))
## V %*% G
Vl <- runif(snps)
print(system.time(VM1 <- vectorGeno(Vl, CM))) # 1.2x slower than '%*%'
print(system.time(VM <- as.vector(Vl %*% M)))
stopifnot(all.equal(as.double(VM), as.double(VM1)))
## G %*% V
Vr <- runif(indiv)
print(system.time(MV1 <- genoVector(CM, Vr))) ## 3x faster than '%*%'
print(system.time(MV <- as.vector(M %*% Vr)))
stopifnot(all.equal(as.double(MV), as.double(MV1)))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.