Last updated: 2019-04-15

workflowr checks: (Click a bullet for more information)
  • R Markdown file: up-to-date

    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.

  • Environment: empty

    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.

  • Seed: set.seed(20190115)

    The command set.seed(20190115) 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.

  • Session information: recorded

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

  • Repository version: 4f3c7b5

    Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility. The version displayed above was the version of the Git repository at the time these results were generated.

    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:    .sos/
        Ignored:    data/.DS_Store
        Ignored:    output/.DS_Store
    
    Untracked files:
        Untracked:  data/random_data_31.rds
        Untracked:  data/random_data_31_sim_gaussian_35.rds
        Untracked:  data/random_data_31_sim_gaussian_35_get_sumstats_1.rds
        Untracked:  data/small_data_1.ld_in_file.in.ld
        Untracked:  data/small_data_1.ld_out_file.out.ld
        Untracked:  data/small_data_132.ld_in_file.in.ld
        Untracked:  data/small_data_132.ld_out_file.out.ld
        Untracked:  data/small_data_132_sim_gaussian_12.rds
        Untracked:  data/small_data_132_sim_gaussian_12_get_sumstats_1.rds
        Untracked:  data/small_data_1_sim_gaussian_2.rds
        Untracked:  data/small_data_1_sim_gaussian_2_get_sumstats_1.rds
        Untracked:  data/small_data_46.rds
        Untracked:  data/small_data_46_sim_gaussian_10.rds
        Untracked:  data/small_data_46_sim_gaussian_10_get_sumstats_2.rds
        Untracked:  data/small_data_69.ld_in_file.in.ld
        Untracked:  data/small_data_69.ld_out_file.out.ld
        Untracked:  data/small_data_69_sim_gaussian_3.rds
        Untracked:  data/small_data_69_sim_gaussian_3_get_sumstats_1.rds
        Untracked:  docs/figure/test.Rmd/
        Untracked:  figure/
        Untracked:  output/dscoutProblem475.rds
        Untracked:  output/dscoutProblem75.rds
        Untracked:  output/finemap_compare_random_data_null_dscout.rds
        Untracked:  output/finemap_compare_random_data_signal_dscout.rds
        Untracked:  output/finemap_compare_small_data_signal_dscout.rds
        Untracked:  output/finemap_compare_small_data_signal_dscout_RE8.rds
        Untracked:  output/r_compare_FINEMAP_PIP_ROC.rds
        Untracked:  output/r_compare_dscout_susie_finemappip_tibble.rds
        Untracked:  output/r_compare_dscout_susie_finemappip_truth_tibble.rds
        Untracked:  output/r_compare_susieb_PIP_ROC.rds
        Untracked:  output/r_compare_susiepip_tibble.rds
        Untracked:  output/r_compare_susierss_PIP_ROC.rds
        Untracked:  output/random_data_100_sim_gaussian_null_1_get_sumstats_1_finemap_1.rds
        Untracked:  output/random_data_31_35_fit_em.rds
        Untracked:  output/random_data_76.rds
        Untracked:  output/random_data_76_sim_gaussian_8.rds
        Untracked:  output/random_data_76_sim_gaussian_8_get_sumstats_1.rds
        Untracked:  output/small_data_42_sim_gaussian_36_get_sumstats_2_susie_z_2.rds
        Untracked:  output/small_data_92_sim_gaussian_30_get_sumstats_2_susie_z_2.rds
    
    Unstaged changes:
        Modified:   analysis/SuSiEDAP_Power_data31_35.Rmd
        Modified:   analysis/SuSiErssNotConverge.Rmd
        Modified:   analysis/SusieZPerformance.Rmd
        Modified:   analysis/SusieZPerformanceRE3.Rmd
        Modified:   output/dsc_susie_z_v_output.rds
    
    
    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.
Expand here to see past versions:
    File Version Author Date Message
    html 20ad418 zouyuxin 2019-04-15 Build site.
    Rmd 295c4fd zouyuxin 2019-04-15 wflow_publish(c(“analysis/r_compare_susie_equal.Rmd”, “analysis/r_compare_susie_notequal.Rmd”))
    html 3cb758c zouyuxin 2019-04-15 Build site.
    Rmd db9fb58 zouyuxin 2019-04-15 wflow_publish(c(“analysis/r_compare_susie_equal.Rmd”, “analysis/r_compare_susie_notequal.Rmd”))
    html 7e64f54 zouyuxin 2019-04-15 Build site.
    Rmd 10db3ac zouyuxin 2019-04-15 wflow_publish(c(“analysis/r_compare_susie_equal.Rmd”, “analysis/r_compare_susie_notequal.Rmd”))
    html aea7b50 zouyuxin 2019-04-15 Build site.
    Rmd 6c860e3 zouyuxin 2019-04-15 wflow_publish(c(“analysis/r_compare_susie_equal.Rmd”, “analysis/r_compare_susie_notequal.Rmd”))
    html f9403e7 zouyuxin 2019-04-15 Build site.
    html 9330967 zouyuxin 2019-04-15 Build site.
    Rmd 97498f0 zouyuxin 2019-04-15 wflow_publish(“analysis/r_compare_susie_notequal.Rmd”)
    html 3457f12 zouyuxin 2019-04-15 Build site.
    Rmd 2b23e20 zouyuxin 2019-04-15 wflow_publish(“analysis/r_compare_susie_notequal.Rmd”)


The design matrix X are real human genotype data from GTEx project, the 150 data in dsc-finemap repo. We simulate under various number of causal variables (1,3,5) and total percentage of variance explained (0.05, 0.2, 0.6, 0.8). The effect size of each causal variable are not equal, one of the causal variable explains the majority of the PVE. Using the summary statistics from univariate regression, we fit SuSiE model using in-sample/out-sample correlation matrix, and compare their results.

library(dscrutils)
library(tibble)
Warning: package 'tibble' was built under R version 3.5.2
library(kableExtra)

Import DSC results

dscout = dscquery('r_compare_data_signal', targets = 'get_sumstats sim_gaussian.pve sim_gaussian.n_signal sim_gaussian.effect_weight data.N_in susie_bhat.ld_method susie_z.ld_method finemap.ld_method score_susie.total score_susie.valid score_susie.size score_susie.purity score_susie.top score_susie.converged score_finemap.pip', omit.filenames = FALSE)
dscout.tibble = as_tibble(dscout)
dscout = readRDS('output/r_compare_dscout_susie_finemappip_tibble.rds')
dscout$method = rep('susie_b', nrow(dscout))
dscout$method[!is.na(dscout$susie_z.ld_method)] = 'susie_rss'
dscout$method[!is.na(dscout$finemap.ld_method)] = 'finemap'

dscout$ld_method = dscout$susie_bhat.ld_method
dscout$ld_method[!is.na(dscout$susie_z.ld_method)] = dscout$susie_z.ld_method[!is.na(dscout$susie_z.ld_method)]
dscout$ld_method[!is.na(dscout$finemap.ld_method)] = dscout$finemap.ld_method[!is.na(dscout$finemap.ld_method)]
dscout$sim_gaussian.effect_weight[which(dscout$sim_gaussian.effect_weight == 'rep(1/n_signal, n_signal)')] = 'equal'
dscout$sim_gaussian.effect_weight[which(dscout$sim_gaussian.effect_weight != 'equal')] = 'notequal'
dscout = dscout[,-c(6,8,9,10)]
colnames(dscout) = c('DSC', 'filename','pve', 'n_signal', 'effect_weight', 'N_in', 'total', 'valid', 'size', 'purity', 'top', 'converged', 'pip', 'method', 'ld_method')
dscout.notequal = dscout[dscout$effect_weight == 'notequal',]
dscout.notequal.susierss = dscout.notequal[dscout.notequal$method == 'susie_rss',]
dscout.notequal.susieb = dscout.notequal[dscout.notequal$method == 'susie_b',]
dscout.notequal.finemap = dscout.notequal[dscout.notequal$method == 'finemap',]

susie_bhat

dscout.notequal.susieb.in_sample = dscout.notequal.susieb[dscout.notequal.susieb$ld_method == 'in_sample',]
dscout.notequal.susieb.out_sample = dscout.notequal.susieb[dscout.notequal.susieb$ld_method == 'out_sample',]
  • Converge

The model from susie_bhat all converge. But lots of cases with out-sample R failed (362 out of 1800). The estimated residual variance becomes negative.

converge.summary = aggregate(converged ~ ld_method, dscout.notequal.susieb, sum)
converge.summary$Fail = 1800 - converge.summary$converged
Fail = converge.summary[converge.summary$Fail!=0,]
Fail[,-2] %>% kable() %>% kable_styling(bootstrap_options = c("striped", "condensed", "responsive"), full_width = F) 
ld_method Fail
2 out_sample 362
  • Purity of CS:
purity.susieb.in_sample = round(aggregate(purity~n_signal+pve, dscout.notequal.susieb.in_sample, mean), 3)
colnames(purity.susieb.in_sample)[colnames(purity.susieb.in_sample) == 'purity'] <- 'purity.in_sample'
purity.susieb.out_sample = round(aggregate(purity~n_signal+pve, dscout.notequal.susieb.out_sample[!is.na(dscout.notequal.susieb.out_sample$converged),], mean), 3)
colnames(purity.susieb.out_sample)[colnames(purity.susieb.out_sample) == 'purity'] <- 'purity.out_sample'
purity.susieb = merge(purity.susieb.in_sample, purity.susieb.out_sample)

purity.susieb %>% kable() %>% kable_styling(bootstrap_options = c("striped", "condensed", "responsive"), full_width = F) 
n_signal pve purity.in_sample purity.out_sample
1 0.05 0.239 0.245
1 0.20 0.952 0.945
1 0.60 0.997 0.996
1 0.80 0.999 1.000
3 0.05 0.244 0.255
3 0.20 0.928 0.918
3 0.60 0.951 0.990
3 0.80 0.990 0.999
5 0.05 0.179 0.186
5 0.20 0.933 0.934
5 0.60 0.943 0.995
5 0.80 0.963 0.999
  • Power:
valid.in = aggregate(valid ~ n_signal + pve, dscout.notequal.susieb.in_sample, sum)
total.in = aggregate(DSC~ n_signal + pve, dscout.notequal.susieb.in_sample, length)
total.in$total_true = total.in$DSC * total.in$n_signal
power.susie.in = merge(valid.in, total.in)
power.susie.in$power.susie.in_sample = round(power.susie.in$valid/(power.susie.in$total_true), 3)
colnames(power.susie.in)[colnames(power.susie.in) == 'valid'] <- 'valid.in_sample'
power.susie.in = power.susie.in[,-c(3,4,5)]

valid.out = aggregate(valid ~ n_signal + pve, dscout.notequal.susieb.out_sample[!is.na(dscout.notequal.susieb.out_sample$converged),], sum)
total.out = aggregate(DSC~ n_signal + pve, dscout.notequal.susieb.out_sample[!is.na(dscout.notequal.susieb.out_sample$converged),], length)
total.out$total_true = total.out$DSC * total.out$n_signal
power.susie.out = merge(valid.out, total.out)
power.susie.out$power.susie.out_sample = round(power.susie.out$valid/(power.susie.out$total_true), 3)
colnames(power.susie.out)[colnames(power.susie.out) == 'valid'] <- 'valid.out_sample'
power.susie.out = power.susie.out[,-c(3,4,5)]

power.susie = Reduce(function(...) merge(...),
       list(power.susie.in, power.susie.out))
colnames(power.susie) = c('n_signal', 'pve', 'IN sample', 'OUT sample')
power.susie %>% kable() %>% kable_styling(bootstrap_options = c("striped", "condensed", "responsive","bordered"), full_width = F)
n_signal pve IN sample OUT sample
1 0.05 0.300 0.300
1 0.20 0.993 0.952
1 0.60 0.993 0.797
1 0.80 0.993 0.778
3 0.05 0.098 0.096
3 0.20 0.344 0.327
3 0.60 0.733 0.392
3 0.80 0.856 0.408
5 0.05 0.039 0.037
5 0.20 0.197 0.196
5 0.60 0.365 0.239
5 0.80 0.765 0.217
  • FDR:
valid.in = aggregate(valid ~ n_signal + pve, dscout.notequal.susieb.in_sample, sum)
total.in = aggregate(total~ n_signal + pve, dscout.notequal.susieb.in_sample, sum)
fdr.in = merge(valid.in, total.in)
fdr.in$fdr.in = round((fdr.in$total - fdr.in$valid)/fdr.in$total, 4)
colnames(fdr.in)[colnames(fdr.in) == 'valid'] <- 'valid.in_sample'
fdr.in = fdr.in[,-c(3,4)]

valid.out = aggregate(valid ~ n_signal + pve, dscout.notequal.susieb.out_sample[!is.na(dscout.notequal.susieb.out_sample$converged),], sum)
total.out = aggregate(total~ n_signal + pve, dscout.notequal.susieb.out_sample[!is.na(dscout.notequal.susieb.out_sample$converged),], sum)
fdr.out = merge(valid.out, total.out)
fdr.out$fdr.out = round((fdr.out$total - fdr.out$valid)/fdr.out$total, 4)
colnames(fdr.out)[colnames(fdr.out) == 'valid'] <- 'valid.out_sample'
fdr.out = fdr.out[,-c(3,4)]

fdr = Reduce(function(...) merge(...),
       list(fdr.in, fdr.out))
colnames(fdr) = c('n_signal', 'pve', 'IN sample', 'OUT sample')
fdr %>% kable() %>% kable_styling(bootstrap_options = c("striped", "condensed", "responsive","bordered"), full_width = F)
n_signal pve IN sample OUT sample
1 0.05 0.0217 0.0625
1 0.20 0.0067 0.3694
1 0.60 0.0067 0.8182
1 0.80 0.0067 0.8433
3 0.05 0.0833 0.1569
3 0.20 0.0491 0.4358
3 0.60 0.0909 0.7397
3 0.80 0.0789 0.7500
5 0.05 0.1212 0.1765
5 0.20 0.0573 0.4132
5 0.60 0.0987 0.7344
5 0.80 0.0860 0.7802

susie_rss

dscout.notequal.susierss.in_sample = dscout.notequal.susierss[dscout.notequal.susierss$ld_method == 'in_sample',]
dscout.notequal.susierss.out_sample = dscout.notequal.susierss[dscout.notequal.susierss$ld_method == 'out_sample',]
  • Converge

There are cases fail to converge in susie_rss.

converge.summary = aggregate(converged ~ pve + n_signal+ld_method, dscout.notequal.susierss, sum)
converge.summary$NotConverge = 150 - converge.summary$converged
NotConverge = converge.summary[converge.summary$NotConverge!=0,]
colnames(NotConverge) = c('pve', 'n_signal', 'ld', 'converged', 'NotConverge(out of 150)')
NotConverge[,-4] %>% kable() %>% kable_styling(bootstrap_options = c("striped", "condensed", "responsive"), full_width = F) 
pve n_signal ld NotConverge(out of 150)
3 0.6 1 in_sample 3
4 0.8 1 in_sample 8
8 0.8 3 in_sample 2
12 0.8 5 in_sample 3
15 0.6 1 out_sample 2
16 0.8 1 out_sample 6
19 0.6 3 out_sample 2
20 0.8 3 out_sample 3
23 0.6 5 out_sample 3
24 0.8 5 out_sample 3
  • Purity of CS:
purity.susierss.in_sample = round(aggregate(purity~n_signal+pve, dscout.notequal.susierss.in_sample[dscout.notequal.susierss.in_sample$converged==1,], mean), 3)
colnames(purity.susierss.in_sample)[colnames(purity.susierss.in_sample) == 'purity'] <- 'purity.in_sample'
purity.susierss.out_sample = round(aggregate(purity~n_signal+pve, dscout.notequal.susierss.out_sample[dscout.notequal.susierss.out_sample$converged==1,], mean), 3)
colnames(purity.susierss.out_sample)[colnames(purity.susierss.out_sample) == 'purity'] <- 'purity.out_sample'
purity.susierss = merge(purity.susierss.in_sample, purity.susierss.out_sample)

purity.susierss %>% kable() %>% kable_styling(bootstrap_options = c("striped", "condensed", "responsive"), full_width = F) 
n_signal pve purity.in_sample purity.out_sample
1 0.05 0.255 0.214
1 0.20 0.953 0.936
1 0.60 0.989 0.988
1 0.80 0.999 0.999
3 0.05 0.261 0.225
3 0.20 0.932 0.881
3 0.60 0.975 0.984
3 0.80 0.980 0.993
5 0.05 0.199 0.153
5 0.20 0.939 0.927
5 0.60 0.979 0.979
5 0.80 0.978 0.989
  • Power:
valid.in = aggregate(valid ~ n_signal + pve, dscout.notequal.susierss.in_sample[dscout.notequal.susierss.in_sample$converged==1,], sum)
total.in = aggregate(DSC~ n_signal + pve, dscout.notequal.susierss.in_sample[dscout.notequal.susierss.in_sample$converged==1,], length)
total.in$total_true = total.in$DSC * total.in$n_signal
power.susie.in = merge(valid.in, total.in)
power.susie.in$power.susie.in_sample = round(power.susie.in$valid/(power.susie.in$total_true), 3)
colnames(power.susie.in)[colnames(power.susie.in) == 'valid'] <- 'valid.in_sample'
power.susie.in = power.susie.in[,-c(3,4,5)]

valid.out = aggregate(valid ~ n_signal + pve, dscout.notequal.susierss.out_sample[dscout.notequal.susierss.out_sample$converged ==1,], sum)
total.out = aggregate(DSC~ n_signal + pve, dscout.notequal.susierss.out_sample[dscout.notequal.susierss.out_sample$converged ==1,], length)
total.out$total_true = total.out$DSC * total.out$n_signal
power.susie.out = merge(valid.out, total.out)
power.susie.out$power.susie.out_sample = round(power.susie.out$valid/(power.susie.out$total_true), 3)
colnames(power.susie.out)[colnames(power.susie.out) == 'valid'] <- 'valid.out_sample'
power.susie.out = power.susie.out[,-c(3,4,5)]

power.susie = Reduce(function(...) merge(...),
       list(power.susie.in, power.susie.out))
colnames(power.susie) = c('n_signal', 'pve', 'IN sample', 'OUT sample')
power.susie %>% kable() %>% kable_styling(bootstrap_options = c("striped", "condensed", "responsive","bordered"), full_width = F)
n_signal pve IN sample OUT sample
1 0.05 0.313 0.240
1 0.20 0.967 0.813
1 0.60 0.694 0.493
1 0.80 0.669 0.576
3 0.05 0.100 0.087
3 0.20 0.338 0.280
3 0.60 0.324 0.241
3 0.80 0.338 0.222
5 0.05 0.040 0.028
5 0.20 0.196 0.168
5 0.60 0.179 0.141
5 0.80 0.178 0.147
  • FDR:
valid.in = aggregate(valid ~ n_signal + pve, dscout.notequal.susierss.in_sample[dscout.notequal.susierss.in_sample$converged==1,], sum)
total.in = aggregate(total~ n_signal + pve, dscout.notequal.susierss.in_sample[dscout.notequal.susierss.in_sample$converged==1,], sum)
fdr.in = merge(valid.in, total.in)
fdr.in$fdr.in = round((fdr.in$total - fdr.in$valid)/fdr.in$total, 4)
colnames(fdr.in)[colnames(fdr.in) == 'valid'] <- 'valid.in_sample'
fdr.in = fdr.in[,-c(3,4)]

valid.out = aggregate(valid ~ n_signal + pve, dscout.notequal.susierss.out_sample[dscout.notequal.susierss.out_sample$converged==1,], sum)
total.out = aggregate(total~ n_signal + pve, dscout.notequal.susierss.out_sample[dscout.notequal.susierss.out_sample$converged==1,], sum)
fdr.out = merge(valid.out, total.out)
fdr.out$fdr.out = round((fdr.out$total - fdr.out$valid)/fdr.out$total, 4)
colnames(fdr.out)[colnames(fdr.out) == 'valid'] <- 'valid.out_sample'
fdr.out = fdr.out[,-c(3,4)]

fdr = Reduce(function(...) merge(...),
       list(fdr.in, fdr.out))
colnames(fdr) = c('n_signal', 'pve', 'IN sample', 'OUT sample')
fdr %>% kable() %>% kable_styling(bootstrap_options = c("striped", "condensed", "responsive","bordered"), full_width = F)
n_signal pve IN sample OUT sample
1 0.05 0.0208 0.1220
1 0.20 0.0333 0.2229
1 0.60 0.6832 0.8617
1 0.80 0.8370 0.8754
3 0.05 0.1000 0.1136
3 0.20 0.0559 0.2410
3 0.60 0.4931 0.7821
3 0.80 0.7132 0.8508
5 0.05 0.1667 0.2500
5 0.20 0.0577 0.2881
5 0.60 0.3853 0.7792
5 0.80 0.7050 0.8266

Session information

sessionInfo()
R version 3.5.1 (2018-07-02)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS  10.14.4

Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.5/Resources/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] kableExtra_1.0.1 tibble_2.0.1     dscrutils_0.3.3 

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.0        rstudioapi_0.9.0  xml2_1.2.0       
 [4] knitr_1.20        whisker_0.3-2     magrittr_1.5     
 [7] workflowr_1.1.1   hms_0.4.2         munsell_0.5.0    
[10] rvest_0.3.2       viridisLite_0.3.0 colorspace_1.4-0 
[13] R6_2.3.0          rlang_0.3.1       highr_0.7        
[16] httr_1.4.0        stringr_1.3.1     tools_3.5.1      
[19] webshot_0.5.1     R.oo_1.22.0       git2r_0.24.0     
[22] htmltools_0.3.6   yaml_2.2.0        rprojroot_1.3-2  
[25] digest_0.6.18     crayon_1.3.4      readr_1.3.1      
[28] R.utils_2.7.0     glue_1.3.0        evaluate_0.12    
[31] rmarkdown_1.11    stringi_1.2.4     compiler_3.5.1   
[34] pillar_1.3.1      scales_1.0.0      backports_1.1.3  
[37] R.methodsS3_1.7.1 pkgconfig_2.0.2  

This reproducible R Markdown analysis was created with workflowr 1.1.1