Last updated: 2022-02-10
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 14f12ab. 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
Modified: analysis/get_tables.Rmd
Modified: analysis/plot_figures.Rmd
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/08_prepare_Shiny.Rmd
) and HTML (docs/08_prepare_Shiny.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 | ef464c8 | Julien Bryois | 2022-02-09 | Build site. |
html | 27e1e80 | Julien Bryois | 2022-02-02 | Build site. |
html | c1c122b | Julien Bryois | 2022-01-28 | Build site. |
html | c47b2d9 | Julien Bryois | 2022-01-26 | Build site. |
Rmd | e995b14 | Julien Bryois | 2022-01-26 | prepare Shiny |
html | 6a43e1a | Julien Bryois | 2022-01-26 | Build site. |
Rmd | f804ef2 | Julien Bryois | 2022-01-26 | prepare Shiny |
Rmd | fd2f2c9 | Julien Bryois | 2022-01-26 | prepare Shiny |
dir.create('output/shiny',showWarnings = FALSE)
hdF5_file_path <- "output/shiny/data.h5"
library(tidyverse)
library(rhdf5)
sum_expression_ms <- readRDS('data_sensitive/expression/ms_sum_expression.individual_id.rds') %>%
mutate(dataset='ms')
sum_expression_ad <- readRDS('data_sensitive/expression/ad_sum_expression.individual_id.rds') %>%
mutate(dataset='ad')
sum_expression <- rbind(sum_expression_ms,sum_expression_ad)
sum_expression <- sum_expression %>%
group_by(individual_id,cell_type) %>%
mutate(libsize=sum(counts)) %>%
mutate(cpm=counts*10^6/libsize) %>%
mutate(log2_cpm=log2(cpm+1)) %>%
ungroup() %>%
mutate(gene=paste0(symbol,'_',ensembl))
Only keep individuals, cell type with at least 10 cells
sum_expression <- filter(sum_expression,n_cells>10)
h5createFile(hdF5_file_path)
[1] TRUE
h5createGroup(hdF5_file_path,"expression")
[1] TRUE
h5createGroup(hdF5_file_path,"genotype")
[1] TRUE
h5createGroup(hdF5_file_path,"eqtl_results")
[1] TRUE
h5createGroup(hdF5_file_path,"annotations")
[1] TRUE
h5createGroup(hdF5_file_path,"coloc")
[1] TRUE
sum_expression %>% group_by(gene) %>%
do(write=h5write(.[,c('cell_type','individual_id','log2_cpm')],
hdF5_file_path,paste0("expression/",unique(.$gene))))
# A tibble: 25,938 x 2
# Rowwise:
gene write
<chr> <list>
1 A1BG_ENSG00000121410 <dbl [1]>
2 A1CF_ENSG00000148584 <dbl [1]>
3 A2M_ENSG00000175899 <dbl [1]>
4 A2ML1_ENSG00000166535 <dbl [1]>
5 A3GALT2_ENSG00000184389 <dbl [1]>
6 A4GALT_ENSG00000128274 <dbl [1]>
7 A4GNT_ENSG00000118017 <dbl [1]>
8 AAAS_ENSG00000094914 <dbl [1]>
9 AACS_ENSG00000081760 <dbl [1]>
10 AADAC_ENSG00000114771 <dbl [1]>
# … with 25,928 more rows
d <- read_tsv('output/eqtl/eqtl.PC70.txt') %>%
dplyr::select(cell_type,gene=pid,SNP=sid,slope,adj_p) %>%
mutate(slope=round(slope,digits=2),adj_p=signif(adj_p,digits=3))
h5write(d, hdF5_file_path,"eqtl_results/eqtl_results_all")
vcf <- data.table::fread("data_sensitive/genotypes/processed/combined_final.vcf.gz",
data.table=FALSE) %>%
as_tibble()
vcf_filt <- filter(vcf,ID%in%d$SNP) %>%
gather(individual,genotype,10:201) %>%
mutate(genotype_parsed=case_when(
genotype=='1/1' ~ 2,
genotype=='0/1' ~ 1,
genotype=='1/0' ~ 1,
genotype=='0/0' ~ 0,
)) %>%
as_tibble() %>%
dplyr::select(ID,individual,REF,ALT,genotype_parsed) %>%
dplyr::rename(genotype=genotype_parsed)
vcf_filt %>% group_by(ID) %>%
do(write=h5write(.[,c('individual','REF','ALT','genotype')],
hdF5_file_path,paste0("genotype/",unique(.$ID))))
# A tibble: 77,887 x 2
# Rowwise:
ID write
<chr> <list>
1 chr1:120288148_G_A <dbl [1]>
2 chr1:144872614_G_C <dbl [1]>
3 chr1:15670060_C_G <dbl [1]>
4 chr1:201330714_G_T <dbl [1]>
5 chr1:22932928_C_G <dbl [1]>
6 chr10:100742917_G_C <dbl [1]>
7 chr10:103719262_C_G <dbl [1]>
8 chr10:17991504_A_G <dbl [1]>
9 chr10:26666405_A_G <dbl [1]>
10 chr10:36742286_G_C <dbl [1]>
# … with 77,877 more rows
d <- read_tsv('output/eqtl_specific/eqtl.PC70.specific.txt') %>%
#Sets pvalue to NA if the model did not converge
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)) %>%
filter(!is.na(nb_pvalue_aggregate), #Remove genes for which the model did not converge (9 genes)
!is.na(nb_pvalue_at_least_one),
nb_pvalue_at_least_one!=Inf) %>%
#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() %>%
mutate(nb_pvalue_all_adj = p.adjust(nb_pvalue_sig_all,method='fdr')) %>%
dplyr::select(cell_type=cell_type_id,
gene=gene_id,
SNP=snp_id,
nb_pvalue_aggregate_adj,
nb_pvalue_at_least_one_adj,
nb_pvalue_all_adj) %>%
mutate(nb_pvalue_aggregate_adj=signif(nb_pvalue_aggregate_adj,digits=3),
nb_pvalue_at_least_one_adj=signif(nb_pvalue_at_least_one_adj,digits=3),
nb_pvalue_all_adj=signif(nb_pvalue_all_adj,digits=3))
h5write(d, hdF5_file_path,"eqtl_results/eqtl_results_specific")
filter_coloc <- function(d,threshold=0.5){
genes2keep <- d %>% filter(PP.H4.abf>threshold) %>% pull(ensembl)
d <- filter(d,ensembl%in%genes2keep)
return(d)
}
ad <- read_tsv('output/coloc/coloc.ad.txt') %>% filter_coloc()
pd <- read_tsv('output/coloc/coloc.pd.txt')%>% filter_coloc()
scz <- read_tsv('output/coloc/coloc.scz.txt')%>% filter_coloc()
ms <- read_tsv('output/coloc/coloc.ms.txt')%>% filter_coloc()
ms_gtex_dice <- read_tsv('output/coloc/coloc.ms.gtex_dice.txt') %>% filter_coloc()
h5write(ad, hdF5_file_path,"coloc/ad")
h5write(pd, hdF5_file_path,"coloc/pd")
h5write(scz, hdF5_file_path,"coloc/scz")
h5write(ms, hdF5_file_path,"coloc/ms")
h5write(ms_gtex_dice, hdF5_file_path,"coloc/ms_gtex_dice")
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] rhdf5_2.32.4 forcats_0.5.0 stringr_1.4.0 dplyr_1.0.0
[5] purrr_0.3.4 readr_1.3.1 tidyr_1.1.0 tibble_3.0.1
[9] ggplot2_3.3.3 tidyverse_1.3.0
loaded via a namespace (and not attached):
[1] Rcpp_1.0.6 lubridate_1.7.9 lattice_0.20-41 assertthat_0.2.1
[5] rprojroot_1.3-2 digest_0.6.25 utf8_1.1.4 R6_2.4.1
[9] cellranger_1.1.0 backports_1.1.7 reprex_0.3.0 evaluate_0.14
[13] httr_1.4.1 pillar_1.4.4 rlang_0.4.10 readxl_1.3.1
[17] rstudioapi_0.11 data.table_1.12.8 whisker_0.4 blob_1.2.1
[21] R.oo_1.23.0 R.utils_2.9.2 rmarkdown_2.2 munsell_0.5.0
[25] broom_0.5.6 compiler_4.0.1 httpuv_1.5.4 modelr_0.1.8
[29] xfun_0.14 pkgconfig_2.0.3 htmltools_0.5.1.1 tidyselect_1.1.0
[33] workflowr_1.6.2 fansi_0.4.1 crayon_1.3.4 dbplyr_1.4.4
[37] withr_2.2.0 later_1.1.0.1 R.methodsS3_1.8.0 grid_4.0.1
[41] nlme_3.1-148 jsonlite_1.6.1 gtable_0.3.0 lifecycle_0.2.0
[45] DBI_1.1.0 git2r_0.27.1 magrittr_1.5 scales_1.1.1
[49] cli_2.0.2 stringi_1.4.6 fs_1.4.1 promises_1.1.1
[53] xml2_1.3.2 ellipsis_0.3.1 generics_0.0.2 vctrs_0.3.1
[57] Rhdf5lib_1.10.0 tools_4.0.1 glue_1.4.1 hms_0.5.3
[61] yaml_2.2.1 colorspace_1.4-1 rvest_0.3.5 knitr_1.28
[65] haven_2.3.1