Last updated: 2023-03-15
Checks: 7 0
Knit directory: fitnessGWAS/
This reproducible R Markdown analysis was created with workflowr (version 1.7.0.4). 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(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 b964e87. 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: .Rapp.history
Ignored: .Rhistory
Ignored: .Rproj.user/
Ignored: .httr-oauth
Ignored: .pversion
Ignored: analysis/.DS_Store
Ignored: analysis/correlations_SNP_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: big_model.rds
Untracked: code/quant_gen_1.R
Untracked: data/input/genomic_relatedness_matrix.rds
Unstaged changes:
Modified: .gitignore
Modified: analysis/quant_genetics.Rmd
Modified: code/pdf_supp_material.Rmd
Modified: code/pdf_supp_material.pdf
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_tables.Rmd
) and HTML
(docs/GWAS_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 |
---|---|---|---|---|
Rmd | b964e87 | lukeholman | 2023-03-15 | wflow_publish("analysis/GWAS_tables.Rmd") |
html | 8eec615 | lukeholman | 2022-07-29 | Build site. |
Rmd | 8961dbc | lukeholman | 2022-07-29 | wflow_publish("analysis/GWAS_tables.Rmd") |
Rmd | 68414e9 | lukeholman | 2022-02-22 | Commit in Feb 2022 |
html | a232dfe | lukeholman | 2021-11-10 | Build site. |
html | 7449a90 | lukeholman | 2021-10-01 | Build site. |
Rmd | 01226ab | lukeholman | 2021-10-01 | wflow_publish("analysis/*") |
html | 8d14298 | lukeholman | 2021-09-26 | Build site. |
Rmd | af15dd6 | lukeholman | 2021-09-26 | Commit Sept 2021 |
Rmd | 3855d33 | lukeholman | 2021-03-04 | big fist commit 2021 |
html | 3855d33 | lukeholman | 2021-03-04 | big fist commit 2021 |
Rmd | a7f5146 | Luke Holman | 2019-01-01 | Lots of work on eQTLs |
Rmd | 8d54ea5 | Luke Holman | 2018-12-23 | Initial commit |
html | 8d54ea5 | Luke Holman | 2018-12-23 | Initial commit |
library(tidyverse)
library(kableExtra)
library(DT)
sci_notation <- function(x) formatC(x, format = "e", digits = 1)
kable_table <- function(df) {
kable(df, "html") %>%
kable_styling() %>%
scroll_box(height = "300px")
}
my_data_table <- function(df){ # Make html tables:
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_sig_loci')),
pageLength = 50
)
) %>%
formatStyle(
columns = c("Female early effect", "Male early effect", "Female late effect", "Male late effect"),
color = styleInterval(cuts = 0, values = c("tomato", "steelblue")),
fontWeight = "bold")
}
db <- DBI::dbConnect(RSQLite::SQLite(), "data/derived/annotations.sqlite3")
p_cutoff <- 1e-05
univariate_lmm_results <-
tbl(db, "univariate_lmm_results") %>%
select(SNP, SNP_clump, contains("raw"), -contains("SE")) %>%
filter(pvalue_female_early_raw < p_cutoff | pvalue_female_late_raw < p_cutoff |
pvalue_male_early_raw < p_cutoff | pvalue_male_late_raw < p_cutoff) %>%
inner_join(tbl(db, "variants"), by = "SNP") %>%
left_join(
tbl(db, "genes") %>%
select(FBID, gene_name), by = "FBID") %>%
collect(n=Inf) %>%
mutate_at(vars(contains("beta")), ~ format(round(.x, 2), nsmall = 2)) %>%
rename_all(~ gsub("beta_", "", .x)) %>%
rename_all(~ gsub("_raw", "", .x)) %>%
select(SNP, SNP_clump, MAF, FBID, gene_name, site.class, starts_with("female"),
starts_with("male"), starts_with("P_"), starts_with("pvalue")) %>%
distinct()
GWAS_table <- univariate_lmm_results %>%
split(.$SNP_clump) %>% # Only keep one SNP from each clump
map_df(~ mutate(.x, sum_p = pvalue_female_early + pvalue_female_late + pvalue_male_early + pvalue_male_late) %>%
arrange(sum_p) %>% head(1)) %>%
select(-sum_p) %>%
mutate_at(vars(contains("pval")), sci_notation) %>%
mutate(SNP_clump = replace(SNP_clump, SNP == SNP_clump, "")) %>%
rename(`Variant` = SNP,
`Variant clump` = SNP_clump,
`Site class` = site.class,
`Gene` = gene_name,
`Female early effect` = female_early,
`Female late effect` = female_late,
`Male early effect` = male_early,
`Male late effect` = male_late,
`Female early pval` = pvalue_female_early,
`Female late pval` = pvalue_female_late,
`Male early pval` = pvalue_male_early,
`Male late pval` = pvalue_male_late)
write_csv(GWAS_table, "data/derived/GWAS_significant_snps.csv")
This table shows variants (either individual SNPs or indels, or clumps of variants in complete linkage disequilibrium) that passed the statistical significance threshold of \(p < 10^{-5}\) for at least one of the four phenotypes, in a linear mixed model GWAS implemented in GEMMA. Column 3 gives the minor allele frequency, columns 4-5 identify genes that overlap the variant, and column 6 shows the site class. Columns 7-10 show the estimated effect size of the variant on the four phenotypes (where positive values mean that the minor allele is associated with higher fitness, and negative values that the minor allele is associated with lower fitness), and the final columns show the corresponding \(p\)-values.
GWAS_table %>% my_data_table()