Skip to content

Commit 04981b5

Browse files
committed
suppress print to console by default
1 parent 6463985 commit 04981b5

File tree

10 files changed

+40
-26
lines changed

10 files changed

+40
-26
lines changed

.Rbuildignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ LICENSE
1313
^vignettes/liu\.rds$
1414
^vignettes/hannum\.rds$
1515
^CRAN-SUBMISSION$
16+
^tests/assets$

R/Unico.r

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ Unico = function(X, W, C1, C2, fit_tau = FALSE,
6464
mean_penalty = 0, var_penalty = 0.01, covar_penalty = 0.01,
6565
mean_max_iterations = 2, var_max_iterations = 3, nloptr_opts_algorithm = "NLOPT_LN_COBYLA",
6666
max_stds = 2, init_weight = "default", max_u = 1, max_v = 1,
67-
parallel = TRUE, num_cores = NULL, log_file = "Unico.log", verbose = TRUE, debug = FALSE){
67+
parallel = TRUE, num_cores = NULL, log_file = "Unico.log", verbose = FALSE, debug = FALSE){
6868

6969
start_logger(log_file, debug, verbose)
7070
flog.info("Starting Unico ...")
@@ -263,7 +263,7 @@ Unico = function(X, W, C1, C2, fit_tau = FALSE,
263263
#'
264264
#' @export tensor
265265
tensor = function(X, W, C1, C2, Unico.mdl, parallel = TRUE, num_cores = NULL,
266-
log_file = "Unico.log", verbose = TRUE, debug = FALSE){
266+
log_file = "Unico.log", verbose = FALSE, debug = FALSE){
267267

268268
start_logger(log_file, debug, verbose)
269269
config = config::get(file = system.file("extdata", "config.yml", package = "Unico"), use_parent = FALSE)
@@ -382,7 +382,7 @@ association_parametric = function(X, Unico.mdl, slot_name = "parametric",
382382
Q_max_stds = Inf,
383383
XQ_max_stds = Inf,
384384
parallel = TRUE, num_cores = NULL,
385-
log_file = "Unico.log", debug = FALSE, verbose = TRUE){
385+
log_file = "Unico.log", verbose = FALSE, debug = FALSE){
386386

387387
start_logger(log_file, debug, verbose)
388388
config = config::get(file = system.file("extdata", "config.yml", package = "Unico"), use_parent = FALSE)
@@ -620,7 +620,7 @@ association_asymptotic = function(X, Unico.mdl, slot_name = "asymptotic",
620620
Q_max_stds = Inf, #analytical variance
621621
V_min_qlt = 0.05, #moment condition variance
622622
parallel = TRUE, num_cores = NULL,
623-
log_file = "Unico.log", debug = FALSE, verbose = TRUE){
623+
log_file = "Unico.log", verbose = FALSE, debug = FALSE){
624624

625625
start_logger(log_file, debug, verbose)
626626
config = config::get(file = system.file("extdata", "config.yml", package = "Unico"), use_parent = FALSE)
@@ -849,7 +849,7 @@ simulate_data = function(n, m, k, p1, p2,
849849
gammas_mean = 1, gammas_std = 0.1,
850850
betas_mean = 1, betas_std = 0.1,
851851
sigmas_lb = 0, sigmas_ub = 1, taus_std = 0.1,
852-
log_file = "Unico.log", verbose = TRUE){
852+
log_file = "Unico.log", verbose = FALSE){
853853
start_logger(log_file, FALSE, verbose)
854854
flog.info("Start simulation ...")
855855

man/Unico.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/association_asymptotic.Rd

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/association_parametric.Rd

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/simulate_data.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/tensor.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-association.R

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ test_that("association testing on cell-type and tissue level covariates has good
44

55
skip_on_cran()
66

7-
basedir <- "../assets/"
8-
97
#source-specific association
10-
sim.data = readRDS(file.path(basedir,"simulation.gammas.10.rds"))
8+
9+
download.file("https://github.com/cozygene/Unico/raw/main/tests/assets/simulation.gammas.10.rds", "simulation.gammas.10.rds")
10+
sim.data = readRDS("simulation.gammas.10.rds")
11+
file.remove("simulation.gammas.10.rds")
12+
1113
Unico.mdl = list()
1214
Unico.mdl$params.hat <- Unico(sim.data$X, sim.data$W, C1 = sim.data$C1, C2 = sim.data$C2, parallel = F)
1315
Unico.mdl$params.hat = association_parametric(X = sim.data$X, Unico.mdl$params.hat, parallel = F)
@@ -21,9 +23,11 @@ test_that("association testing on cell-type and tissue level covariates has good
2123
global.marg.pvals = Unico.mdl$params.hat$parametric$betas_hat_pvals
2224
expect_equal(sum(global.marg.pvals < 0.05/(nrow(global.marg.pvals) * ncol(global.marg.pvals)))/(nrow(global.marg.pvals) * ncol(global.marg.pvals)) < 0.05, TRUE)
2325

24-
2526
#non-source-specific association
26-
sim.data = readRDS(file.path(basedir,"simulation.betas.10.rds"))
27+
download.file("https://github.com/cozygene/Unico/raw/main/tests/assets/simulation.betas.10.rds","simulation.betas.10.rds")
28+
sim.data = readRDS("simulation.betas.10.rds")
29+
file.remove("simulation.betas.10.rds")
30+
2731
Unico.mdl = list()
2832
Unico.mdl$params.hat <- Unico(sim.data$X, sim.data$W, C1 = sim.data$C1, C2 = sim.data$C2, parallel = F)
2933
Unico.mdl$params.hat = association_parametric(X = sim.data$X, Unico.mdl$params.hat, parallel = F)

tests/testthat/test-parameter.R

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,20 @@ library(Unico)
33
test_that("estimated params and tensors are consisitent with frozen result", {
44
skip_on_cran()
55

6-
basedir <- "../assets/"
7-
set.seed(2023)
6+
7+
#basedir <- "../assets"
8+
download.file("https://github.com/cozygene/Unico/raw/main/tests/assets/simulation.rds","simulation.rds")
9+
download.file("https://github.com/cozygene/Unico/raw/main/tests/assets/frozen.mdl.rds","frozen.mdl.rds")
10+
11+
sim.data = readRDS("simulation.rds")
12+
frozen.mdl = readRDS("frozen.mdl.rds")
13+
14+
file.remove("simulation.rds")
15+
file.remove("frozen.mdl.rds")
16+
17+
818
#model fit
9-
sim.data = readRDS(file.path(basedir,"simulation.rds"))
19+
set.seed(2023)
1020
Unico.mdl = list()
1121
Unico.mdl$params.hat <- Unico(sim.data$X, sim.data$W, C1 = sim.data$C1, C2 = sim.data$C2, parallel = F)
1222
n = nrow(sim.data$W)
@@ -16,7 +26,6 @@ test_that("estimated params and tensors are consisitent with frozen result", {
1626
p2 = ncol(sim.data$C2)
1727

1828
# mean check
19-
frozen.mdl = readRDS(file.path(basedir,"frozen.mdl.rds"))
2029
for (h in 1:k){
2130
expect_equal(cor(frozen.mdl$mus_hat[,h], Unico.mdl$params.hat$mus_hat[,h]) > 0.99, TRUE)
2231
}

vignettes/Unico-Tutorial.Rmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ library(Unico)
1919
library(matrixStats)
2020
2121
#For visualization in this vignette
22-
install.packages(c("ggplot2","ggpubr","hexbin", "egg"))
22+
install.packages(c("ggplot2","ggpubr","hexbin","egg"))
2323
source("https://github.com/cozygene/Unico/raw/main/vignettes/vignetts.utils.r")
2424
```
2525

0 commit comments

Comments
 (0)