Last updated: 2020-08-05
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/training.RData | data/training.RData |
/Users/nicholeyang/Desktop/gene_level_fine_mapping/data/train_add_hic.RData | data/train_add_hic.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 e85eacc. 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
Untracked files:
Untracked: data/hic_eqtl.RData
Untracked: data/train_add_hic.RData
Unstaged changes:
Modified: analysis/model_hic.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/add_hic_feature.Rmd
) and HTML (docs/add_hic_feature.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 | e85eacc | yunqiyang0215 | 2020-08-05 | wflow_publish(“analysis/add_hic_feature.Rmd”) |
html | d74427c | yunqiyang0215 | 2020-08-05 | Build site. |
Rmd | d0ad5a2 | yunqiyang0215 | 2020-08-05 | wflow_publish(“analysis/add_hic_feature.Rmd”) |
load("/Users/nicholeyang/Desktop/Rotation2/data/hic_eqtl.RData")
head(hic_eqtl)
chr start loc_38map baitChr baitStart baitEnd
df_snps 1 100643730 chr1:100178174-100178174 1 100713369 100722257
X2 1 101361178 chr1:100895622-100895622 1 87379937 87381019
X2.1 1 101361178 chr1:100895622-100895622 1 95536274 95538845
X2.2 1 101361178 chr1:100895622-100895622 1 98385116 98389489
X2.3 1 101361178 chr1:100895622-100895622 1 100231938 100238252
X2.4 1 101361178 chr1:100895622-100895622 1 100249523 100251737
baitID baitName oeChr oeStart oeEnd oeID oeName
df_snps 27326 DBT;RP11-305E17.4 1 100634352 100646989 27306 LRRC39
X2 23051 HS2ST1;SEP15 1 101360898 101363055 27516 EXTL2;SLC30A7
X2.1 25596 ALG14 1 101360898 101363055 27516 EXTL2;SLC30A7
X2.2 26553 DPYD 1 101360898 101363055 27516 EXTL2;SLC30A7
X2.3 27180 FRRS1 1 101360898 101363055 27516 EXTL2;SLC30A7
X2.4 27182 RNU4-75P 1 101360898 101363055 27516 EXTL2;SLC30A7
dist Mon Mac0 Mac1
df_snps -77142 1.34843055599415 1.78921772839366 1.99634719222292
X2 13981499 0 0 0
X2.1 5824417 0 0.465695547029591 0
X2.2 2974674 0 0.926519775296238 2.52224939360564
X2.3 1126882 2.89316496564785 10.7618511038685 6.6110787600356
X2.4 1111347 2.24744093217506 9.70507665907856 5.92291542638399
Mac2 Neu MK EP
df_snps 3.84121648347469 6.6419009785134 3.04135339426089 1.34115496917577
X2 0 0 0 0
X2.1 0 0 0 0
X2.2 1.84838858472344 0 0 0
X2.3 8.87116886614274 0 7.36660394659741 0
X2.4 5.21110811135408 3.27608835168057 5.65619485450452 1.37318289845971
Ery FoeT nCD4 tCD4
df_snps 5.67015582143414 3.05676235556647 2.93116627100789 2.82620900824891
X2 0 5.98672074531884 7.64738754701126 3.7619497300554
X2.1 0 0 1.13980263210717 0
X2.2 0 7.01735672371564 7.02105829238459 5.33996347469841
X2.3 9.60222489674592 1.19872663945268 2.40955754341805 0.883580083863637
X2.4 6.76819441601615 0.229785161823062 6.13067570692578 8.16139741483703
aCD4 naCD4 nCD8 tCD8
df_snps 3.01147313782106 3.19101824842048 2.20595105037866 2.19621256112425
X2 6.72053163467254 9.91922157469345 0 7.5966163534812
X2.1 0.394818585888307 2.69464062510513 5.03898592801291 3.93778263870396
X2.2 3.47660053737806 7.32439411893241 3.95130982543128 3.52920996524329
X2.3 1.19474781222933 1.4353267284434 2.03706000977369 2.20463021502093
X2.4 4.97039210529628 3.84760946495465 5.48068559290623 4.8540590419425
nB tB clusterID clusterPostProb
df_snps 4.13498913605023 5.24561817997031 7 0.815
X2 0 0 10 0.999
X2.1 0 0 10 0.912
X2.2 0.350167329501555 1.75640180174979 10 0.812
X2.3 2.30542223744791 3.47593895897212 32 0.854
X2.4 9.79918042442615 4.92540990098449 21 0.866
## remove NA genes
hic_eqtl2 = hic_eqtl[!is.na(hic_eqtl$baitName), ]
## split those with several bait genes
bait_gene = strsplit(as.character(hic_eqtl2$baitName), ';')
ngenes = lapply(bait_gene, function(x) length(x))
index_list = c()
for(i in 1:dim(hic_eqtl2)[1]){
index = rep(i, ngenes[[i]])
index_list = c(index_list, index)
}
hic_eqtl3 = hic_eqtl2[index_list, ]
hic_eqtl3$bait_gene = unlist(bait_gene)
load("/Users/nicholeyang/Desktop/gene_level_fine_mapping/data/training.RData")
## remove NAs
dat = rbind(train_pos_all, train_neg_all)
NAs = apply(dat, 1, function(x) sum(is.na(x)))
dat = dat[NAs == 0, ]
## add variable snp_loc38 to training data
var_loc = strsplit(as.character(dat$variant_id), '_')
dat$snp_loc38 = paste(unlist(lapply(var_loc, function(x) x[1])), unlist(lapply(var_loc, function(x) x[2])), sep = ':')
## add variable snp_loc38 to hic_eqtl3
var_loc = strsplit(as.character(hic_eqtl3$loc_38map), '-')
hic_eqtl3$snp_loc38 = unlist(lapply(var_loc, function(x) x[1]))
coding_gene_list = read.table('/Users/nicholeyang/Desktop/Rotation2/data/coding_gene_list.txt', header = TRUE)
coding_gene_list$gene_name = coding_gene_list$Approved_symbol
hic_eqtl3$gene_name = hic_eqtl3$bait_gene
hic_eqtl4 = merge(coding_gene_list, hic_eqtl3, by = 'gene_name', all = FALSE)
dim(hic_eqtl4)[1]
[1] 18776
index_in_hic = c()
for(i in 1:dim(dat)[1]){
index = which(dat[i, ]$gene_name == hic_eqtl4$gene_name & dat[i, ]$snp_loc38 == hic_eqtl4$snp_loc38)
index_in_hic = c(index_in_hic, index)
}
length(index_in_hic)
[1] 9452
train_hic = hic_eqtl4[index_in_hic, c("gene_name", "Mon", "Mac0", "Mac1", "Mac2", "Neu",
"MK", "EP", "Ery", "FoeT", "nCD4", "tCD4", "aCD4",
"naCD4", "nCD8", "tCD8", "nB", "tB","snp_loc38")]
dat_add_hic = merge(dat, train_hic, by = c('gene_name', 'snp_loc38'), all = TRUE)
## check NAs
Nas = apply(dat_add_hic, 2, function(x) sum(is.na(x)))
Nas
gene_name snp_loc38 variant_id UTR5 UTR3
0 0 0 0 0
exon intron upstream tss_dist_to_snp y
0 0 0 0 0
Mon Mac0 Mac1 Mac2 Neu
57448 57448 57448 57448 57448
MK EP Ery FoeT nCD4
57448 57448 57448 57448 57448
tCD4 aCD4 naCD4 nCD8 tCD8
57448 57448 57448 57448 57448
nB tB
57448 57448
## replace NAs with 0
dat_add_hic[is.na(dat_add_hic)] <- 0
## binary the hic features
cols = c("Mon", "Mac0", "Mac1", "Mac2", "Neu", "MK", "EP", "Ery", "FoeT",
"nCD4", "tCD4", "aCD4", "naCD4", "nCD8", "tCD8", "nB", "tB")
for( i in 1:length(cols)){
dat_add_hic[, cols[i]] = ifelse(as.numeric(as.character(dat_add_hic[, cols[i]])) >5, 1, 0)
}
save(dat_add_hic, file = '/Users/nicholeyang/Desktop/gene_level_fine_mapping/data/train_add_hic.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