Last updated: 2024-08-29

Checks: 6 1

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.

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/Downloads/survival-data-analysis/output/logistic_surv_comparison/top_signal_AA.csv output/logistic_surv_comparison/top_signal_AA.csv
/Users/nicholeyang/Downloads/survival-data-analysis/output/logistic_surv_comparison/top_signal_COA.csv output/logistic_surv_comparison/top_signal_COA.csv
/Users/nicholeyang/Downloads/survival-data-analysis/output/logistic_surv_comparison/top_signal_AOA.csv output/logistic_surv_comparison/top_signal_AOA.csv
/Users/nicholeyang/Downloads/survival-data-analysis/output/logistic_surv_comparison/top_signal_LR_AA.csv output/logistic_surv_comparison/top_signal_LR_AA.csv
/Users/nicholeyang/Downloads/survival-data-analysis/output/logistic_surv_comparison/top_signal_LR_COA.csv output/logistic_surv_comparison/top_signal_LR_COA.csv
/Users/nicholeyang/Downloads/survival-data-analysis/output/logistic_surv_comparison/top_signal_LR_AOA.csv output/logistic_surv_comparison/top_signal_LR_AOA.csv
/Users/nicholeyang/Downloads/survival-data-analysis/output/top_signal.pdf output/top_signal.pdf

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 0e38750. 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:   output/logistic_surv_comparison/top_signal_LR_AA.csv
    Modified:   output/logistic_surv_comparison/top_signal_LR_AOA.csv
    Modified:   output/logistic_surv_comparison/top_signal_LR_COA.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/gwas_pval_summary.Rmd) and HTML (docs/gwas_pval_summary.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 0e38750 yunqiyang0215 2024-08-29 wflow_publish("analysis/gwas_pval_summary.Rmd")
html 22a99d2 yunqiyang0215 2024-08-28 Build site.
html 82b913b yunqiyang0215 2024-08-28 Build site.
Rmd 884e25a yunqiyang0215 2024-08-28 wflow_publish("analysis/gwas_pval_summary.Rmd")
html c0e1aa5 yunqiyang0215 2024-08-28 Build site.
Rmd f59aa54 yunqiyang0215 2024-08-28 wflow_publish("analysis/gwas_pval_summary.Rmd")
html c288e8c yunqiyang0215 2024-08-16 Build site.
Rmd 1461dc1 yunqiyang0215 2024-08-16 wflow_publish("analysis/gwas_pval_summary.Rmd")
html 8376452 yunqiyang0215 2024-08-15 Build site.
Rmd e405310 yunqiyang0215 2024-08-15 wflow_publish("analysis/gwas_pval_summary.Rmd")
html 2241d7c yunqiyang0215 2024-08-15 Build site.
Rmd 6634fcd yunqiyang0215 2024-08-15 wflow_publish("analysis/gwas_pval_summary.Rmd")
html 9e4ae0d yunqiyang0215 2024-07-29 Build site.
Rmd 8f45318 yunqiyang0215 2024-07-29 wflow_publish("analysis/gwas_pval_summary.Rmd")
html 868041d yunqiyang0215 2024-07-24 Build site.
Rmd 72826b8 yunqiyang0215 2024-07-24 wflow_publish("analysis/gwas_pval_summary.Rmd")
html 883fe5e yunqiyang0215 2024-07-03 Build site.
Rmd 444349b yunqiyang0215 2024-07-03 wflow_publish("analysis/gwas_pval_summary.Rmd")
html 528677f yunqiyang0215 2024-07-03 Build site.
Rmd 8128e8f yunqiyang0215 2024-07-03 wflow_publish("analysis/gwas_pval_summary.Rmd")

library(stringr)
logistic.aoa <- list.files(path="/Users/nicholeyang/Downloads/survivalsusie/data/gwas_logistic_out/aoa", pattern = "\\.glm\\.logistic$", full.names = TRUE)
logistic.coa <- list.files(path="/Users/nicholeyang/Downloads/survivalsusie/data/gwas_logistic_out/coa", pattern = "\\.glm\\.logistic$", full.names = TRUE)

logistic <- list.files(path="/Users/nicholeyang/Downloads/survivalsusie/data/gwas_logistic_out/all", pattern = "\\.glm\\.logistic$", full.names = TRUE)
dir = "/Users/nicholeyang/Downloads/survivalsusie/result/gwas_surv"
surv.aoa <- list.files(path = dir, pattern = "^aoa.*\\.rds$", full.names = TRUE)
surv.coa <- list.files(path = dir, pattern = "^coa.*\\.rds$", full.names = TRUE)
surv <- list.files(path = dir, pattern = "^all.*\\.rds$", full.names = TRUE)

1. All asthma

## Based on logistic pvalue
pattern <- "chr[0-9XYM]+_[0-9]+_[0-9]+"
pval.all = data.frame(matrix(NA, nrow = length(logistic), ncol = 4))
colnames(pval.all) = c("region", "snp", "logistic", "coxph")
for (i in 1:length(logistic)){
  path = logistic[i]
  region = str_extract(path, pattern)
  gwas.logistic = read.csv(path, header = TRUE, sep = "\t")
  gwas.surv = readRDS(paste0(dir, "/all_gwas_", region, ".rds"))
  gwas.surv = data.frame(gwas.surv)
  gwas.surv$ID = sapply(1:nrow(gwas.surv), function(i) unlist(strsplit(rownames(gwas.surv)[i], "_"))[1])
  indx = which.min(gwas.logistic$P)
  snp = gwas.logistic$ID[indx]
  pval.all[i, ] = c(region, snp, -log10(gwas.logistic$P[indx]),
                   -log10(gwas.surv$p.value.spa[which(gwas.surv$ID == snp)]))
}
## Based on survival pvalue
pattern <- "chr[0-9XYM]+_[0-9]+_[0-9]+"
pval.all2 = data.frame(matrix(NA, nrow = length(logistic), ncol = 4))
colnames(pval.all2) = c("region", "snp", "logistic", "coxph")
for (i in 1:length(logistic)){
  path = logistic[i]
  region = str_extract(path, pattern)
  gwas.logistic = read.csv(path, header = TRUE, sep = "\t")
  gwas.surv = readRDS(paste0(dir, "/all_gwas_", region, ".rds"))
  gwas.surv = data.frame(gwas.surv)
  gwas.surv$ID = sapply(1:nrow(gwas.surv), function(i) unlist(strsplit(rownames(gwas.surv)[i], "_"))[1])
  indx = which.min(gwas.surv$p.value.spa)
  snp = gwas.surv$ID[indx]
  pval.all2[i, ] = c(region, snp, -log10(gwas.logistic$P[which(gwas.logistic$ID == snp)]),
                   -log10(gwas.surv$p.value.spa[which(gwas.surv$ID == snp)]))
}
snp_list = rbind(pval.all, pval.all2)
write.csv(snp_list, "/Users/nicholeyang/Downloads/survival-data-analysis/output/logistic_surv_comparison/top_signal_AA.csv")

2. COA

## logistic signal
pattern <- "chr[0-9XYM]+_[0-9]+_[0-9]+"
pval.coa = data.frame(matrix(NA, nrow = length(logistic), ncol = 4))
colnames(pval.coa) = c("region", "snp", "logistic", "coxph")
for (i in 1:length(logistic.coa)){
  path = logistic.coa[i]
  region = str_extract(path, pattern)
  gwas.logistic = read.csv(path, header = TRUE, sep = "\t")
  gwas.surv = readRDS(paste0(dir, "/coa_gwas_", region, ".rds"))
  gwas.surv = data.frame(gwas.surv)
  gwas.surv$ID = sapply(1:nrow(gwas.surv), function(i) unlist(strsplit(rownames(gwas.surv)[i], "_"))[1])
  indx = which.min(gwas.logistic$P)
  snp = gwas.logistic$ID[indx]
  pval.coa[i, ] = c(region, snp, -log10(gwas.logistic$P[indx]),
                   -log10(gwas.surv$p.value.spa[which(gwas.surv$ID == snp)]))
}
## survival signals
pattern <- "chr[0-9XYM]+_[0-9]+_[0-9]+"
pval.coa2 = data.frame(matrix(NA, nrow = length(logistic), ncol = 4))
colnames(pval.coa2) = c("region", "snp", "logistic", "coxph")
for (i in 1:length(logistic.coa)){
  path = logistic.coa[i]
  region = str_extract(path, pattern)
  gwas.logistic = read.csv(path, header = TRUE, sep = "\t")
  gwas.surv = readRDS(paste0(dir, "/coa_gwas_", region, ".rds"))
  gwas.surv = data.frame(gwas.surv)
  gwas.surv$ID = sapply(1:nrow(gwas.surv), function(i) unlist(strsplit(rownames(gwas.surv)[i], "_"))[1])
  indx = which.min(gwas.surv$p.value.spa)
  snp = gwas.surv$ID[indx]
  pval.coa2[i, ] = c(region, snp, -log10(gwas.logistic$P[which(gwas.logistic$ID == snp)]),
                   -log10(gwas.surv$p.value.spa[which(gwas.surv$ID == snp)]))
}
snp_list = rbind(pval.coa, pval.coa2)
write.csv(snp_list, "/Users/nicholeyang/Downloads/survival-data-analysis/output/logistic_surv_comparison/top_signal_COA.csv")

3. AOA

## logistic signals
pattern <- "chr[0-9XYM]+_[0-9]+_[0-9]+"
pval.aoa = data.frame(matrix(NA, nrow = length(logistic), ncol = 4))
colnames(pval.aoa) = c("region", "snp", "logistic", "coxph")
for (i in 1:length(logistic.aoa)){
  path = logistic.aoa[i]
  region = str_extract(path, pattern)
  gwas.logistic = read.csv(path, header = TRUE, sep = "\t")
  gwas.surv = readRDS(paste0(dir, "/aoa_gwas_", region, ".rds"))
  gwas.surv = data.frame(gwas.surv)
  gwas.surv$ID = sapply(1:nrow(gwas.surv), function(i) unlist(strsplit(rownames(gwas.surv)[i], "_"))[1])
  indx = which.min(gwas.logistic$P)
  snp = gwas.logistic$ID[indx]
  pval.aoa[i, ] = c(region, snp, -log10(gwas.logistic$P[indx]),
                   -log10(gwas.surv$p.value.spa[which(gwas.surv$ID == snp)]))
}
## survival signals
pattern <- "chr[0-9XYM]+_[0-9]+_[0-9]+"
pval.aoa2 = data.frame(matrix(NA, nrow = length(logistic), ncol = 4))
colnames(pval.aoa2) = c("region", "snp", "logistic", "coxph")
for (i in 1:length(logistic.aoa)){
  path = logistic.aoa[i]
  region = str_extract(path, pattern)
  gwas.logistic = read.csv(path, header = TRUE, sep = "\t")
  gwas.surv = readRDS(paste0(dir, "/aoa_gwas_", region, ".rds"))
  gwas.surv = data.frame(gwas.surv)
  gwas.surv$ID = sapply(1:nrow(gwas.surv), function(i) unlist(strsplit(rownames(gwas.surv)[i], "_"))[1])
  indx = which.min(gwas.surv$p.value.spa)
  snp = gwas.surv$ID[indx]
  pval.aoa2[i, ] = c(region, snp, -log10(gwas.logistic$P[which(gwas.logistic$ID == snp)]),
                   -log10(gwas.surv$p.value.spa[which(gwas.surv$ID == snp)]))
}
snp_list = rbind(pval.aoa, pval.aoa2)
write.csv(snp_list, "/Users/nicholeyang/Downloads/survival-data-analysis/output/logistic_surv_comparison/top_signal_AOA.csv")

Likelihood ratios of top signals

res.AA = read.csv("/Users/nicholeyang/Downloads/survival-data-analysis/output/logistic_surv_comparison/top_signal_LR_AA.csv", row.names = "X")

res.COA = read.csv("/Users/nicholeyang/Downloads/survival-data-analysis/output/logistic_surv_comparison/top_signal_LR_COA.csv", row.names = "X")

res.AOA = read.csv("/Users/nicholeyang/Downloads/survival-data-analysis/output/logistic_surv_comparison/top_signal_LR_AOA.csv", row.names = "X")
par(mfrow = c(1,3))

indx.remove = which(res.AA$region %in% c("chr2_236400001_242193529", "chr12_54500001_56200000", "chr19_31900001_35100000"))
hist(res.AA$survival[-indx.remove] - res.AA$logistic.1[-indx.remove], main = "AA",
     xlab = "CoxPH log(LR) - logistic log(LR)")


indx.remove = which(res.COA$region %in% c("chr2_236400001_242193529", "chr12_54500001_56200000", "chr19_31900001_35100000"))
hist(res.COA$survival[-indx.remove] - res.COA$logistic.1[-indx.remove], main = "COA",
     xlab = "CoxPH log(LR) - logistic log(LR)")



indx.remove = which(res.AOA$region %in% c("chr2_236400001_242193529", "chr12_54500001_56200000", "chr19_31900001_35100000"))
hist(res.AOA$survival[-indx.remove] - res.AOA$logistic.1[-indx.remove], main = "AOA",
     xlab = "CoxPH log(LR) - logistic log(LR)")

Version Author Date
82b913b yunqiyang0215 2024-08-28
c0e1aa5 yunqiyang0215 2024-08-28
2241d7c yunqiyang0215 2024-08-15
9e4ae0d yunqiyang0215 2024-07-29
pdf("/Users/nicholeyang/Downloads/survival-data-analysis/output/top_signal.pdf", height = 4, width = 8)
par(mfrow = c(1,3))

indx.remove = which(res.AA$region %in% c("chr2_236400001_242193529", "chr12_54500001_56200000", "chr19_31900001_35100000"))
plot(res.AA$logistic.1[-indx.remove], res.AA$survival[-indx.remove], pch = 20, xlab = "Logistic log(LR)", ylab = "CoxPH log(LR)", main = "AA")
abline(a = 0, b = 1, col = "red")

print(paste0(sum(res.AA$logistic.1[-indx.remove] < res.AA$survival[-indx.remove]), " out of ", length(res.AA$logistic.1[-indx.remove]), " signals has survival log(LR) higher than logistic log(LR)."))
[1] "16 out of 18 signals has survival log(LR) higher than logistic log(LR)."
indx.remove = which(res.COA$region %in% c("chr2_236400001_242193529", "chr12_54500001_56200000", "chr19_31900001_35100000"))
plot(res.COA$logistic.1[-indx.remove], res.COA$survival[-indx.remove], pch = 20, xlab = "Logistic log(LR)", ylab = "CoxPH log(LR)", main = "COA")
abline(a = 0, b = 1, col = "red")

print(paste0(sum(res.COA$logistic.1[-indx.remove] < res.COA$survival[-indx.remove]), " out of ", length(res.COA$logistic.1[-indx.remove]), " signals has survival log(LR) higher than logistic log(LR)."))
[1] "10 out of 18 signals has survival log(LR) higher than logistic log(LR)."
indx.remove = which(res.AOA$region %in% c("chr2_236400001_242193529", "chr12_54500001_56200000", "chr19_31900001_35100000"))
plot(res.AOA$logistic.1[-indx.remove], res.AOA$survival[-indx.remove], pch = 20, xlab = "Logistic log(LR)", ylab = "CoxPH log(LR)", main = "AOA")
abline(a = 0, b = 1, col = "red")

print(paste0(sum(res.AOA$logistic.1[-indx.remove] < res.AOA$survival[-indx.remove]), " out of ", length(res.AOA$logistic.1[-indx.remove]), " signals has survival log(LR) higher than logistic log(LR)."))
[1] "11 out of 18 signals has survival log(LR) higher than logistic log(LR)."
par(mfrow = c(1,3))
plot(res.AA$logistic, res.AA$coxph)
abline(a = 0, b = 1, col = "red")
plot(res.AOA$logistic, res.AOA$coxph)
abline(a = 0, b = 1, col = "red")
plot(res.COA$logistic, res.COA$coxph)
abline(a = 0, b = 1, col = "red")


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] stringr_1.4.0   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        tools_4.1.1      xfun_0.27       
[13] utf8_1.2.2       cli_3.6.1        git2r_0.28.0     jquerylib_0.1.4 
[17] htmltools_0.5.5  ellipsis_0.3.2   rprojroot_2.0.2  yaml_2.2.1      
[21] digest_0.6.28    tibble_3.1.5     lifecycle_1.0.3  later_1.3.0     
[25] sass_0.4.4       vctrs_0.6.3      promises_1.2.0.1 fs_1.5.0        
[29] cachem_1.0.6     glue_1.4.2       evaluate_0.14    rmarkdown_2.11  
[33] stringi_1.7.5    bslib_0.4.1      compiler_4.1.1   pillar_1.9.0    
[37] jsonlite_1.7.2   httpuv_1.6.3     pkgconfig_2.0.3