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: 6c860e3

    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:  analysis/r_compare_finemap.Rmd
        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
    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.
    Rmd 1949fad zouyuxin 2019-04-15 wflow_publish(c(“analysis/r_compare_susie_equal.Rmd”, “analysis/r_compare_susie_notequal.Rmd”))
    html abcd36b zouyuxin 2019-04-15 Build site.
    Rmd d06cde0 zouyuxin 2019-04-15 wflow_publish(“analysis/r_compare_susie_equal.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). We set effect size of each causal variable to be equal. 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.equal = dscout[dscout$effect_weight == 'equal',]
dscout.equal.susierss = dscout.equal[dscout.equal$method == 'susie_rss',]
dscout.equal.susieb = dscout.equal[dscout.equal$method == 'susie_b',]
dscout.equal.finemap = dscout.equal[dscout.equal$method == 'finemap',]

susie_bhat

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

The model from susie_bhat all converge. But lots of cases with out-sample R failed (274 out of 1800). The error could be negative residual variance.

converge.summary = aggregate(converged ~ ld_method, dscout.equal.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 274
  • Purity of CS:
purity.susieb.in_sample = round(aggregate(purity~n_signal+pve, dscout.equal.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.equal.susieb.out_sample[!is.na(dscout.equal.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.116 0.119
3 0.20 0.814 0.840
3 0.60 0.987 0.997
3 0.80 0.996 0.999
5 0.05 0.056 0.060
5 0.20 0.683 0.732
5 0.60 0.974 0.992
5 0.80 0.994 0.998
  • Power:
valid.in = aggregate(valid ~ n_signal + pve, dscout.equal.susieb.in_sample, sum)
total.in = aggregate(DSC~ n_signal + pve, dscout.equal.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(4,5)]

valid.out = aggregate(valid ~ n_signal + pve, dscout.equal.susieb.out_sample[!is.na(dscout.equal.susieb.out_sample$converged),], sum)
total.out = aggregate(DSC~ n_signal + pve, dscout.equal.susieb.out_sample[!is.na(dscout.equal.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(4,5)]

power.susie = Reduce(function(...) merge(...),
       list(power.susie.in, power.susie.out))
power.susie %>% kable() %>% kable_styling(bootstrap_options = c("striped", "condensed", "responsive","bordered"), full_width = F) %>% add_header_above(c(" ", " ","IN sample" = 2, "OUT sample" = 2)) %>% column_spec(c(4, 6), bold = T)
IN sample
OUT sample
n_signal pve valid.in_sample power.susie.in_sample valid.out_sample power.susie.out_sample
1 0.05 45 0.300 45 0.300
1 0.20 149 0.993 140 0.952
1 0.60 149 0.993 94 0.797
1 0.80 149 0.993 42 0.778
3 0.05 17 0.038 18 0.040
3 0.20 215 0.478 201 0.453
3 0.60 375 0.833 178 0.467
3 0.80 385 0.856 107 0.457
5 0.05 10 0.013 9 0.012
5 0.20 137 0.183 150 0.203
5 0.60 579 0.772 286 0.400
5 0.80 612 0.816 229 0.405
  • FDR
valid.in = aggregate(valid ~ n_signal + pve, dscout.equal.susieb.in_sample, sum)
total.in = aggregate(total~ n_signal + pve, dscout.equal.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[,-4]

valid.out = aggregate(valid ~ n_signal + pve, dscout.equal.susieb.out_sample[!is.na(dscout.equal.susieb.out_sample$converged),], sum)
total.out = aggregate(total~ n_signal + pve, dscout.equal.susieb.out_sample[!is.na(dscout.equal.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[,-4]

fdr = Reduce(function(...) merge(...),
       list(fdr.in, fdr.out))

fdr %>% kable() %>% kable_styling(bootstrap_options = c("striped", "condensed", "responsive","bordered"), full_width = F) %>% add_header_above(c(" ", " ", "SuSiE b" = 2, "SuSiE rss" = 2)) %>% column_spec(c(4,6), bold = T)
SuSiE b
SuSiE rss
n_signal pve valid.in_sample fdr.in valid.out_sample fdr.out
1 0.05 45 0.0217 45 0.0625
1 0.20 149 0.0067 140 0.3694
1 0.60 149 0.0067 94 0.8182
1 0.80 149 0.0067 42 0.8433
3 0.05 17 0.2273 18 0.2500
3 0.20 215 0.1502 201 0.3619
3 0.60 375 0.1176 178 0.6973
3 0.80 385 0.1387 107 0.7206
5 0.05 10 0.0909 9 0.1818
5 0.20 137 0.1988 150 0.4094
5 0.60 579 0.1267 286 0.5855
5 0.80 612 0.1319 229 0.5918

susie_rss

dscout.equal.susierss.in_sample = dscout.equal.susierss[dscout.equal.susierss$ld_method == 'in_sample',]
dscout.equal.susierss.out_sample = dscout.equal.susierss[dscout.equal.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.equal.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 1
12 0.8 5 in_sample 1
15 0.6 1 out_sample 2
16 0.8 1 out_sample 6
20 0.8 3 out_sample 1
24 0.8 5 out_sample 1
  • Purity of CS:
purity.susierss.in_sample = round(aggregate(purity~n_signal+pve, dscout.equal.susierss.in_sample[dscout.equal.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.equal.susierss.out_sample[dscout.equal.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.123 0.108
3 0.20 0.832 0.734
3 0.60 0.980 0.962
3 0.80 0.989 0.985
5 0.05 0.066 0.050
5 0.20 0.679 0.647
5 0.60 0.955 0.938
5 0.80 0.974 0.970
  • Power:
valid.in = aggregate(valid ~ n_signal + pve, dscout.equal.susierss.in_sample[dscout.equal.susierss.in_sample$converged==1,], sum)
total.in = aggregate(DSC~ n_signal + pve, dscout.equal.susierss.in_sample[dscout.equal.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'

valid.out = aggregate(valid ~ n_signal + pve, dscout.equal.susierss.out_sample[dscout.equal.susierss.out_sample$converged ==1,], sum)
total.out = aggregate(DSC~ n_signal + pve, dscout.equal.susierss.out_sample[dscout.equal.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 = Reduce(function(...) merge(...),
       list(power.susie.in, power.susie.out))
power.susie = power.susie[,-c(3,4)]
power.susie %>% kable() %>% kable_styling(bootstrap_options = c("striped", "condensed", "responsive","bordered"), full_width = F) %>% add_header_above(c(" ", " ","IN sample" = 2, "OUT sample" = 2)) %>% column_spec(c(4, 6), bold = T)
IN sample
OUT sample
n_signal pve valid.in_sample power.susie.in_sample valid.out_sample power.susie.out_sample
1 0.05 47 0.313 36 0.240
1 0.20 145 0.967 122 0.813
3 0.05 18 0.040 17 0.038
3 0.20 195 0.433 150 0.333
3 0.60 350 0.778 224 0.498
3 0.80 333 0.745 202 0.452
5 0.05 11 0.015 8 0.011
5 0.20 132 0.176 104 0.139
5 0.60 497 0.663 307 0.409
5 0.80 527 0.707 309 0.415
  • FDR:
valid.in = aggregate(valid ~ n_signal + pve, dscout.equal.susierss.in_sample[dscout.equal.susierss.in_sample$converged==1,], sum)
total.in = aggregate(total~ n_signal + pve, dscout.equal.susierss.in_sample[dscout.equal.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[,-4]

valid.out = aggregate(valid ~ n_signal + pve, dscout.equal.susierss.out_sample[dscout.equal.susierss.out_sample$converged==1,], sum)
total.out = aggregate(total~ n_signal + pve, dscout.equal.susierss.out_sample[dscout.equal.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[,-4]

fdr = Reduce(function(...) merge(...),
       list(fdr.in, fdr.out))

fdr %>% kable() %>% kable_styling(bootstrap_options = c("striped", "condensed", "responsive","bordered"), full_width = F) %>% add_header_above(c(" ", " ", "SuSiE b" = 2, "SuSiE rss" = 2)) %>% column_spec(c(4,6), bold = T)
SuSiE b
SuSiE rss
n_signal pve valid.in_sample fdr.in valid.out_sample fdr.out
1 0.05 47 0.0208 36 0.1220
1 0.20 145 0.0333 122 0.2229
1 0.60 102 0.6832 73 0.8617
1 0.80 95 0.8370 83 0.8754
3 0.05 18 0.2174 17 0.1905
3 0.20 195 0.1772 150 0.3056
3 0.60 350 0.1898 224 0.5650
3 0.80 333 0.2854 202 0.6599
5 0.05 11 0.1538 8 0.2000
5 0.20 132 0.2048 104 0.3418
5 0.60 497 0.1605 307 0.4661
5 0.80 527 0.1930 309 0.5261

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