Last updated: 2022-02-11

Checks: 7 0

Knit directory: snRNA_eqtl/

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(20211124) 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 a933f86. 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:    .Rproj.user/
    Ignored:    data_sensitive/
    Ignored:    output/.DS_Store

Untracked files:
    Untracked:  analysis/._index.Rmd
    Untracked:  analysis/additional/
    Untracked:  analysis/alternatives/
    Untracked:  analysis/clean_analysis.Rmd
    Untracked:  analysis/log_run_slurm_out
    Untracked:  analysis/log_run_slurm_stderr
    Untracked:  analysis/portfolio/
    Untracked:  analysis/revision.Rmd
    Untracked:  analysis/run_slurm.Rscript
    Untracked:  analysis/run_slurm.sbatch
    Untracked:  data/dice/
    Untracked:  data/epigenome_enrichment/
    Untracked:  data/gencode/
    Untracked:  data/gnomad_loeuf/
    Untracked:  data/gtex/
    Untracked:  data/gwas/
    Untracked:  data/gwas_epigenome_overlap/
    Untracked:  data/locuszoom/
    Untracked:  data/magma_interaction_eqtl/
    Untracked:  data/magma_specific_genes/
    Untracked:  data/metabrain/
    Untracked:  data/umap/
    Untracked:  output/._.DS_Store
    Untracked:  output/coloc/
    Untracked:  output/eqtl/
    Untracked:  output/eqtl_specific/
    Untracked:  output/figures/
    Untracked:  output/gwas_epigenome_overlap/
    Untracked:  output/shiny/
    Untracked:  output/tables/

Unstaged changes:
    Modified:   .gitignore
    Modified:   analysis/04_coloc.Rmd
    Modified:   analysis/_site.yml
    Deleted:    output/README.md

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/get_tables.Rmd) and HTML (docs/get_tables.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
html b3da8a6 Julien Bryois 2022-02-10 Build site.
Rmd c125e72 Julien Bryois 2022-02-10 get tables
html 194bc0a Julien Bryois 2022-01-28 Build site.
Rmd dd69b4d Julien Bryois 2022-01-28 get tables

library(tidyverse)
dir.create('output/tables',showWarnings = FALSE)

Suplementary tables

Table S1

Manually created

Table S2

matched_snps <- read_tsv('output/eqtl/eqtl.PC70.metabrain.matched.txt') %>% dplyr::select(cell_type,sid=SNP,ensembl,beta_metabrain,p_metabrain,Replication)
Parsed with column specification:
cols(
  SNP_id_hg38 = col_character(),
  ensembl = col_character(),
  AlleleAssessed = col_character(),
  beta_metabrain = col_double(),
  se_metabrain = col_double(),
  p_metabrain = col_double(),
  cell_type = col_character(),
  symbol = col_character(),
  SNP = col_character(),
  chr_hg38 = col_double(),
  effect_allele = col_character(),
  other_allele = col_character(),
  slope = col_double(),
  se = col_double(),
  bpval = col_double(),
  adj_p = col_double(),
  p_rep_adj = col_double(),
  Replication = col_character()
)
snp_alleles <- data.table::fread('data_sensitive/genotypes/processed/plink.frq',data.table=FALSE) %>% dplyr::select(sid=SNP,effect_allele=A1,other_allele=A2) %>% as_tibble()
tableS2 <- read_tsv('output/eqtl/eqtl.PC70.txt') %>% 
  separate(pid,into=c('symbol','ensembl'),sep='_') %>% 
  inner_join(.,snp_alleles,by='sid') %>% 
  left_join(.,matched_snps,by=c('cell_type','sid','ensembl')) %>% 
  dplyr::select(cell_type,symbol,ensembl,SNP=sid,effect_allele,other_allele,dist_TSS=dist,beta=slope,bpval,adj_p,beta_metabrain,p_metabrain,Replication) %>% 
  write_csv(.,'output/tables/tableS2.csv')

Table S3

snp_pos <- read_tsv('data_sensitive/genotypes/processed/snp_pos_hg38.txt',col_names=FALSE) %>% dplyr::rename(CHROM=X1,POS=X2,SNP=X3)
tableS3 <- read_tsv('output/eqtl/eqtl.70PCs.caveman.txt') %>% 
  separate(GENE,into=c('symbol','ensembl','chr','pos_top_cis_eQTL','A1_eqtl','A2_eqtl'),sep='_') %>% 
  dplyr::select(cell_type,symbol,ensembl,CHROM,POS,CaVEMaN,Probability) %>% arrange(-Probability) %>% 
  unique() %>% 
  left_join(.,snp_pos,by=c('CHROM','POS')) %>% 
  dplyr::select(cell_type,symbol,ensembl,SNP,chr_hg38=CHROM,pos_hg38=POS,CaVEMaN,Probability) %>% 
  write_csv(.,'output/tables/tableS3.csv')

Table S4

tableS4 <- read_tsv('output/eqtl_specific/eqtl.PC70.specific.txt') %>% 
  #Sets pvalue to NA if the model did not converge or if the model output is Inf
  mutate(nb_pvalue_aggregate=ifelse(nb_pvalue_aggregate_model_converged==FALSE,NA,nb_pvalue_aggregate)) %>% 
  mutate(nb_pvalue_at_least_one=ifelse(nb_pvalue_at_least_one_model_converged==FALSE,NA,nb_pvalue_at_least_one)) %>%
  #Get adjusted pvalues
  mutate(nb_pvalue_aggregate_adj=p.adjust(nb_pvalue_aggregate,method='fdr'),
         nb_pvalue_at_least_one_adj=p.adjust(nb_pvalue_at_least_one,method = 'fdr')) %>% 
  #For each row, get the maximum pvalue across all cell types, this will be the gene-level pvalue testing whether the genetic effect on gene expression is different than all other cell types
  rowwise() %>% 
  mutate(nb_pvalue_sig_all=max(Astrocytes_p,`Endothelial cells_p`,`Excitatory neurons_p`,`Inhibitory neurons_p`,Microglia_p,Oligodendrocytes_p,`OPCs / COPs_p`,Pericytes_p,na.rm=TRUE)) %>% 
  ungroup() %>% 
  #Sets pvalue to NA if the model did not converge
  mutate(nb_pvalue_sig_all=ifelse(nb_pvalue_at_least_one_model_converged==FALSE | nb_pvalue_sig_all==Inf | nb_pvalue_sig_all==-Inf,NA,nb_pvalue_sig_all)) %>% 
  mutate(nb_pvalue_all_adj = p.adjust(nb_pvalue_sig_all,method='fdr')) %>% 
  separate(gene_id,into=c('symbol','ensembl'),sep='_') %>%
  dplyr::select(cell_type_id,symbol,ensembl,
                snp_id,nb_pvalue_aggregate,nb_pvalue_aggregate_adj,nb_pvalue_at_least_one,                                                                      nb_pvalue_at_least_one_adj,nb_pvalue_all=nb_pvalue_sig_all,                                                                                     nb_pvalue_all_adj,nb_pvalue_aggregate_model_converged,
                nb_pvalue_at_least_one_model_converged,Astrocytes_p:Pericytes_p) %>% 
  arrange(nb_pvalue_aggregate) %>% 
  write_csv('output/tables/tableS4.csv')

Table S5

read_tsv('output/coloc/coloc.ms.txt') %>% write_csv('output/tables/tableS5.ms.csv')
read_tsv('output/coloc/coloc.ad.txt') %>% write_csv('output/tables/tableS5.ad.csv')
read_tsv('output/coloc/coloc.scz.txt') %>% write_csv('output/tables/tableS5.scz.csv')
read_tsv('output/coloc/coloc.pd.txt') %>% write_csv('output/tables/tableS5.pd.csv')

Table S6

read_tsv('output/coloc/coloc.ms.gtex_dice.txt') %>% write_csv('output/tables/tableS6.csv')

Table S7

read_csv('output/gwas_epigenome_overlap/GWAS_epigenomic_marks.closest_gene.closest_coloc.filtered.SNP2TFBS.txt') %>% write_csv('output/tables/tableS7.csv')

sessionInfo()
R version 4.0.1 (2020-06-06)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS/LAPACK: /pstore/apps/OpenBLAS/0.3.1-GCC-7.3.0-2.30/lib/libopenblasp-r0.3.1.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] forcats_0.5.0   stringr_1.4.0   dplyr_1.0.0     purrr_0.3.4    
 [5] readr_1.3.1     tidyr_1.1.0     tibble_3.0.1    ggplot2_3.3.3  
 [9] tidyverse_1.3.0 workflowr_1.6.2

loaded via a namespace (and not attached):
 [1] tidyselect_1.1.0  xfun_0.14         haven_2.3.1       lattice_0.20-41  
 [5] colorspace_1.4-1  vctrs_0.3.1       generics_0.0.2    htmltools_0.5.1.1
 [9] yaml_2.2.1        blob_1.2.1        rlang_0.4.10      later_1.1.0.1    
[13] pillar_1.4.4      withr_2.2.0       glue_1.4.1        DBI_1.1.0        
[17] dbplyr_1.4.4      modelr_0.1.8      readxl_1.3.1      lifecycle_0.2.0  
[21] munsell_0.5.0     gtable_0.3.0      cellranger_1.1.0  rvest_0.3.5      
[25] evaluate_0.14     knitr_1.28        httpuv_1.5.4      fansi_0.4.1      
[29] broom_0.5.6       Rcpp_1.0.6        promises_1.1.1    backports_1.1.7  
[33] scales_1.1.1      jsonlite_1.6.1    fs_1.4.1          hms_0.5.3        
[37] digest_0.6.25     stringi_1.4.6     grid_4.0.1        rprojroot_1.3-2  
[41] cli_2.0.2         tools_4.0.1       magrittr_1.5      crayon_1.3.4     
[45] whisker_0.4       pkgconfig_2.0.3   ellipsis_0.3.1    data.table_1.12.8
[49] xml2_1.3.2        reprex_0.3.0      lubridate_1.7.9   rstudioapi_0.11  
[53] assertthat_0.2.1  rmarkdown_2.2     httr_1.4.1        R6_2.4.1         
[57] nlme_3.1-148      git2r_0.27.1      compiler_4.0.1