-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuild_matrices.r
More file actions
38 lines (32 loc) · 850 Bytes
/
Copy pathbuild_matrices.r
File metadata and controls
38 lines (32 loc) · 850 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
suppressPackageStartupMessages(library(lme4))
library(feather)
library(optparse)
option_list <- list(
make_option("--data"),
make_option("--formula"),
make_option("--X"),
make_option("--Z"),
make_option("--Lambdatx"),
make_option("--Lambdati"),
make_option("--Lambdatp")
)
opt <- parse_args(OptionParser(option_list=option_list))
data <- read_feather(opt$data)
formula <- readLines(opt$formula)
lf <- lFormula(formula, data)
file <- file(opt$X, "wb")
writeBin(c(t(lf$X)), file)
close(file)
file <- file(opt$Z, "wb")
writeBin(c(t(as.matrix(lf$reTrms$Zt))), file)
close(file)
Lambdat <- lf$reTrms$Lambdat
file <- file(opt$Lambdatx, "wb")
writeBin(Lambdat@x, file)
close(file)
file <- file(opt$Lambdati, "wb")
writeBin(Lambdat@i, file)
close(file)
file <- file(opt$Lambdatp, "wb")
writeBin(Lambdat@p, file)
close(file)