Last updated: 2024-09-15

Checks: 6 1

Knit directory: survival-susie/

This reproducible R Markdown analysis was created with workflowr (version 1.7.0). 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.

Using absolute paths to the files within your workflowr project makes it difficult for you and others to run your code on a different machine. Change the absolute path(s) below to the suggested relative path(s) to make your code more reproducible.

absolute relative
/project2/mstephens/yunqiyang/surv-susie/survival-susie/output/cs_gtex.pdf output/cs_gtex.pdf
/project2/mstephens/yunqiyang/surv-susie/survival-susie/output/cs_ukb.pdf output/cs_ukb.pdf

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 639e207. 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:    .RData
    Ignored:    .Rhistory
    Ignored:    .Rproj.user/

Unstaged changes:
    Modified:   analysis/bf_comparison.Rmd
    Modified:   analysis/bf_comparison2.Rmd
    Deleted:    analysis/calibration_large_sample.Rmd
    Modified:   analysis/check_bf.Rmd
    Modified:   analysis/coxph_na.Rmd
    Modified:   code/pip.R
    Modified:   output/bf_comparison.pdf
    Modified:   output/bf_comparison_b_0.01_n_500000.pdf
    Modified:   output/bf_comparison_b_0.1_n_500000.pdf
    Modified:   output/bf_different_bhat_large_n.pdf
    Modified:   output/bf_different_bhat_small_n.pdf
    Modified:   output/bf_different_n_large_b.pdf
    Modified:   output/cs_gtex.pdf
    Modified:   output/cs_ukb.pdf
    Modified:   output/pip_gtex.pdf
    Modified:   output/pip_ukb.pdf

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/summarize_cs.Rmd) and HTML (docs/summarize_cs.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 639e207 yunqi yang 2024-09-15 wflow_publish("analysis/summarize_cs.Rmd")
html eb74833 yunqi yang 2024-09-15 Build site.
Rmd 504292a yunqi yang 2024-09-15 wflow_publish("analysis/summarize_cs.Rmd")
html 007504d yunqi yang 2024-04-16 Build site.
Rmd 7eff69c yunqi yang 2024-04-16 wflow_publish("analysis/summarize_cs.Rmd")

get_mean_abs_corr <- function(res.cs, dat_indx){
  res.mac <- sapply(dat_indx, function(i) {
  if (!is.null(res.cs[[i]])) {
    return(res.cs[[i]]$purity$mean.abs.corr)
  } else {
    return(NULL)
  }
})
  return(unlist(res.mac))
}
source("./code/post_summary.R")

1. Small data (GTEx)

susie = readRDS("/project2/mstephens/yunqiyang/surv-susie/sim2024/sim_default_iter/susie.rds")
rss = readRDS("/project2/mstephens/yunqiyang/surv-susie/sim2024/sim_default_iter/rss.rds")
pdf("/project2/mstephens/yunqiyang/surv-susie/survival-susie/output/cs_gtex.pdf", width = 10, height = 6)
par(mfrow = c(2,3))
# 1. coverage of cs
coverage = matrix(NA, nrow = 2, ncol = 3)
rownames(coverage) = c("susie", "susie.rss")
colnames(coverage) = c("effect:1", "effect:2", "effect:3")
for (i in 1:3) {
  dat_indx = which(susie$simulate.num_effect == i)
  coverage[1, i] = calculate_cs_coverage(susie$susie.cs, susie$simulate.is_effect, dat_indx)
  
  dat_indx = which(rss$simulate.num_effect == i)
  coverage[2, i] = calculate_cs_coverage(rss$rss.cs, rss$simulate.is_effect, dat_indx)
}

# 2. power of cs
power_cs = matrix(NA, ncol = 3, nrow = 2)
rownames(power_cs) = c("susie", "susie.rss")
colnames(power_cs) = c("effect:1", "effect:2", "effect:3")

for (i in 1:3){
  dat_indx = which(susie$simulate.num_effect == i)
  cs_effect = get_cs_effect(susie$susie.cs, dat_indx, p = 1000)
  is_effect = unlist(lapply(dat_indx, function(x) susie$simulate.is_effect[[x]]))
  power = sum(cs_effect ==1 & is_effect == 1)/sum(is_effect)
  power_cs[1, i] = power
  
  cs_effect = get_cs_effect(rss$rss.cs, dat_indx, p = 1000)
  is_effect = unlist(lapply(dat_indx, function(x) rss$simulate.is_effect[[x]]))
  power = sum(cs_effect ==1 & is_effect == 1)/sum(is_effect)
  power_cs[2, i] = power
}

# 3. mean abs correlation
# 1. coverage of cs
mac = matrix(NA, nrow = 2, ncol = 3)
rownames(mac) = c("susie", "susie.rss")
colnames(mac) = c("effect:1", "effect:2", "effect:3")
for (i in 1:3) {
  dat_indx = which(susie$simulate.num_effect == i)
  
  mac[1, i] = mean(get_mean_abs_corr(susie$susie.cs, dat_indx), na.rm = TRUE)
  mac[2, i] = mean(get_mean_abs_corr(rss$rss.cs, dat_indx), na.rm = TRUE)
}



plot(coverage[1, ], pch = 20, ylim = c(min(coverage) - 0.1, 1), col = "darkred", xlab = "number of effect", ylab = "coverage")
points(coverage[2, ], pch = 20, col = "blue")
legend("bottomleft", legend = c("susie", "susie.rss"), pch = c(20, 20), col = c("darkred", "blue"))
mtext("(a)", side = 1, line = 4)

plot(power_cs[1, ], pch = 20, ylim = c(min(power_cs) - 0.1, max(power_cs) + 0.1), col = "darkred", xlab = "number of effect", ylab = "power")
points(power_cs[2, ], pch = 20, col = "blue")
legend("bottomleft", legend = c("susie", "susie.rss"), pch = c(20, 20), col = c("darkred", "blue"))
mtext("(b)", side = 1, line = 4)

plot(mac[1, ], pch = 20, ylim = c(0.97, 1), col = "darkred", xlab = "number of effect", ylab = "mean absolute correlation")
points(mac[2, ], pch = 20, col = "blue")
legend("bottomleft", legend = c("susie", "susie.rss"), pch = c(20, 20), col = c("darkred", "blue"))
mtext("(c)", side = 1, line = 4)

#### Plot against different censoring levels 
censor_lvls = unique(susie$simulate.censor_lvl)
coverage = matrix(NA, nrow = 2, ncol = length(censor_lvls))
rownames(coverage) = c("susie", "susie.rss")
colnames(coverage) = censor_lvls

power_cs = matrix(NA, nrow = 2, ncol = length(censor_lvls))
rownames(power_cs) = c("susie", "susie.rss")
colnames(power_cs) = censor_lvls

mac = matrix(NA, nrow = 2, ncol = length(censor_lvls))
rownames(mac) = c("susie", "susie.rss")
colnames(mac) = censor_lvls


for (i in 1:length(censor_lvls)) {
  # susie
  dat_indx = which(susie$simulate.censor_lvl == censor_lvls[i])
  coverage[1, i] = calculate_cs_coverage(susie$susie.cs, susie$simulate.is_effect, dat_indx)
  
  cs_effect = get_cs_effect(susie$susie.cs, dat_indx, p = 1000)
  is_effect = unlist(lapply(dat_indx, function(x) susie$simulate.is_effect[[x]]))
  power = sum(cs_effect ==1 & is_effect == 1)/sum(is_effect)
  power_cs[1, i] = power
  mac[1, i] = mean(get_mean_abs_corr(susie$susie.cs, dat_indx), na.rm = TRUE)
  
  #susie rss
  dat_indx = which(rss$simulate.censor_lvl == censor_lvls[i])
  coverage[2, i] = calculate_cs_coverage(rss$rss.cs, rss$simulate.is_effect, dat_indx)
  
  cs_effect = get_cs_effect(rss$rss.cs, dat_indx, p = 1000)
  is_effect = unlist(lapply(dat_indx, function(x) rss$simulate.is_effect[[x]]))
  power = sum(cs_effect ==1 & is_effect == 1)/sum(is_effect)
  power_cs[2, i] = power
  mac[2, i] = mean(get_mean_abs_corr(rss$rss.cs, dat_indx), na.rm = TRUE)
}


plot(censor_lvls, coverage[1, ], pch = 20, ylim = c(min(coverage) - 0.1, 1), col = "darkred", xlab = "censor level", ylab = "coverage")
points(censor_lvls, coverage[2, ], pch = 20, col = "blue")
legend("bottomleft", legend = c("susie", "susie.rss"), pch = c(20, 20), col = c("darkred", "blue"))
mtext("(d)", side = 1, line = 4)


plot(censor_lvls, power_cs[1, ], pch = 20, ylim = c(min(power_cs) - 0.1, max(power_cs) + 0.1), col = "darkred", xlab = "censor level", ylab = "power")
points(censor_lvls, power_cs[2, ], pch = 20, col = "blue")
legend("bottomleft", legend = c("susie", "susie.rss"), pch = c(20, 20), col = c("darkred", "blue"))
mtext("(e)", side = 1, line = 4)


plot(censor_lvls, mac[1, ], pch = 20, ylim = c(0.97, 1), col = "darkred", xlab = "censor level", ylab = "mean absolute correlation")
points(censor_lvls, mac[2, ], pch = 20, col = "blue")
legend("bottomleft", legend = c("susie", "susie.rss"), pch = c(20, 20), col = c("darkred", "blue"))
mtext("(f)", side = 1, line = 4)

2. Large data (UKB)

susie = readRDS("/project2/mstephens/yunqiyang/surv-susie/dsc202401/susie.rds")
rss = readRDS("/project2/mstephens/yunqiyang/surv-susie/dsc202401/susie_rss.rds")
censor_lvls = unique(susie$simulate.censor_lvl)
pdf("/project2/mstephens/yunqiyang/surv-susie/survival-susie/output/cs_ukb.pdf", width = 10, height = 6)
par(mfrow = c(2,3))
# 1. coverage of cs
coverage = matrix(NA, nrow = 2, ncol = 3)
rownames(coverage) = c("susie", "susie.rss")
colnames(coverage) = c("effect:1", "effect:2", "effect:3")
for (i in 1:3) {
  dat_indx = which(susie$simulate.num_effect == i)
  coverage[1, i] = calculate_cs_coverage(susie$susie.cs, susie$simulate.is_effect, dat_indx)
  
  dat_indx = which(rss$simulate.num_effect == i)
  coverage[2, i] = calculate_cs_coverage(rss$susie_rss.cs, rss$simulate.is_effect, dat_indx)
}

# 2. power of cs
power_cs = matrix(NA, ncol = 3, nrow = 2)
rownames(power_cs) = c("susie", "susie.rss")
colnames(power_cs) = c("effect:1", "effect:2", "effect:3")

for (i in 1:3){
  dat_indx = which(susie$simulate.num_effect == i)
  cs_effect = get_cs_effect(susie$susie.cs, dat_indx, p = 1000)
  is_effect = unlist(lapply(dat_indx, function(x) susie$simulate.is_effect[[x]]))
  power = sum(cs_effect ==1 & is_effect == 1)/sum(is_effect)
  power_cs[1, i] = power
  
  cs_effect = get_cs_effect(rss$susie_rss.cs, dat_indx, p = 1000)
  is_effect = unlist(lapply(dat_indx, function(x) rss$simulate.is_effect[[x]]))
  power = sum(cs_effect ==1 & is_effect == 1)/sum(is_effect)
  power_cs[2, i] = power
}

# 3. mean abs correlation
# 1. coverage of cs
mac = matrix(NA, nrow = 2, ncol = 3)
rownames(mac) = c("susie", "susie.rss")
colnames(mac) = c("effect:1", "effect:2", "effect:3")
for (i in 1:3) {
  dat_indx = which(susie$simulate.num_effect == i)
  
  mac[1, i] = mean(get_mean_abs_corr(susie$susie.cs, dat_indx), na.rm = TRUE)
  mac[2, i] = mean(get_mean_abs_corr(rss$susie_rss.cs, dat_indx), na.rm = TRUE)
}



plot(coverage[1, ], pch = 20, ylim = c(min(coverage) - 0.1, 1), col = "darkred", xlab = "number of effect", ylab = "coverage")
points(coverage[2, ], pch = 20, col = "blue")
legend("bottomleft", legend = c("susie", "susie.rss"), pch = c(20, 20), col = c("darkred", "blue"))
mtext("(a)", side = 1, line = 4)

plot(power_cs[1, ], pch = 20, ylim = c(min(power_cs) - 0.1, max(power_cs) + 0.1), col = "darkred", xlab = "number of effect", ylab = "power")
points(power_cs[2, ], pch = 20, col = "blue")
legend("bottomleft", legend = c("susie", "susie.rss"), pch = c(20, 20), col = c("darkred", "blue"))
mtext("(b)", side = 1, line = 4)

plot(mac[1, ], pch = 20, ylim = c(0.97, 1), col = "darkred", xlab = "number of effect", ylab = "mean absolute correlation")
points(mac[2, ], pch = 20, col = "blue")
legend("bottomleft", legend = c("susie", "susie.rss"), pch = c(20, 20), col = c("darkred", "blue"))
mtext("(c)", side = 1, line = 4)

#### Plot against different censoring levels 
censor_lvls = unique(susie$simulate.censor_lvl)
coverage = matrix(NA, nrow = 2, ncol = length(censor_lvls))
rownames(coverage) = c("susie", "susie.rss")
colnames(coverage) = censor_lvls

power_cs = matrix(NA, nrow = 2, ncol = length(censor_lvls))
rownames(power_cs) = c("susie", "susie.rss")
colnames(power_cs) = censor_lvls

mac = matrix(NA, nrow = 2, ncol = length(censor_lvls))
rownames(mac) = c("susie", "susie.rss")
colnames(mac) = censor_lvls


for (i in 1:length(censor_lvls)) {
  # susie
  dat_indx = which(susie$simulate.censor_lvl == censor_lvls[i])
  coverage[1, i] = calculate_cs_coverage(susie$susie.cs, susie$simulate.is_effect, dat_indx)
  
  cs_effect = get_cs_effect(susie$susie.cs, dat_indx, p = 1000)
  is_effect = unlist(lapply(dat_indx, function(x) susie$simulate.is_effect[[x]]))
  power = sum(cs_effect ==1 & is_effect == 1)/sum(is_effect)
  power_cs[1, i] = power
  mac[1, i] = mean(get_mean_abs_corr(susie$susie.cs, dat_indx), na.rm = TRUE)
  
  #susie rss
  dat_indx = which(rss$simulate.censor_lvl == censor_lvls[i])
  coverage[2, i] = calculate_cs_coverage(rss$susie_rss.cs, rss$simulate.is_effect, dat_indx)
  
  cs_effect = get_cs_effect(rss$susie_rss.cs, dat_indx, p = 1000)
  is_effect = unlist(lapply(dat_indx, function(x) rss$simulate.is_effect[[x]]))
  power = sum(cs_effect ==1 & is_effect == 1)/sum(is_effect)
  power_cs[2, i] = power
  mac[2, i] = mean(get_mean_abs_corr(rss$susie_rss.cs, dat_indx), na.rm = TRUE)
}


plot(censor_lvls, coverage[1, ], pch = 20, ylim = c(min(coverage) - 0.1, 1), col = "darkred", xlab = "censor level", ylab = "coverage")
points(censor_lvls, coverage[2, ], pch = 20, col = "blue")
legend("bottomleft", legend = c("susie", "susie.rss"), pch = c(20, 20), col = c("darkred", "blue"))
mtext("(d)", side = 1, line = 4)


plot(censor_lvls, power_cs[1, ], pch = 20, ylim = c(min(power_cs) - 0.1, max(power_cs) + 0.1), col = "darkred", xlab = "censor level", ylab = "power")
points(censor_lvls, power_cs[2, ], pch = 20, col = "blue")
legend("bottomleft", legend = c("susie", "susie.rss"), pch = c(20, 20), col = c("darkred", "blue"))
mtext("(e)", side = 1, line = 4)


plot(censor_lvls, mac[1, ], pch = 20, ylim = c(0.97, 1), col = "darkred", xlab = "censor level", ylab = "mean absolute correlation")
points(censor_lvls, mac[2, ], pch = 20, col = "blue")
legend("bottomleft", legend = c("susie", "susie.rss"), pch = c(20, 20), col = c("darkred", "blue"))
mtext("(f)", side = 1, line = 4)

sessionInfo()
R version 4.2.0 (2022-04-22)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS/LAPACK: /software/openblas-0.3.13-el7-x86_64/lib/libopenblas_haswellp-r0.3.13.so

locale:
 [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C         LC_TIME=C           
 [4] LC_COLLATE=C         LC_MONETARY=C        LC_MESSAGES=C       
 [7] LC_PAPER=C           LC_NAME=C            LC_ADDRESS=C        
[10] LC_TELEPHONE=C       LC_MEASUREMENT=C     LC_IDENTIFICATION=C 

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] workflowr_1.7.0

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.12      highr_0.9        compiler_4.2.0   pillar_1.9.0    
 [5] bslib_0.3.1      later_1.3.0      git2r_0.30.1     jquerylib_0.1.4 
 [9] tools_4.2.0      getPass_0.2-2    digest_0.6.29    jsonlite_1.8.0  
[13] evaluate_0.15    lifecycle_1.0.4  tibble_3.2.1     pkgconfig_2.0.3 
[17] rlang_1.1.3      cli_3.6.2        rstudioapi_0.13  yaml_2.3.5      
[21] xfun_0.30        fastmap_1.1.0    httr_1.4.3       stringr_1.5.1   
[25] knitr_1.39       fs_1.5.2         vctrs_0.6.5      sass_0.4.1      
[29] rprojroot_2.0.3  glue_1.6.2       R6_2.5.1         processx_3.8.0  
[33] fansi_1.0.3      rmarkdown_2.14   callr_3.7.3      magrittr_2.0.3  
[37] whisker_0.4      ps_1.7.0         promises_1.2.0.1 htmltools_0.5.2 
[41] httpuv_1.6.5     utf8_1.2.2       stringi_1.7.6