Last updated: 2023-04-11

Checks: 7 0

Knit directory: survival-susie/

This reproducible R Markdown analysis was created with workflowr (version 1.6.2). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.


Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.

Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.

The command set.seed(20230201) was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.

Great job! Recording the operating system, R version, and package versions is critical for reproducibility.

Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.

Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.

Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.

The results in this page were generated with repository version 96956f3. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.

Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish or wflow_git_commit). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:


Ignored files:
    Ignored:    .DS_Store
    Ignored:    .Rhistory
    Ignored:    .Rproj.user/
    Ignored:    analysis/.DS_Store
    Ignored:    analysis/.RData
    Ignored:    analysis/.Rhistory
    Ignored:    data/.DS_Store

Untracked files:
    Untracked:  analysis/ibss_null_model.Rmd

Unstaged changes:
    Modified:   analysis/check_coxph_fit.Rmd
    Deleted:    analysis/null_model_demo.Rmd
    Modified:   analysis/null_model_zscore.Rmd
    Deleted:    analysis/one_predictor_investigation.Rmd
    Deleted:    analysis/ser_survival.Rmd
    Modified:   analysis/sim_survival_with_censoring.Rmd
    Modified:   code/VI_exponential.R

Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.


These are the previous versions of the repository in which changes were made to the R Markdown (analysis/susie_poor_performance_example.Rmd) and HTML (docs/susie_poor_performance_example.html) files. If you’ve configured a remote Git repository (see ?wflow_git_remote), click on the hyperlinks in the table below to view the files as they were in that past version.

File Version Author Date Message
Rmd 96956f3 yunqiyang0215 2023-04-11 wflow_publish("analysis/susie_poor_performance_example.Rmd")
html 8978b7c yunqiyang0215 2023-04-11 Build site.
Rmd b5194ad yunqiyang0215 2023-04-11 wflow_publish("analysis/susie_poor_performance_example.Rmd")
html 47c2c5f yunqiyang0215 2023-04-11 Build site.
Rmd 64a1a5b yunqiyang0215 2023-04-11 wflow_publish("analysis/susie_poor_performance_example.Rmd")
html 530a3e8 yunqiyang0215 2023-04-11 Build site.
Rmd 3826773 yunqiyang0215 2023-04-11 wflow_publish("analysis/susie_poor_performance_example.Rmd")
html 1150235 yunqiyang0215 2023-04-10 Build site.
Rmd ac9c105 yunqiyang0215 2023-04-10 wflow_publish("analysis/susie_poor_performance_example.Rmd")
html 6bb83e4 yunqiyang0215 2023-04-10 Build site.
Rmd afc124e yunqiyang0215 2023-04-10 wflow_publish("analysis/susie_poor_performance_example.Rmd")
html ed83105 yunqiyang0215 2023-04-10 Build site.
Rmd 512b4e9 yunqiyang0215 2023-04-10 wflow_publish("analysis/susie_poor_performance_example.Rmd")
html c63185a yunqiyang0215 2023-04-10 Build site.
Rmd 65ae05e yunqiyang0215 2023-04-10 wflow_publish("analysis/susie_poor_performance_example.Rmd")

Description:

Example data where Susie doesn’t perform well.

The first example is where Susie output false positive when L is larger than truth. The true number of effect here is 1. When L=1, the result looks good. When increasing L, the PIP is inflated….

The second example is where Susie wasn’t able to find the true signal, while bvsnlp can.

library(survival)
source("./code/surv_susie_helper.R")
devtools::load_all("/Users/nicholeyang/Desktop/logisticsusie/R")
# ℹ Loading logisticsusie

Example 1

res = readRDS("./data/simulate_380.rds")
res$effect_size
res$effect_indx
# [1] -0.5318875
# [1] 1
maf = apply(res$dat$X, 2, function(x) sum(x)/2/length(x))
rs = cor(res$dat$X)
rs[lower.tri(rs, diag = TRUE)] <- NA
range(maf)
range(rs, na.rm = TRUE)
# [1] 0.006097561 0.993883724
# [1] -0.2732643  0.3577365
## Create  survival object
y <- Surv(res$dat$y[,1], res$dat$y[,2])
X = as.matrix(res$dat$X)

Check if any coefficient tends to infinite

p = 1e3
res.cox = matrix(NA, nrow = p, ncol = 2)
colnames(res.cox) = c("coef", "se")
res.cox = data.frame(res.cox)

for (i in 1:p){
  fit <- coxph(y~ X[,i])
  res.cox[i, ] = summary(fit)$coef[, c(1,3)]
}
range(res.cox$coef)
# [1] -0.9421428  1.5538041

Run susie with L=1

maxiter = 1e3
fit_coxph <- ser_from_univariate(surv_uni_fun)
fit <- ibss_from_ser(X, y, L = 1, prior_variance = 1., prior_weights = rep(1/p, p), tol = 1e-3, maxit = maxiter, estimate_intercept = TRUE, ser_function = fit_coxph)

pip <- logisticsusie:::get_pip(fit$alpha)
effect_estimate <- colSums(fit$alpha * fit$mu)
sort(pip, decreasing = TRUE)[1:5]
pip[1:5]
# 11.453 sec elapsed
# [1] 9.945515e-01 5.120386e-03 5.692610e-05 4.574745e-05 2.646572e-05
# [1] 9.945515e-01 4.476417e-08 1.238833e-07 3.967854e-08 1.233310e-07

Run susie with L=2

fit_coxph <- ser_from_univariate(surv_uni_fun)
fit <- ibss_from_ser(X, y, L = 2, prior_variance = 1., prior_weights = rep(1/p, p), tol = 1e-3, maxit = maxiter, estimate_intercept = TRUE, ser_function = fit_coxph)

pip <- logisticsusie:::get_pip(fit$alpha)
sort(pip, decreasing = TRUE)[1:5]
# 43.533 sec elapsed
# [1] 0.999681939 0.954927683 0.005078653 0.004195424 0.002573596

Run susie with L=5

fit_coxph <- ser_from_univariate(surv_uni_fun)
fit <- ibss_from_ser(X, y, L = 5, prior_variance = 1., prior_weights = rep(1/p, p), tol = 1e-3, maxit = maxiter, estimate_intercept = TRUE, ser_function = fit_coxph)

pip <- logisticsusie:::get_pip(fit$alpha)
sort(pip, decreasing = TRUE)[1:5]
# 141.565 sec elapsed
# [1] 0.9998206 0.9661254 0.1561482 0.1253916 0.1109885

Example 2

res = readRDS("./data/simulate_38.rds")
res$effect_size
res$effect_indx
# [1] -1.602415
# [1] 1
maf = apply(res$dat$X, 2, function(x) sum(x)/2/length(x))
rs = cor(res$dat$X)
rs[lower.tri(rs, diag = TRUE)] <- NA
range(maf)
maf[1:5]
range(rs, na.rm = TRUE)
# [1] 0.004355401 0.992160279
#          x1          x2          x3          x4          x5 
# 0.010452962 0.009581882 0.640981428 0.646389101 0.324884820 
# [1] -0.2635109  0.4556858
## Create  survival object
y <- Surv(res$dat$y[,1], res$dat$y[,2])
X = as.matrix(res$dat$X)

Check if any coefficient tends to infinite

p = 1e3
res.cox = matrix(NA, nrow = p, ncol = 2)
colnames(res.cox) = c("coef", "se")
res.cox = data.frame(res.cox)

for (i in 1:p){
  fit <- coxph(y~ X[,i])
  res.cox[i, ] = summary(fit)$coef[, c(1,3)]
}
range(res.cox$coef)
# [1] -1.134286  0.783593

Run susie with L=1

maxiter = 1e3
fit_coxph <- ser_from_univariate(surv_uni_fun)
fit <- ibss_from_ser(X, y, L = 1, prior_variance = 1., prior_weights = rep(1/p, p), tol = 1e-3, maxit = maxiter, estimate_intercept = TRUE, ser_function = fit_coxph)

pip <- logisticsusie:::get_pip(fit$alpha)
effect_estimate <- colSums(fit$alpha * fit$mu)
sort(pip, decreasing = TRUE)[1:5]
pip[1]
# 11.583 sec elapsed
# [1] 0.10594171 0.10264788 0.02522573 0.01764054 0.01607244
# [1] 0.1059417

Remove X with maf < 0.3 and run Susie with L=1


maxiter = 1e3
X1 = X[, maf > 0.3]
X1 = cbind(X[,1], X1)

fit_coxph <- ser_from_univariate(surv_uni_fun)
fit <- ibss_from_ser(X1, y, L = 1, prior_variance = 1., prior_weights = rep(1/p, p), tol = 1e-3, maxit = maxiter, estimate_intercept = TRUE, ser_function = fit_coxph)

pip <- logisticsusie:::get_pip(fit$alpha)
effect_estimate <- colSums(fit$alpha * fit$mu)
sort(pip, decreasing = TRUE)[1:5]
pip[1]
# 5.447 sec elapsed
# [1] 0.30463718 0.04621656 0.03530294 0.01830156 0.01743457
# [1] 0.3046372

sessionInfo()
# R version 4.1.1 (2021-08-10)
# Platform: x86_64-apple-darwin20.6.0 (64-bit)
# Running under: macOS Monterey 12.0.1
# 
# Matrix products: default
# BLAS:   /usr/local/Cellar/openblas/0.3.18/lib/libopenblasp-r0.3.18.dylib
# LAPACK: /usr/local/Cellar/r/4.1.1_1/lib/R/lib/libRlapack.dylib
# 
# locale:
# [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
# 
# attached base packages:
# [1] stats     graphics  grDevices utils     datasets  methods   base     
# 
# other attached packages:
# [1] logisticsusie_0.0.0.9004 testthat_3.1.0           survival_3.2-11         
# [4] workflowr_1.6.2         
# 
# loaded via a namespace (and not attached):
#  [1] tidyselect_1.1.1   xfun_0.27          bslib_0.4.1        remotes_2.4.1     
#  [5] purrr_0.3.4        splines_4.1.1      lattice_0.20-44    generics_0.1.2    
#  [9] vctrs_0.3.8        usethis_2.1.3      htmltools_0.5.2    yaml_2.2.1        
# [13] utf8_1.2.2         rlang_1.0.6        pkgbuild_1.2.0     jquerylib_0.1.4   
# [17] later_1.3.0        pillar_1.6.4       glue_1.4.2         withr_2.5.0       
# [21] sessioninfo_1.1.1  matrixStats_0.63.0 lifecycle_1.0.1    stringr_1.4.0     
# [25] tictoc_1.1         devtools_2.4.2     evaluate_0.14      memoise_2.0.1     
# [29] knitr_1.36         callr_3.7.0        fastmap_1.1.0      httpuv_1.6.3      
# [33] ps_1.6.0           fansi_0.5.0        Rcpp_1.0.8.3       promises_1.2.0.1  
# [37] cachem_1.0.6       desc_1.4.0         pkgload_1.2.3      jsonlite_1.7.2    
# [41] fs_1.5.0           digest_0.6.28      stringi_1.7.5      dplyr_1.0.7       
# [45] processx_3.5.2     rprojroot_2.0.2    grid_4.1.1         cli_3.1.0         
# [49] tools_4.1.1        magrittr_2.0.1     sass_0.4.4         tibble_3.1.5      
# [53] crayon_1.4.1       whisker_0.4        pkgconfig_2.0.3    ellipsis_0.3.2    
# [57] Matrix_1.5-3       prettyunits_1.1.1  rmarkdown_2.11     rstudioapi_0.13   
# [61] R6_2.5.1           git2r_0.28.0       compiler_4.1.1