Last updated: 2024-04-16

Checks: 7 0

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.

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 7eff69c. 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:    .Rhistory
    Ignored:    .Rproj.user/

Unstaged changes:
    Deleted:    analysis/calibration_large_sample.Rmd
    Modified:   analysis/coxph_na.Rmd
    Modified:   code/post_summary.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/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 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")
# 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)
}

coverage
           effect:1  effect:2  effect:3
susie     0.9797980 0.9696970 0.9552239
susie.rss 0.9569892 0.9042553 0.8320000
# 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
}

power_cs
          effect:1 effect:2  effect:3
susie        0.485    0.485 0.4416667
susie.rss    0.445    0.430 0.3633333
# 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)
}
mac
           effect:1  effect:2  effect:3
susie     0.9873018 0.9909014 0.9867641
susie.rss 0.9854272 0.9852113 0.9838690
par(mfrow = c(1,3))
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"))

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 of cs")
points(power_cs[2, ], pch = 20, col = "blue")
legend("bottomleft", legend = c("susie", "susie.rss"), pch = c(20, 20), col = c("darkred", "blue"))

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"))

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)
}

coverage
                  0       0.2       0.4       0.6       0.8
susie     0.9657534 0.9741379 0.9814815 0.9326923 0.9670330
susie.rss 0.9338235 0.8909091 0.8073394 0.8297872 0.9156627
power_cs
                  0       0.2       0.4       0.6       0.8
susie     0.5958333 0.4875000 0.4458333 0.4125000 0.3750000
susie.rss 0.5375000 0.4166667 0.3666667 0.3416667 0.3333333
mac
                  0       0.2       0.4       0.6       0.8
susie     0.9915309 0.9914166 0.9929758 0.9831470 0.9795343
susie.rss 0.9851081 0.9909688 0.9868677 0.9805707 0.9772073
par(mfrow = c(1,3))
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"))

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 of cs")
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"))

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"))

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)
# 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)
}

coverage
           effect:1  effect:2  effect:3
susie     1.0000000 0.9555556 0.8955224
susie.rss 0.7355372 0.6147541 0.6288344
# 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
  
  dat_indx = which(rss$simulate.num_effect == i)
  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
}

power_cs
           effect:1  effect:2  effect:3
susie     0.7833333 0.7083333 0.6750000
susie.rss 0.7416667 0.6250000 0.5805556
# 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)
}
mac
           effect:1  effect:2  effect:3
susie     0.9937133 0.9938112 0.9955902
susie.rss 0.9938938 0.9951686 0.9972310
par(mfrow = c(1,3))
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"))

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 of cs")
points(power_cs[2, ], pch = 20, col = "blue")
legend("bottomleft", legend = c("susie", "susie.rss"), pch = c(20, 20), col = c("darkred", "blue"))

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"))

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)
}

coverage
                  0       0.2       0.4       0.6       0.8      0.99
susie     0.9622642 0.9716981 0.9052632 0.8971963 0.9555556 0.8684211
susie.rss 0.6923077 0.6796875 0.6153846 0.5928571 0.6083333 0.7209302
power_cs
                  0   0.2       0.4       0.6       0.8      0.99
susie     0.8416667 0.825 0.7416667 0.8000000 0.7083333 0.3083333
susie.rss 0.7500000 0.725 0.6666667 0.6916667 0.6083333 0.2916667
mac
                  0      0.2       0.4       0.6       0.8      0.99
susie     0.9946540 0.995251 0.9975147 0.9949978 0.9970369 0.9795085
susie.rss 0.9972356 0.998741 0.9975953 0.9959821 0.9960839 0.9777948
par(mfrow = c(1,3))
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"))

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 of cs")
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"))

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"))


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.8.3     highr_0.9        bslib_0.3.1      compiler_4.2.0  
 [5] pillar_1.7.0     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    tibble_3.1.7     lifecycle_1.0.1  pkgconfig_2.0.3 
[17] rlang_1.0.2      cli_3.3.0        rstudioapi_0.13  yaml_2.3.5      
[21] xfun_0.30        fastmap_1.1.0    httr_1.4.3       stringr_1.4.0   
[25] knitr_1.39       sass_0.4.1       fs_1.5.2         vctrs_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] ellipsis_0.3.2   httpuv_1.6.5     utf8_1.2.2       stringi_1.7.6   
[45] crayon_1.5.1