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 d0ad5a2. 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/
Untracked files:
Untracked: analysis/train_add_hic.RData
Untracked: data/hic_eqtl.RData
Untracked: data/train_add_hic.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/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 | d0ad5a2 | yunqiyang0215 | 2020-08-05 | wflow_publish(“analysis/add_hic_feature.Rmd”) |
load("/Users/nicholeyang/Desktop/Rotation2/data/hic_eqtl.RData")
hic_eqtl2 = hic_eqtl[!is.na(hic_eqtl$baitName), ]
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, ]
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 = ':')
var_loc = strsplit(as.character(hic_eqtl3$loc_38map), '-')
hic_eqtl3$snp_loc38 = unlist(lapply(var_loc, function(x) x[1]))
## restrict to coding gene
coding_gene_list = read.table('/Users/nicholeyang/Desktop/Rotation2/data/coding_gene_list.txt', header = TRUE)
coding_gene_list$bait_gene = coding_gene_list$Approved_symbol
hic_eqtl4 = merge(coding_gene_list, hic_eqtl3, by = 'bait_gene', all = FALSE)
colnames(hic_eqtl4)[1] = 'gene_name'
tail(dat)
gene_name variant_id UTR5 UTR3 exon intron upstream
121265 SEC61B chr9_99153605_C_T_b38 0 0 0 0 0
49988 GALNT12 chr9_99153605_C_T_b38 0 0 0 0 0
4837 ALG2 chr9_99153605_C_T_b38 0 0 0 0 0
49602 GABBR2 chr9_99153605_C_T_b38 0 0 0 0 0
6225 ANKS6 chr9_99153605_C_T_b38 0 0 0 0 0
28348 COL15A1 chr9_99153605_C_T_b38 0 0 0 0 0
tss_dist_to_snp y snp_loc38
121265 68696 0 chr9:99153605
49988 345906 0 chr9:99153605
4837 67535 0 chr9:99153605
49602 444408 0 chr9:99153605
6225 357066 0 chr9:99153605
28348 209966 0 chr9:99153605
Among all the gene-snp pairs, ~9500 hic features are added.
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)
}
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