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: 295c4fd

    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
    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(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(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 44 0.098 43 0.096
3 0.20 155 0.344 145 0.327
3 0.60 330 0.733 133 0.392
3 0.80 385 0.856 82 0.408
5 0.05 29 0.039 28 0.037
5 0.20 148 0.197 142 0.196
5 0.60 274 0.365 136 0.239
5 0.80 574 0.765 89 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[,-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[,-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(" ", " ", "IN sample" = 2, "OUT sample" = 2)) %>% column_spec(c(4,6), bold = T)
IN sample
OUT sample
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 44 0.0833 43 0.1569
3 0.20 155 0.0491 145 0.4358
3 0.60 330 0.0909 133 0.7397
3 0.80 385 0.0789 82 0.7500
5 0.05 29 0.1212 28 0.1765
5 0.20 148 0.0573 142 0.4132
5 0.60 274 0.0987 136 0.7344
5 0.80 574 0.0860 89 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(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(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 47 0.313 36 0.240
1 0.20 145 0.967 122 0.813
1 0.60 102 0.694 73 0.493
1 0.80 95 0.669 83 0.576
3 0.05 45 0.100 39 0.087
3 0.20 152 0.338 126 0.280
3 0.60 146 0.324 107 0.241
3 0.80 150 0.338 98 0.222
5 0.05 30 0.040 21 0.028
5 0.20 147 0.196 126 0.168
5 0.60 134 0.179 104 0.141
5 0.80 131 0.178 108 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[,-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[,-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(" ", " ", "IN sample" = 2, "OUT sample" = 2)) %>% column_spec(c(4,6), bold = T)
IN sample
OUT sample
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 45 0.1000 39 0.1136
3 0.20 152 0.0559 126 0.2410
3 0.60 146 0.4931 107 0.7821
3 0.80 150 0.7132 98 0.8508
5 0.05 30 0.1667 21 0.2500
5 0.20 147 0.0577 126 0.2881
5 0.60 134 0.3853 104 0.7792
5 0.80 131 0.7050 108 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