Last updated: 2021-02-23
Checks: 6 1
Knit directory: fitnessGWAS/
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.
The R Markdown is untracked by Git. 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(20180914)
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 c386787. 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: .httr-oauth
Ignored: .pversion
Ignored: analysis/.DS_Store
Ignored: analysis/correlations_SNP_effects_cache/
Ignored: analysis/plot_models_variant_effects_cache/
Ignored: code/.DS_Store
Ignored: code/Drosophila_GWAS.Rmd
Ignored: data/.DS_Store
Ignored: data/derived/
Ignored: data/input/.DS_Store
Ignored: data/input/.pversion
Ignored: data/input/dgrp.fb557.annot.txt
Ignored: data/input/dgrp2.bed
Ignored: data/input/dgrp2.bim
Ignored: data/input/dgrp2.fam
Ignored: data/input/huang_transcriptome/
Ignored: figures/.DS_Store
Untracked files:
Untracked: Rplots.pdf
Untracked: analysis/GO_KEGG_enrichment.Rmd
Untracked: analysis/plot_models_variant_effects.Rmd
Untracked: code/GO_and_KEGG_gsea.R
Untracked: code/make_sites_files_for_ARGweaver.R
Untracked: code/run_argweaver.R
Untracked: code/run_mashr.R
Untracked: data/argweaver/
Untracked: figures/eff_size_histos.pdf
Untracked: figures/mixture_proportions.pdf
Untracked: figures/stats_figure.pdf
Untracked: manuscript/
Unstaged changes:
Modified: .gitignore
Modified: analysis/GWAS_tables.Rmd
Modified: analysis/TWAS.Rmd
Modified: analysis/checking_mashr_results.Rmd
Modified: analysis/eQTL_analysis.Rmd
Modified: analysis/get_predicted_line_means.Rmd
Modified: analysis/gwas_adaptive_shrinkage.Rmd
Modified: analysis/index.Rmd
Modified: analysis/make_annotation_database.Rmd
Modified: analysis/perform_gwas.Rmd
Modified: analysis/plot_line_means.Rmd
Modified: analysis/plotting_results.Rmd
Deleted: code/gwas_adaptive_shrinkage.R
Modified: data/input/female_fitness.csv
Modified: data/input/female_fitness_CLEANED.csv
Modified: data/input/male_fitness.csv
Modified: data/input/male_fitness_CLEANED.csv
Deleted: figures/figure1.eps
Deleted: figures/figure1.png
Deleted: figures/figure2.eps
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.
There are no past versions. Publish this analysis with wflow_publish()
to start tracking its development.
library(dplyr)
library(tibble)
library(clusterProfiler)
library(fgsea)
library(ggplot2)
library(readr)
library(glue)
library(stringr)
library(tidyr)
library(kableExtra)
library(purrr)
library(DT)
source("code/GO_and_KEGG_gsea.R")
# Make html tables:
my_data_table <- function(df){
datatable(
df, rownames=FALSE,
autoHideNavigation = TRUE,
extensions = c("Scroller", "Buttons"),
options = list(
dom = 'Bfrtip',
deferRender=TRUE,
scrollX=TRUE, scrollY=400,
scrollCollapse=TRUE,
buttons =
list('pageLength', 'colvis', 'csv', list(
extend = 'pdf',
pageSize = 'A4',
orientation = 'landscape',
filename = 'GWAS_enrichment')),
columnDefs = list( list(targets = c(8,10), visible = FALSE)),
pageLength = 50
)
)
}
options(stringsAsFactors = FALSE)
# Connect to the database of annotations
db <- DBI::dbConnect(RSQLite::SQLite(), "data/derived/annotations.sqlite3")
The following uses custom code stored in code/GO_and_KEGG_gsea.R
, which in turn relies on the fgsea
package. This test involves ranking genes by some statistic (e.g. the ) and then searching for GO and KEGG terms that are over-represented among genes at the top or bottom of the list.
Here, we first calculate the average for each of the mixture assignment probabilities (i.e. equal effects, sexual anatagonism, female-limited, and male limited) for all the loci mapping to each gene, to obtain gene-level measures. The reults are then used for GO and KEGG enrichment tests using fgsea
. The output of fgsea
includes the “normalised enrichment score” (NES), which describes how much the pathway is over-represented at the top of this list (for positive NES), or over-represented at the bottom (negative NES), and there is an associated \(p\)-value for each NES (calculated by resampling).
In the tables below, one can click ‘column visibility’ then either ‘leadingEdge’ or ‘genes’ to see a list of genes that were annotated with the focal GO or KEGG term and also scored highly for the focal gene-level metric.
gene_means <- tbl(db, "univariate_lmm_results") %>%
select(SNP, starts_with("P_")) %>% select(-P_null) %>%
left_join(tbl(db, "variants") %>% select(SNP, FBID), by = "SNP") %>%
select(-SNP) %>%
filter(!is.na(FBID)) %>%
collect(n=Inf) %>%
group_by(FBID) %>%
summarise_all(mean) %>%
left_join(tbl(db, "genes") %>%
select(FBID, gene_name) %>%
collect(n=Inf), by = "FBID")
concordant_enrichment <- GO_and_KEGG_gsea(gene_means, column = "P_equal_effects")
female_specific_enrichment <- GO_and_KEGG_gsea(gene_means, column = "P_female_specific")
male_specific_enrichment <- GO_and_KEGG_gsea(gene_means, column = "P_male_specific")
sex_antag_enrichment <- GO_and_KEGG_gsea(gene_means, column = "P_sex_antag")
concordant_enrichment %>%
filter(Test_type == "KEGG") %>%
my_data_table()
female_specific_enrichment %>%
filter(Test_type == "KEGG") %>%
my_data_table()
male_specific_enrichment %>%
filter(Test_type == "KEGG") %>%
my_data_table()
sex_antag_enrichment %>%
filter(Test_type == "KEGG") %>%
my_data_table()
concordant_enrichment %>%
filter(Test_type == "GO: Biological process") %>%
my_data_table()
female_specific_enrichment %>%
filter(Test_type == "GO: Biological process") %>%
my_data_table()
male_specific_enrichment %>%
filter(Test_type == "GO: Biological process") %>%
my_data_table()
sex_antag_enrichment %>%
filter(Test_type == "GO: Biological process") %>%
my_data_table()
concordant_enrichment %>%
filter(Test_type == "GO: Molecular function") %>%
my_data_table()
female_specific_enrichment %>%
filter(Test_type == "GO: Molecular function") %>%
my_data_table()
male_specific_enrichment %>%
filter(Test_type == "GO: Molecular function") %>%
my_data_table()
sex_antag_enrichment %>%
filter(Test_type == "GO: Molecular function") %>%
my_data_table()
concordant_enrichment %>%
filter(Test_type == "GO: Cellular component") %>%
my_data_table()
female_specific_enrichment %>%
filter(Test_type == "GO: Cellular component") %>%
my_data_table()
male_specific_enrichment %>%
filter(Test_type == "GO: Cellular component") %>%
my_data_table()
sex_antag_enrichment %>%
filter(Test_type == "GO: Cellular component") %>%
my_data_table()
sessionInfo()
R version 4.0.3 (2020-10-10)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Catalina 10.15.7
Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRblas.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
locale:
[1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] DT_0.13 purrr_0.3.4 kableExtra_1.1.0
[4] tidyr_1.1.0 stringr_1.4.0 glue_1.4.2
[7] readr_1.3.1 ggplot2_3.3.2 fgsea_1.14.0
[10] clusterProfiler_3.16.0 tibble_3.0.1 dplyr_1.0.0
loaded via a namespace (and not attached):
[1] fs_1.4.1 enrichplot_1.8.1 bit64_0.9-7
[4] webshot_0.5.2 RColorBrewer_1.1-2 progress_1.2.2
[7] httr_1.4.1 rprojroot_1.3-2 tools_4.0.3
[10] backports_1.1.7 R6_2.4.1 DBI_1.1.0
[13] BiocGenerics_0.34.0 colorspace_1.4-1 withr_2.2.0
[16] tidyselect_1.1.0 gridExtra_2.3 prettyunits_1.1.1
[19] bit_1.1-15.2 compiler_4.0.3 git2r_0.27.1
[22] rvest_0.3.5 Biobase_2.48.0 scatterpie_0.1.4
[25] xml2_1.3.2 triebeard_0.3.0 scales_1.1.1
[28] ggridges_0.5.2 digest_0.6.25 rmarkdown_2.5
[31] DOSE_3.14.0 pkgconfig_2.0.3 htmltools_0.5.0
[34] dbplyr_1.4.4 htmlwidgets_1.5.1 rlang_0.4.6
[37] rstudioapi_0.11 RSQLite_2.2.0 gridGraphics_0.5-0
[40] farver_2.0.3 generics_0.0.2 jsonlite_1.7.0
[43] crosstalk_1.1.0.1 BiocParallel_1.22.0 GOSemSim_2.14.0
[46] magrittr_2.0.1 ggplotify_0.0.5 GO.db_3.11.4
[49] Matrix_1.2-18 Rcpp_1.0.4.6 munsell_0.5.0
[52] S4Vectors_0.26.1 viridis_0.5.1 lifecycle_0.2.0
[55] stringi_1.5.3 yaml_2.2.1 ggraph_2.0.3
[58] MASS_7.3-53 plyr_1.8.6 qvalue_2.20.0
[61] grid_4.0.3 blob_1.2.1 parallel_4.0.3
[64] promises_1.1.0 ggrepel_0.8.2 DO.db_2.9
[67] crayon_1.3.4 lattice_0.20-41 graphlayouts_0.7.0
[70] cowplot_1.0.0 splines_4.0.3 hms_0.5.3
[73] knitr_1.30 pillar_1.4.4 igraph_1.2.5
[76] reshape2_1.4.4 stats4_4.0.3 fastmatch_1.1-0
[79] evaluate_0.14 downloader_0.4 BiocManager_1.30.10
[82] data.table_1.12.8 vctrs_0.3.0 tweenr_1.0.1
[85] httpuv_1.5.3.1 urltools_1.7.3 gtable_0.3.0
[88] polyclip_1.10-0 assertthat_0.2.1 xfun_0.19
[91] ggforce_0.3.1 europepmc_0.4 tidygraph_1.2.0
[94] later_1.0.0 viridisLite_0.3.0 rvcheck_0.1.8
[97] AnnotationDbi_1.50.0 memoise_1.1.0 IRanges_2.22.2
[100] workflowr_1.6.2 ellipsis_0.3.1