• Description:
    • 1. Logistic gwas
    • 2. Survival gwas
    • 3. Compare logistic gwas and survival gwas

Last updated: 2024-06-18

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 25f958e. 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/

Unstaged changes:
    Deleted:    analysis/logistic_gwas_asthma.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/gwas_asthma.Rmd) and HTML (docs/gwas_asthma.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 25f958e yunqiyang0215 2024-06-18 wflow_publish("analysis/gwas_asthma.Rmd")
html 1455c77 yunqiyang0215 2024-06-18 Build site.
html 7ca547a yunqiyang0215 2024-06-17 Build site.
Rmd eff7db1 yunqiyang0215 2024-06-17 wflow_publish("analysis/gwas_asthma.Rmd")
html 4e9442a yunqiyang0215 2024-06-17 Build site.
Rmd 83936d2 yunqiyang0215 2024-06-17 wflow_publish("analysis/gwas_asthma.Rmd")
html 8ea4062 yunqiyang0215 2024-06-17 Build site.
Rmd dee3233 yunqiyang0215 2024-06-17 wflow_publish("analysis/gwas_asthma.Rmd")
html 9919087 yunqiyang0215 2024-06-17 Build site.
Rmd 17cba29 yunqiyang0215 2024-06-17 wflow_publish("analysis/gwas_asthma.Rmd")
html bd3def9 yunqiyang0215 2024-06-17 Build site.
Rmd 1696e52 yunqiyang0215 2024-06-17 wflow_publish("analysis/gwas_asthma.Rmd")
html 1e17a25 yunqiyang0215 2024-06-17 Build site.
Rmd 95e02d0 yunqiyang0215 2024-06-17 wflow_publish("analysis/gwas_asthma.Rmd")

Description:

  1. Logistic gwas result for all asthma, childhood asthma and adulthood asthma

  2. Survival gwas result for all asthma, childhood asthma and adulthood asthma

  3. Compare logistic and survival gwas on all asthma

library(stringr)

1. Logistic gwas

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

file <- list.files(path="/Users/nicholeyang/Downloads/survivalsusie/data/gwas_logistic_out/all", pattern = "\\.glm\\.logistic$", full.names = TRUE)
par(mfrow = c(6,2))
for (i in 1:length(file)){
  region = file[i]
  region_name = strsplit(region, "/")[[1]][9]
  gwas = read.csv(region, header = TRUE, sep = "\t")
  plot(gwas$POS, -log10(gwas$P), pch = 20, cex = 0.5, main = region_name, ylab = "log10-pval", xlab = "Position")
}

Version Author Date
1e17a25 yunqiyang0215 2024-06-17
par(mfrow = c(6,2))
for (i in 1:length(file.aoa)){
  region.aoa = file.aoa[i]
  region.coa = file.coa[i]
  region_name = strsplit(region.aoa, "/")[[1]][9]
  gwas.aoa = read.csv(region.aoa, header = TRUE, sep = "\t")
  gwas.coa = read.csv(region.coa, header = TRUE, sep = "\t")
  ymin = min(log10(gwas.aoa$P)) - 1
  ymax = max(-log10(gwas.coa$P)) + 2
  plot(gwas.aoa$POS, log10(gwas.aoa$P), ylim = c(ymin, ymax), pch = 20, cex = 0.5, col = "#2c7fb8", main = region_name, ylab = "log10-pval", xlab = "Position")
  points(gwas.coa$POS, -log10(gwas.coa$P), pch = 20, cex = 0.5, col = "#de2d26")
  legend("topright", legend = c("COA", "AOA"), col = c("#de2d26", "#2c7fb8"), pch = 20)
}

Version Author Date
1e17a25 yunqiyang0215 2024-06-17

2. Survival gwas

path_to_files = "/Users/nicholeyang/Downloads/survivalsusie/result/gwas_surv"
file.aoa <- list.files(path = path_to_files, pattern = "^aoa.*\\.rds$", full.names = TRUE)
file.coa <- list.files(path = path_to_files, pattern = "^coa.*\\.rds$", full.names = TRUE)
file <- list.files(path = path_to_files, pattern = "^all.*\\.rds$", full.names = TRUE)
par(mfrow = c(6,2))
pattern <- "chr[0-9XYM]+_[0-9]+_[0-9]+"
for (i in 1:length(file)){
  region = file[i]
  region_name = str_extract(region, pattern)
  gwas = readRDS(region)
  plot(-log10(gwas[, 'p.value.spa']), pch = 20, cex = 0.5, main = region_name, ylab = "log10-pval", xlab = "Position")
}

Version Author Date
1455c77 yunqiyang0215 2024-06-18
bd3def9 yunqiyang0215 2024-06-17
1e17a25 yunqiyang0215 2024-06-17
par(mfrow = c(6,2))
for (i in 1:length(file.aoa)){
  region.aoa = file.aoa[i]
  region.coa = file.coa[i]
  region_name = str_extract(region.aoa, pattern)
  gwas.aoa = readRDS(region.aoa)
  gwas.coa = readRDS(region.coa)
  ymin = min(log10(gwas.aoa[, 'p.value.spa']), na.rm = TRUE) - 1
  ymax = max(-log10(gwas.coa[, 'p.value.spa']), na.rm = TRUE) + 2
  plot(log10(gwas.aoa[, 'p.value.spa']), ylim = c(ymin, ymax), pch = 20, cex = 0.5, col = "#2c7fb8", main = region_name, ylab = "log10-pval", xlab = "Position")
  points(-log10(gwas.coa[, 'p.value.spa']), pch = 20, cex = 0.5, col = "#de2d26")
  legend("topright", legend = c("COA", "AOA"), col = c("#de2d26", "#2c7fb8"), pch = 20)
}

Version Author Date
1455c77 yunqiyang0215 2024-06-18
bd3def9 yunqiyang0215 2024-06-17
1e17a25 yunqiyang0215 2024-06-17

3. Compare logistic gwas and survival gwas

file.logistic <- list.files(path="/Users/nicholeyang/Downloads/survivalsusie/data/gwas_logistic_out/all", pattern = "\\.glm\\.logistic$", full.names = TRUE)
file.survival <- list.files(path = "/Users/nicholeyang/Downloads/survivalsusie/result/gwas_surv", pattern = "^all.*\\.rds$", full.names = TRUE)
par(mfrow = c(6,2))

pattern <- "chr[0-9XYM]+_[0-9]+_[0-9]+"
for (i in 1:length(file.survival)){
  region = file.survival[i]
  region_name = str_extract(region, pattern)

  path.logistic = paste0("/Users/nicholeyang/Downloads/survivalsusie/data/gwas_logistic_out/all/gwas_", 
                         region_name, ".asthma.glm.logistic")
  
  # read in gwas results
  gwas.logistic = read.csv(path.logistic, header = TRUE, sep = "\t")
  gwas.survival = data.frame(readRDS(region))
  
  # merge two datasets
  snp_ids = sapply(rownames(gwas.survival), function(x) unlist(strsplit(x, "_"))[1])
  gwas.survival$ID = snp_ids
  dat = merge(gwas.logistic, gwas.survival, by = "ID")
  plot(dat$POS, -log10(dat$P), pch = 20, cex = 0.5, main = region_name, ylab = "log10-pval", xlab = "Position", ylim = c(0, max(-log10(dat$P), -log10(dat$p.value.spa)) + 1), col = "#de2d26")
  points(dat$POS, -log10(dat$p.value.spa), pch = 20, cex = 0.5)
  
  legend("topright", legend = c("logistic.gwas", "survival.gwas"), col = c("#de2d26", 1), pch = 20)
}

Version Author Date
1455c77 yunqiyang0215 2024-06-18
4e9442a yunqiyang0215 2024-06-17
8ea4062 yunqiyang0215 2024-06-17
9919087 yunqiyang0215 2024-06-17

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