Last updated: 2020-09-21

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/gene_level_fine_mapping/data/train_add_hic.RData data/train_add_hic.RData
/Users/nicholeyang/Desktop/gene_level_fine_mapping/data/train_all.RData data/train_all.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 14d24c9. 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

Untracked files:
    Untracked:  data/hic_eqtl.RData
    Untracked:  data/train_add_hic.RData
    Untracked:  data/train_all.RData

Unstaged changes:
    Modified:   analysis/add_hic_feature.Rmd
    Modified:   analysis/assess_distal_observation_filtered.Rmd

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/atac_eqtl.Rmd) and HTML (docs/atac_eqtl.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 14d24c9 yunqiyang0215 2020-09-21 wflow_publish(“analysis/atac_eqtl.Rmd”)

atac = readRDS('/Users/nicholeyang/Desktop/Rotation2/data/interrogation_of_hematicells_data/peakGeneCorrelation.rds')

## load SNPs 
load('/Users/nicholeyang/Desktop/Rotation2/gene-level fine mapping/data/snp_hg19_hg38.RData')
unique(atac$chr)
 [1] chrX  chr20 chr1  chr6  chr7  chr12 chr4  chr17 chr16 chr2  chr3  chr8 
[13] chr19 chr9  chr11 chr13 chr14 chr5  chr10 chr22 chr18 chr15 chr21
23 Levels: chrX chr20 chr1 chr6 chr7 chr12 chr4 chr17 chr16 chr2 chr3 ... chr21
length(unique(atac$gene))
[1] 11905
range(atac$correlation)
[1] 0.441 0.989
head(atac)
    chr    start      end   gene correlation  p-value
6  chrX 99616179 99616679 TSPAN6       0.448 8.31e-03
16 chrX 99665839 99666339 TSPAN6       0.660 2.78e-06
17 chrX 99666697 99667197 TSPAN6       0.570 1.73e-04
18 chrX 99668153 99668653 TSPAN6       0.572 1.56e-04
21 chrX 99702599 99703099 TSPAN6       0.508 1.52e-03
36 chrX 99890747 99891247 TSPAN6       0.478 3.75e-03

99883795 99891794

head(dat_snp)
   chr     start                loc_38map
1 chr1 100643730 chr1:100178174-100178174
2 chr1 101361178 chr1:100895622-100895622
3 chr1  10271688   chr1:10211630-10211630
4 chr1 104097685 chr1:103555063-103555063
5 chr1 108588372 chr1:108045750-108045750
6 chr1 108742123 chr1:108199501-108199501
unique(dat_snp$chr)
 [1] chr1  chr10 chr11 chr12 chr13 chr14 chr15 chr16 chr17 chr18 chr19 chr2 
[13] chr20 chr21 chr22 chr3  chr4  chr5  chr6  chr7  chr8  chr9 
22 Levels: chr1 chr10 chr11 chr12 chr13 chr14 chr15 chr16 chr17 chr18 ... chr9
str(atac)
'data.frame':   643072 obs. of  6 variables:
 $ chr        : Factor w/ 23 levels "chrX","chr20",..: 1 1 1 1 1 1 1 1 1 1 ...
 $ start      : int  99616179 99665839 99666697 99668153 99702599 99890747 99891545 99983250 99990833 99998134 ...
 $ end        : int  99616679 99666339 99667197 99668653 99703099 99891247 99892045 99983750 99991333 99998634 ...
 $ gene       : Factor w/ 12003 levels "TSPAN6","DPM1",..: 1 1 1 1 1 1 1 1 1 1 ...
 $ correlation: num  0.448 0.66 0.57 0.572 0.508 0.478 0.631 0.445 0.472 0.52 ...
 $ p-value    : num  8.31e-03 2.78e-06 1.73e-04 1.56e-04 1.52e-03 3.75e-03 1.18e-05 9.06e-03 4.40e-03 1.04e-03 ...
str(dat_snp)
'data.frame':   5053 obs. of  3 variables:
 $ chr      : Factor w/ 22 levels "chr1","chr10",..: 1 1 1 1 1 1 1 1 1 1 ...
 $ start    : Factor w/ 4875 levels "100000545","100001077",..: 19 44 109 144 235 241 244 254 256 257 ...
 $ loc_38map: Factor w/ 4875 levels "chr1:100178174-100178174",..: 1 2 3 4 5 6 7 8 9 10 ...
dat_snp$start = as.numeric(as.character(dat_snp$start))
dat_snp$loc_38map = as.character(dat_snp$loc_38map)

load training data

load('/Users/nicholeyang/Desktop/gene_level_fine_mapping/data/train_add_hic.RData')
## map eqtls with atac signature 

snp_list = c()
index_list = c()
for (i in 1: dim(dat_snp)[1]){
  
  index = which(as.character(atac$chr) == as.character(dat_snp$chr[i]) & (atac$start < dat_snp$start[i]) & (atac$end > dat_snp$start[i]))
  index_list = c(index_list, index)
  
  snp = rep(dat_snp$loc_38map[i], length(index))
  snp_list = c(snp_list, snp)
}
snp_loc38 = unlist(lapply(strsplit(as.character(snp_list), '-'), function(x) x[1]))
eqtl_atac = cbind(snp_loc38, atac[index_list, ])

colnames(eqtl_atac)[5] = 'gene_name'
dat_add_hic_atac = merge(dat_add_hic, eqtl_atac, by = c('gene_name', 'snp_loc38'), all.x = TRUE)
dat_add_hic_atac2 = dat_add_hic_atac[!duplicated(dat_add_hic_atac), ]
train_all_sig = dat_add_hic_atac2[,!(names(dat_add_hic_atac2) %in% c('chr', "start","end", 'p-value'))]
train_all_sig[is.na(train_all_sig)] <- 0

save(train_all_sig, file = '/Users/nicholeyang/Desktop/gene_level_fine_mapping/data/train_all.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