Last updated: 2024-08-27
Checks: 7 0
Knit directory: survival-data-analysis/
This reproducible R Markdown analysis was created with workflowr (version 1.6.2). 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(20240324)
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.
Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.
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 c73aa55. 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: output/.DS_Store
Ignored: scripts/.DS_Store
Ignored: scripts/.RData
Ignored: scripts/.Rhistory
Untracked files:
Untracked: data/gwas_chr17_33500001_39800000.txt
Unstaged changes:
Modified: analysis/gwas_pval_summary.Rmd
Modified: output/logistic_surv_comparison/top_signal_LR_AA.csv
Deleted: output/top_signal_AA.csv
Deleted: output/top_signal_AOA.csv
Deleted: output/top_signal_COA.csv
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/region_cut.Rmd
) and HTML (docs/region_cut.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 | c73aa55 | yunqiyang0215 | 2024-08-27 | wflow_publish("analysis/region_cut.Rmd") |
html | c417e68 | yunqiyang0215 | 2024-06-26 | Build site. |
Rmd | e6e18d5 | yunqiyang0215 | 2024-06-26 | wflow_publish("analysis/region_cut.Rmd") |
html | 0c4354b | yunqiyang0215 | 2024-06-18 | Build site. |
Rmd | d9c6599 | yunqiyang0215 | 2024-06-18 | wflow_publish("analysis/region_cut.Rmd") |
html | ebeca15 | yunqiyang0215 | 2024-06-18 | Build site. |
Rmd | 2b1f395 | yunqiyang0215 | 2024-06-18 | wflow_publish("analysis/region_cut.Rmd") |
This file cut the regions from survival GWAS results to create smaller regions for fine-mapping. We first find the top signal (smallest pvalue.spa) based on the preferred analysis, and select the region +- 250kb around the top signal.
regions = c("chr1_150600001_155100000",
"chr10_6600001_12200000",
"chr11_75500001_77400000",
"chr15_59000001_63400000",
"chr17_33500001_39800000",
"chr2_102100001_105300000",
"chr6_30500001_32100000",
"chr12_46000001_48700000",
"chr2_143400001_147900000")
analysis.prefer = c("coa", "aa", "aa", "aa","coa", "aa", "aa", "aoa", "aoa")
dist = 250000
for (i in 1:length(regions)){
reg = regions[i]
if (analysis.prefer[i] == "aa"){
path.surv = paste0("/Users/nicholeyang/Downloads/survivalsusie/result/gwas_surv/all_gwas_", reg, ".rds")
path.logit = paste0("/Users/nicholeyang/Downloads/survivalsusie/data/gwas_logistic_out/all/gwas_", reg, ".asthma.glm.logistic")
}
if (analysis.prefer[i] == "coa"){
path.surv = paste0("/Users/nicholeyang/Downloads/survivalsusie/result/gwas_surv/coa_gwas_", reg, ".rds")
path.logit = paste0("/Users/nicholeyang/Downloads/survivalsusie/data/gwas_logistic_out/coa/gwas_", reg, ".asthma_coa.glm.logistic")
}
if (analysis.prefer[i] == "aoa"){
path.surv = paste0("/Users/nicholeyang/Downloads/survivalsusie/result/gwas_surv/aoa_gwas_", reg, ".rds")
path.logit = paste0("/Users/nicholeyang/Downloads/survivalsusie/data/gwas_logistic_out/aoa/gwas_", reg, ".asthma_aoa.glm.logistic")
}
gwas.surv = data.frame(readRDS(path.surv))
gwas.logit = read.csv(path.logit, header = TRUE, sep = "\t")
gwas.surv$ID = sapply(1:nrow(gwas.surv), function(i) strsplit(rownames(gwas.surv)[i], "_")[[1]][1])
gwas.surv$variant = rownames(gwas.surv)
dat = merge(gwas.surv, gwas.logit, by = "ID")
top = which(dat$p.value.spa == min(dat$p.value.spa, na.rm = TRUE))
pos_start = dat$POS[top] - dist
pos_end = dat$POS[top] + dist
indx = which(dat$POS > pos_start & dat$POS < pos_end)
print(paste0("There are ", length(dat$variant[indx]), " SNPs remain in ", reg))
write.table(dat$variant[indx],
paste0("/Users/nicholeyang/Downloads/survivalsusie/data/asthma_finemap_snplist202408/sub_", reg, '.txt'))
}
[1] "There are 1333 SNPs remain in chr1_150600001_155100000"
[1] "There are 1651 SNPs remain in chr10_6600001_12200000"
[1] "There are 1628 SNPs remain in chr11_75500001_77400000"
[1] "There are 1558 SNPs remain in chr15_59000001_63400000"
[1] "There are 1212 SNPs remain in chr17_33500001_39800000"
[1] "There are 1821 SNPs remain in chr2_102100001_105300000"
[1] "There are 9934 SNPs remain in chr6_30500001_32100000"
[1] "There are 1595 SNPs remain in chr12_46000001_48700000"
[1] "There are 1190 SNPs remain in chr2_143400001_147900000"
select the top signal + surrounding SNPs based on all asthma;
select the top signal + surrounding SNPs based on AOA.
par(mfrow = c(4,2))
dir = "/Users/nicholeyang/Downloads/survivalsusie/result/gwas_surv"
for (reg in regions){
file_path = paste0(dir, "/all_gwas_", reg, ".rds")
gwas = data.frame(readRDS(file_path))
print(paste0("There are ", nrow(gwas), " SNPs in ", reg))
top = which(gwas$p.value.spa == min(gwas$p.value.spa))
start = top - 2500
end = top + 2500
if (reg == "chr1_150600001_155100000"){ start = top - 1500}
if (reg == "chr11_75500001_77400000"){
start = top - 1000
end = top + 1000
}
if (reg == "chr15_59000001_63400000") {
start = top - 500
end = top + 500
}
if (reg == "chr17_33500001_39800000"){start = top - 1500}
start = max(1, start)
end = min(nrow(gwas), end)
print(paste0("There are ", nrow(gwas[start:end, ]), " SNPs remain in ", reg))
plot(-log10(gwas[start:end, ]$p.value.spa),pch = 20, cex = 0.5, main = reg)
write.table(rownames(gwas[start:end, ]),
paste0("/Users/nicholeyang/Downloads/survivalsusie/data/asthma_finemap_snplist/sub_", reg, '.txt'))
}
[1] "There are 10507 SNPs in chr1_150600001_155100000"
[1] "There are 4001 SNPs remain in chr1_150600001_155100000"
[1] "There are 21347 SNPs in chr10_6600001_12200000"
[1] "There are 5001 SNPs remain in chr10_6600001_12200000"
[1] "There are 5352 SNPs in chr11_75500001_77400000"
[1] "There are 2001 SNPs remain in chr11_75500001_77400000"
[1] "There are 13682 SNPs in chr15_59000001_63400000"
[1] "There are 1001 SNPs remain in chr15_59000001_63400000"
[1] "There are 16832 SNPs in chr17_33500001_39800000"
[1] "There are 4001 SNPs remain in chr17_33500001_39800000"
[1] "There are 8043 SNPs in chr2_102100001_105300000"
[1] "There are 4780 SNPs remain in chr2_102100001_105300000"
[1] "There are 14915 SNPs in chr6_30500001_32100000"
[1] "There are 5001 SNPs remain in chr6_30500001_32100000"
[1] "There are 7941 SNPs in chr12_46000001_48700000"
[1] "There are 3580 SNPs remain in chr12_46000001_48700000"
Version | Author | Date |
---|---|---|
ebeca15 | yunqiyang0215 | 2024-06-18 |
[1] "There are 9647 SNPs in chr2_143400001_147900000"
[1] "There are 5001 SNPs remain in chr2_143400001_147900000"
reg = "chr12_46000001_48700000"
file_path = "/Users/nicholeyang/Downloads/survivalsusie/result/gwas_surv/aoa_gwas_chr12_46000001_48700000.rds"
gwas = data.frame(readRDS(file_path))
start = 5500
end = 7000
plot(-log10(gwas[start:end, ]$p.value.spa),pch = 20, cex = 0.5, main = reg)
write.table(rownames(gwas[start:end, ]),
paste0("/Users/nicholeyang/Downloads/survivalsusie/data/asthma_finemap_snplist/sub_", reg, '.txt'))
reg = "chr2_143400001_147900000"
file_path = "/Users/nicholeyang/Downloads/survivalsusie/result/gwas_surv/aoa_gwas_chr2_143400001_147900000.rds"
gwas = data.frame(readRDS(file_path))
start = 5000
end = 7000
plot(-log10(gwas[start:end, ]$p.value.spa),pch = 20, cex = 0.5, main = reg)
write.table(rownames(gwas[start:end, ]),
paste0("/Users/nicholeyang/Downloads/survivalsusie/data/asthma_finemap_snplist/sub_", reg, '.txt'))
sessionInfo()
R version 4.1.1 (2021-08-10)
Platform: x86_64-apple-darwin20.6.0 (64-bit)
Running under: macOS Monterey 12.0.1
Matrix products: default
BLAS: /usr/local/Cellar/openblas/0.3.18/lib/libopenblasp-r0.3.18.dylib
LAPACK: /usr/local/Cellar/r/4.1.1_1/lib/R/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.2
loaded via a namespace (and not attached):
[1] Rcpp_1.0.8.3 rstudioapi_0.13 whisker_0.4 knitr_1.36
[5] magrittr_2.0.1 R6_2.5.1 rlang_1.1.1 fastmap_1.1.0
[9] fansi_0.5.0 highr_0.9 stringr_1.4.0 tools_4.1.1
[13] xfun_0.27 utf8_1.2.2 cli_3.6.1 git2r_0.28.0
[17] jquerylib_0.1.4 htmltools_0.5.5 ellipsis_0.3.2 rprojroot_2.0.2
[21] yaml_2.2.1 digest_0.6.28 tibble_3.1.5 lifecycle_1.0.3
[25] later_1.3.0 sass_0.4.4 vctrs_0.6.3 promises_1.2.0.1
[29] fs_1.5.0 cachem_1.0.6 glue_1.4.2 evaluate_0.14
[33] rmarkdown_2.11 stringi_1.7.5 bslib_0.4.1 compiler_4.1.1
[37] pillar_1.9.0 jsonlite_1.7.2 httpuv_1.6.3 pkgconfig_2.0.3