Last updated: 2020-06-23

Checks: 6 1

Knit directory: PSYMETAB/

This reproducible R Markdown analysis was created with workflowr (version 1.6.0). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.


The R Markdown file has unstaged changes. To know which version of the R Markdown file created these results, you’ll want to first commit it to the Git repo. If you’re still working on the analysis, you can ignore this warning. When you’re finished, you can run wflow_publish to commit the R Markdown file and build the HTML.

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(20191126) 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 version displayed above was the version of the Git repository at the time these results were generated.

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:    ._docs
    Ignored:    .drake/
    Ignored:    analysis/.Rhistory
    Ignored:    analysis/._GWAS.Rmd
    Ignored:    analysis/._data_processing_in_genomestudio.Rmd
    Ignored:    analysis/._quality_control.Rmd
    Ignored:    analysis/GWAS/
    Ignored:    analysis/PRS/
    Ignored:    analysis/QC/
    Ignored:    analysis/site_libs/
    Ignored:    analysis_prep_1_clustermq.out
    Ignored:    analysis_prep_2_clustermq.out
    Ignored:    analysis_prep_3_clustermq.out
    Ignored:    analysis_prep_4_clustermq.out
    Ignored:    data/processed/
    Ignored:    data/raw/
    Ignored:    download_impute_1_clustermq.out
    Ignored:    init_analysis_1_clustermq.out
    Ignored:    init_analysis_2_clustermq.out
    Ignored:    init_analysis_3_clustermq.out
    Ignored:    init_analysis_4_clustermq.out
    Ignored:    init_analysis_5_clustermq.out
    Ignored:    init_analysis_6_clustermq.out
    Ignored:    packrat/lib-R/
    Ignored:    packrat/lib-ext/
    Ignored:    packrat/lib/
    Ignored:    post_impute_1_clustermq.out
    Ignored:    pre_impute_qc_1_clustermq.out
    Ignored:    process_init_10_clustermq.out
    Ignored:    process_init_11_clustermq.out
    Ignored:    process_init_12_clustermq.out
    Ignored:    process_init_13_clustermq.out
    Ignored:    process_init_14_clustermq.out
    Ignored:    process_init_15_clustermq.out
    Ignored:    process_init_16_clustermq.out
    Ignored:    process_init_17_clustermq.out
    Ignored:    process_init_18_clustermq.out
    Ignored:    process_init_19_clustermq.out
    Ignored:    process_init_1_clustermq.out
    Ignored:    process_init_20_clustermq.out
    Ignored:    process_init_21_clustermq.out
    Ignored:    process_init_22_clustermq.out
    Ignored:    process_init_23_clustermq.out
    Ignored:    process_init_24_clustermq.out
    Ignored:    process_init_25_clustermq.out
    Ignored:    process_init_26_clustermq.out
    Ignored:    process_init_27_clustermq.out
    Ignored:    process_init_28_clustermq.out
    Ignored:    process_init_29_clustermq.out
    Ignored:    process_init_2_clustermq.out
    Ignored:    process_init_30_clustermq.out
    Ignored:    process_init_31_clustermq.out
    Ignored:    process_init_3_clustermq.out
    Ignored:    process_init_4_clustermq.out
    Ignored:    process_init_5_clustermq.out
    Ignored:    process_init_6_clustermq.out
    Ignored:    process_init_7_clustermq.out
    Ignored:    process_init_8_clustermq.out
    Ignored:    process_init_9_clustermq.out
    Ignored:    prs_1_clustermq.out
    Ignored:    prs_2_clustermq.out
    Ignored:    prs_3_clustermq.out
    Ignored:    prs_4_clustermq.out

Untracked files:
    Untracked:  analysis/genetic_quality_control.Rmd
    Untracked:  analysis/plans.Rmd
    Untracked:  analysis_prep.log
    Untracked:  download_impute.log
    Untracked:  grs.log
    Untracked:  init_analysis.log
    Untracked:  process_init.log
    Untracked:  prs.log

Unstaged changes:
    Modified:   analysis/GWAS.Rmd
    Modified:   analysis/data_sources.Rmd
    Modified:   analysis/index.Rmd
    Modified:   analysis/pheno_quality_control.Rmd
    Deleted:    analysis/project.Rmd
    Modified:   analysis/quality_control.Rmd
    Modified:   cache_log.csv
    Modified:   post_impute.log
    Modified:   slurm_clustermq.tmpl

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 R Markdown and HTML files. If you’ve configured a remote Git repository (see ?wflow_git_remote), click on the hyperlinks in the table below to view them.

File Version Author Date Message
Rmd a56ae32 Sjaarda Jennifer Lynn 2020-01-22 add GWAS functions
html 46477dd Jenny Sjaarda 2019-12-06 Build site.
Rmd 16f6c28 Sjaarda Jennifer Lynn 2019-12-06 add gwas Rmd

The following document outlines and summarizes the GWAS analyses run in PSYMETAB.

Analysis preparation.

found that GYYEHMDR is listed as both Male and Female -> should be female only.

GWAS.

General settings.

Drug classification.

After discussion with others, it was decided to define drugs into three classes

  1. AP1 pour faible risque de prise de poids: Amisulpride, Aripiprazole, Brexpiprazole, Cariprazine, Carbamazepine, Chlorprothixene, Flupentixol, Fluphenazine, Haloperidol, Lurasidone, Pipampérone, Promazine, Sertindole, Sulpiride, Tiapride

  2. AP2 pour risque intermédiaire de prise de poids: Amitriptyline, Asenapine, Clomipramine, Dibenzepine, Doxepine, Imipramine, Lévomépromazine, Lithium, Mirtazapine, Nortriptyline, Opipramol, Palipéridone, Quétiapine, Rispéridone, Trimipramine, Zuclopenthixol

  3. AP3 pour risque élevé de prise de poids: Clozapine, Olanzapine, Valproate

Specifically, high, medium and low inducers were defined as follows:

high_inducers
[1] "Olanzapine" "Clozapine"  "Valproate" 
med_inducers
 [1] "Amitriptyline"   "Asenapine"       "Clomipramine"    "Doxepine"       
 [5] "Levomepromazine" "Lithium"         "Mirtazapine"     "Paliperidone"   
 [9] "Risperidone"     "Quetiapine"      "Trimipramine"    "Zuclopenthixol" 
low_inducers
 [1] "Amisulpride"     "Aripiprazole"    "Brexpiprazole"   "Cariprazine"    
 [5] "Carbamazepine"   "Chlorprothixene" "Flupentixol"     "Fluphenazine"   
 [9] "Haloperidol"     "Lurasidone"      "Pipamperone"     "Sertindole"     
[13] "Sulpiride"       "Tiapride"       

Check if “Mois” column makes sense.

Plus or minus on follow-up to double check that the “Mois” column make sense.

leeway_time <- 90 For example, if one visit is marked month 3 on September 5/15; and the previous visit marked month 0 on June 15/19, the script below will check if: the difference between the two dates (September 5/15 - June 15/19) is within the difference between the two months (3 = 90 days) +/- the ‘leeway_time’

min_follow_up <- 14

Three types of GWAS were run

Interaction

Baseline

Subgroup

het_out <-
  fread(
    paste0("analysis/GWAS/subgroup/", eth, "/", output, "_", suffix,
      "_", eth, ".", outcome_var, ".het"),
    header = F,
    data.table = F
  )

sig_list <- which(as.numeric(het_out[, 2]) < 5e-08)
length(sig_list)
colnames(het_out) <- c("ID", "P_HET")
result <- cbind(filter, "P_HET" = het_out$P_HET)
png(
  paste0("analysis/GWAS/subgroup/", eth, "/", output, "_", suffix, "_", eth, ".", outcome_var, ".het.manhattan.png"),
  width = 2000,
  height = 1000,
  pointsize = 18
)
manhattan(result, p = "P_HET", chr = "CHROM")
dev.off()

png(
  paste0(
    "analysis/GWAS/subgroup/", eth, "/", output, "_", suffix, "_", eth, ".", outcome_var, ".het.qq.png"),
  width = 2000,
  height = 1000,
  pointsize = 18
)
qq(result$P_HET)
dev.off()


#### GWAS
    sig_nodrug <-nodrug[ which(nodrug$P < 5e-08),]
    sig_drug <- drug[which(drug$P < 5e-08),]
    for(data in c("nodrug", "drug"))
    {
      gwas_result <- get(data)
      joint <- reduce(list(gwas_result,freq,info), full_join, by = "ID")
      sig <- joint %>%
              mutate_at("P", as.numeric) %>%
              filter(P < 5e-06) %>%
              filter(ALT_FREQS > maf_threshold & ALT_FREQS < (1 - maf_threshold)) %>%
              filter(R2 > info_threshold)

      joint_maf <- joint %>% filter(ALT_FREQS > maf_threshold & ALT_FREQS < (1- maf_threshold))%>% mutate_at("P", as.numeric)
      sig <- joint_maf  %>% filter(P < gw_sig)
      png("man_interaction.png", width=2000, height=1000, pointsize=18)
      manhattan(joint_maf)
      dev.off()

      png("interaction_qq2.png", width=2000, height=1000, pointsize=18)
      qq(joint_maf$P)
      dev.off()

            qq(gwas_result2$P)
    # sig_nodrug <- sig
    }
    
    gwas_result <- fread(result, data.table=F, stringsAsFactors=F)
  gwas_result2 <- gwas_result %>% rename(CHR = "#CHROM") %>% rename(BP = POS) %>% filter(!is.na(P))


  #### GWAS
  sig_nodrug <-nodrug[ which(nodrug$P < 5e-08),]
  sig_drug <- drug[which(drug$P < 5e-08),]

  for(data in c("nodrug", "drug"))
  {
  gwas_result <- get(data)
  gwas_munge <- gwas_result %>% rename(CHR = "#CHROM") %>% rename(BP = POS) %>% filter(!is.na(P))
  joint <- reduce(list(gwas_munge,freq,info), full_join, by = "ID")
  sig <- joint %>%
          mutate_at("P", as.numeric) %>%
          filter(P < 5e-06) %>%
          filter(ALT_FREQS > maf_threshold & ALT_FREQS < (1 - maf_threshold)) %>%
          filter(R2 > info_threshold)
  # sig_nodrug <- sig
  }

Adjustment co-variants

loadd(pheno_raw)

# temp <-   pheno_raw %>%
#     mutate(Date = as.Date(Date, format = '%d.%m.%Y'))  %>% filter(!is.na(Date)) %>% arrange(Date)  %>%
#     mutate(AP1 = gsub(" ", "_",AP1)) %>% mutate_at("AP1",as.factor) %>% mutate(AP1 = gsub("_.*$","", AP1)) %>% mutate(AP1 = na_if(AP1, "")) %>%## merge retard/depot with original
#     group_by(GEN) %>%  mutate(sex = check_sex(Sexe))
# temp %>% filter(is.na(sex)) %>% dplyr::select(sex, Sexe) %>% filter(!is.na(Sexe))
#
# GEN      sex   Sexe
#   <chr>    <chr> <chr>
# 1 GYYEHMDR NA    M
# 2 GYYEHMDR NA    M
# 3 GYYEHMDR NA    M
# 4 GYYEHMDR NA    F
# 5 GYYEHMDR NA    F

sessionInfo()
R version 3.5.3 (2019-03-11)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS: /data/sgg2/jenny/bin/R-3.5.3/lib64/R/lib/libRblas.so
LAPACK: /data/sgg2/jenny/bin/R-3.5.3/lib64/R/lib/libRlapack.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] tidylog_1.0.1           OpenImageR_1.1.6        fuzzyjoin_0.1.5        
 [4] kableExtra_1.1.0        R.utils_2.9.2           R.oo_1.23.0            
 [7] R.methodsS3_1.7.1       TwoSampleMR_0.4.25      reader_1.0.6           
[10] NCmisc_1.1.6            optparse_1.6.4          readxl_1.3.1           
[13] ggthemes_4.2.0          tryCatchLog_1.1.6       futile.logger_1.4.3    
[16] DataExplorer_0.8.0      taRifx_1.0.6.1          qqman_0.1.4            
[19] MASS_7.3-51.5           bit64_0.9-7             bit_1.1-14             
[22] rslurm_0.5.0            rmeta_3.0               devtools_2.2.1         
[25] usethis_1.5.1           data.table_1.12.8       clustermq_0.8.8.1      
[28] future.batchtools_0.8.1 future_1.15.1           rlang_0.4.5            
[31] knitr_1.26              drake_7.12.0.9000       forcats_0.4.0          
[34] stringr_1.4.0           dplyr_0.8.3             purrr_0.3.3            
[37] readr_1.3.1             tidyr_1.0.3             tibble_2.1.3           
[40] ggplot2_3.2.1           tidyverse_1.3.0         pacman_0.5.1           
[43] processx_3.4.1          workflowr_1.6.0        

loaded via a namespace (and not attached):
  [1] backports_1.1.6      plyr_1.8.5           igraph_1.2.5        
  [4] lazyeval_0.2.2       storr_1.2.1          listenv_0.8.0       
  [7] digest_0.6.25        htmltools_0.4.0      tiff_0.1-5          
 [10] fansi_0.4.1          magrittr_1.5         checkmate_1.9.4     
 [13] memoise_1.1.0        base64url_1.4        remotes_2.1.0       
 [16] globals_0.12.5       modelr_0.1.5         prettyunits_1.1.0   
 [19] jpeg_0.1-8.1         colorspace_1.4-1     rvest_0.3.5         
 [22] rappdirs_0.3.1       haven_2.2.0          xfun_0.11           
 [25] callr_3.4.0          crayon_1.3.4         jsonlite_1.6        
 [28] brew_1.0-6           glue_1.4.0           gtable_0.3.0        
 [31] webshot_0.5.2        pkgbuild_1.0.6       scales_1.1.0        
 [34] futile.options_1.0.1 DBI_1.1.0            Rcpp_1.0.3          
 [37] xtable_1.8-4         viridisLite_0.3.0    progress_1.2.2      
 [40] txtq_0.2.0           clisymbols_1.2.0     htmlwidgets_1.5.1   
 [43] httr_1.4.1           getopt_1.20.3        calibrate_1.7.5     
 [46] ellipsis_0.3.0       pkgconfig_2.0.3      dbplyr_1.4.2        
 [49] tidyselect_0.2.5     reshape2_1.4.3       later_1.0.0         
 [52] munsell_0.5.0        cellranger_1.1.0     tools_3.5.3         
 [55] cli_2.0.1            generics_0.0.2       broom_0.5.3         
 [58] fastmap_1.0.1        evaluate_0.14        yaml_2.2.0          
 [61] fs_1.3.1             packrat_0.5.0        nlme_3.1-143        
 [64] mime_0.8             whisker_0.4          formatR_1.7         
 [67] proftools_0.99-2     xml2_1.2.2           compiler_3.5.3      
 [70] rstudioapi_0.10      png_0.1-7            filelock_1.0.2      
 [73] testthat_2.3.1       reprex_0.3.0         stringi_1.4.5       
 [76] ps_1.3.0             desc_1.2.0           lattice_0.20-38     
 [79] vctrs_0.2.4          pillar_1.4.3         lifecycle_0.1.0     
 [82] networkD3_0.4        httpuv_1.5.2         R6_2.4.1            
 [85] promises_1.1.0       gridExtra_2.3        sessioninfo_1.1.1   
 [88] codetools_0.2-16     lambda.r_1.2.4       assertthat_0.2.1    
 [91] pkgload_1.0.2        rprojroot_1.3-2      withr_2.1.2         
 [94] batchtools_0.9.12    parallel_3.5.3       hms_0.5.3           
 [97] grid_3.5.3           rmarkdown_1.18       git2r_0.26.1        
[100] shiny_1.4.0          lubridate_1.7.4