Last updated: 2020-07-10

Checks: 6 1

Knit directory: gene-level fine mapping/

This reproducible R Markdown analysis was created with workflowr (version 1.6.1). 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(20200622) 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
/Users/nicholeyang/Desktop/Rotation2/gene-level fine mapping/data/SNPs_causal.RData data/SNPs_causal.RData

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 d183f85. 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:    .DS_Store
    Ignored:    .Rhistory
    Ignored:    .Rproj.user/
    Ignored:    analysis/.DS_Store
    Ignored:    analysis/.RData
    Ignored:    analysis/.Rhistory
    Ignored:    data/.DS_Store

Untracked files:
    Untracked:  analysis/annovar.Rmd
    Untracked:  analysis/gene_annotation.Rmd
    Untracked:  data/Homo_sapiens.GRCh37.87.gtf
    Untracked:  data/Homo_sapiens.GRCh37.87.gtf.gz
    Untracked:  data/README (1)
    Untracked:  data/SNPs_causal.RData
    Untracked:  data/dt_pos_processed.RData
    Untracked:  dt_pos_processed.RData

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/eqtl_process.Rmd) and HTML (docs/eqtl_process.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 d183f85 yunqiyang0215 2020-07-10 wflow_publish(“analysis/eqtl_process.Rmd”)
html 044f64c yunqiyang0215 2020-07-01 Build site.
html aedb190 yunqiyang0215 2020-07-01 Build site.
Rmd 82cc76e yunqiyang0215 2020-07-01 wflow_publish(“analysis/eqtl_process.Rmd”)

create positive gene-SNP set

# unix command 
srun --pty --mem 5G -t 01:00:00 /bin/bash
module load R
R
setwd("/home/yunqiyang/summer_rotation/whole_blood_eqtl")
dt = read.table("Whole_Blood.variants_pip.txt", header = TRUE)

dim(dt) # 420370 6
sum(is.na(dt)) # 0
setEPS()
postscript("pip_summary.eps")
hist(dt$pip)
dev.off()
length(unique(dt$gene)) # 15252
sum(dt$pip>0.5) # 5080
sum(dt$pip>0.8) # 2751
sum(dt$pip>0.1) # 28559
# save data 
dt_pos = dt[dt$pip>0.5, ]
dt_neg = dt[-(dt$pip>0.5), ]

save(dt_pos, file = 'SNPs_causal.RData')
save(dt_neg, file = 'SNPs_control.RData')

processing gene-SNP positive set

# load fine-mapping positive set
load("/Users/nicholeyang/Desktop/Rotation2/gene-level fine mapping/data/SNPs_causal.RData")

split snp info into multiple columns

dt_pos$variant_id = as.character(dt_pos$variant_id)
var_position = strsplit(dt_pos$variant_id, '_')

chr = rep(NA, length(var_position))
SNP_loc = rep(NA, length(var_position))
  
for (i in 1:length(var_position)){
  chr[i] = var_position[[i]][1]
  SNP_loc[i] = var_position[[i]][2]
}
chr = unlist(lapply(var_position, function(x) x[1]))
dt_pos$SNP_chr = gsub('\\D','', chr)
dt_pos$SNP_loc = unlist(lapply(var_position, function(x) x[2]))

create gene_id without gene version number

gene_seg = strsplit(as.character(dt_pos$gene), '.', fixed = TRUE)
dt_pos$gene_id = unlist(lapply(gene_seg, function(x) x[1]))
head(dt_pos)
                  gene rank             variant_id      pip log10_abf
5   ENSG00000000457.13    1 chr1_169891332_G_A_b38 0.939551    20.142
43  ENSG00000000460.16    1 chr1_169661963_G_A_b38 0.580082     5.656
307  ENSG00000001561.6    1  chr6_46130021_C_G_b38 0.657995     5.590
308  ENSG00000001561.6    2 chr6_46129743_G_GT_b38 0.513630    22.020
418  ENSG00000001629.9    1  chr7_92245996_C_T_b38 0.520558     7.253
594 ENSG00000002016.17    1   chr12_949572_C_G_b38 0.522047    23.668
    cluster_id SNP_chr   SNP_loc         gene_id
5            1       1 169891332 ENSG00000000457
43           1       1 169661963 ENSG00000000460
307          2       6  46130021 ENSG00000001561
308          3       6  46129743 ENSG00000001561
418          1       7  92245996 ENSG00000001629
594          2      12    949572 ENSG00000002016
save(dt_pos, file = 'dt_pos_processed.RData')

sessionInfo()
R version 3.6.3 (2020-02-29)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Catalina 10.15.5

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.6/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] workflowr_1.6.1

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.4      rprojroot_1.3-2 digest_0.6.25   later_1.0.0    
 [5] R6_2.4.1        backports_1.1.5 git2r_0.26.1    magrittr_1.5   
 [9] evaluate_0.14   highr_0.8       stringi_1.4.6   rlang_0.4.5    
[13] fs_1.3.2        promises_1.1.0  whisker_0.4     rmarkdown_2.1  
[17] tools_3.6.3     stringr_1.4.0   glue_1.3.2      httpuv_1.5.2   
[21] xfun_0.12       yaml_2.2.1      compiler_3.6.3  htmltools_0.4.0
[25] knitr_1.28