• Table showing the significant transcripts
    • Count the numbers of significant genes

Last updated: 2021-03-05

Checks: 7 0

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.


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 ac8ee22. 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:    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
    Ignored:    figures/fig1_inkscape.svg
    Ignored:    figures/figure1a.pdf
    Ignored:    figures/figure1b.pdf

Untracked files:
    Untracked:  figures/SNP_effect_ED.pdf
    Untracked:  figures/boyle_plot.pdf
    Untracked:  figures/fig1.pdf

Unstaged changes:
    Modified:   .gitignore
    Modified:   analysis/GWAS_tables.Rmd
    Modified:   analysis/get_predicted_line_means.Rmd
    Modified:   analysis/index.Rmd
    Modified:   analysis/perform_gwas.Rmd
    Modified:   analysis/plot_line_means.Rmd
    Modified:   analysis/plot_models_variant_effects.Rmd
    Deleted:    data/input/clough_2014_dsx_targets.csv
    Deleted:    figures/figure1.eps
    Deleted:    figures/figure2.eps
    Modified:   manuscript/GWAS_manuscript.Rmd
    Modified:   manuscript/GWAS_manuscript.pdf
    Modified:   manuscript/GWAS_manuscript.tex

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/TWAS_tables.Rmd) and HTML (docs/TWAS_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 ac8ee22 lukeholman 2021-03-05 wflow_publish(“analysis/TWAS_tables.Rmd”)
Rmd 3855d33 lukeholman 2021-03-04 big fist commit 2021
html 3855d33 lukeholman 2021-03-04 big fist commit 2021

library(tidyverse)
library(DT)
library(kableExtra)

kable_table <- function(df) { # cool tables
  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 = 'TWAS_sig_genes')),
      pageLength = 50
    )
  )
}

sig_transcripts_table <- read_csv("data/derived/TWAS/sig_transcripts_table.csv")

tallies <- sort(table(sig_transcripts_table$type))

big_table <- sig_transcripts_table %>%
  select(-type) %>%
  left_join(
    sig_transcripts_table %>%
      group_by(FBID) %>%
      summarise(type = list(type), .groups = "drop") %>%
      mutate(type = str_remove_all(map_chr(type, ~ paste0(.x, collapse = "; ")), "sig_")),
    by = "FBID") %>%
  select(FBID, gene_name, type, chromosome, AveExpr, male_bias_in_expression, everything()) %>%
  mutate(chromosome = replace(chromosome, is.na(chromosome), "Unknown")) %>%
  select(-gene_symbol, -entrez_id) %>%
  arrange(-P_sex_antag) %>%
  rename(`Gene name` = gene_name,
         Significance = type,
         Chromosome = chromosome,
         `Female early` = beta_FE,
         `Female late` = beta_FL,
         `Male early` = beta_ME,
         `Male late` = beta_ML,
         `Male bias in expression (logFC)` = male_bias_in_expression,
         `Average expression level` = AveExpr) %>%
  rename_all(~ str_remove_all(.x, "ED[_]")) %>%
  distinct() 

Table showing the significant transcripts

The table shows the 784 transcripts that were significant in one or more ways (shown in the ‘significance’ column), e.g. transcripts whose abundance showed a sexually antagonistic relationship with fitness in the early-life assays are denoted SA_early. Columns 7-10 show the mashr-adjusted regression coefficients that relate the line mean transcript abundance to the line mean fitnesses. The last five columns give the mixture assignment probabilities from mashr. Abbreviations: AC = age concordant, SC = sexually concordant, SA = sexually antagonistic.

We define significantly antagonistic transcripts as those where the relationship with fitness is significantly positive for one sex (or age class) and significantly negative for the other, with LFSR < 0.05. Similarly, we define significantly concordant transcripts as those where the relationship with fitness is significantly positive for one sex or age class and also significantly positive for the other (LFSR < 0.05). This is quite conservative, because a transcript needs to have a LFSR < 0.05 for two tests, giving two chances for a ‘false negative’.

big_table %>%  my_data_table()

Count the numbers of significant genes

Abbreviations: AC = age concordant, SC = sexually concordant, SA = sexually antagonistic.

tallies %>%
  enframe() %>%
  arrange(-value) %>%
  mutate(x = str_remove_all(name, "sig_"),
         `Number statistically significant` = value) %>%
  mutate(x = str_replace_all(x, "AC", "Age concordant"),
         x = str_replace_all(x, "SC", "Sexually concordant"),
         x = str_replace_all(x, "SA", "Sexually angatonistic"),
         x = str_replace_all(x, "_females", " (in females)"),
         x = str_replace_all(x, "_males", " (in males)"),
         x = str_replace_all(x, "_early", " (in early life)"),
         x = str_replace_all(x, "_late", " (in late life)")) %>%
  rename(`Type of transcript` = x) %>%
  select(`Type of transcript`, `Number statistically significant`) %>%
  kable_table()
Type of transcript Number statistically significant
Age concordant (in males) 483
Age concordant (in females) 466
Sexually concordant (in late life) 142
Sexually concordant (in early life) 132
Sexually angatonistic (in early life) 40
Sexually angatonistic (in late life) 35

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] kableExtra_1.1.0 DT_0.13          forcats_0.5.0    stringr_1.4.0   
 [5] dplyr_1.0.0      purrr_0.3.4      readr_1.3.1      tidyr_1.1.0     
 [9] tibble_3.0.1     ggplot2_3.3.2    tidyverse_1.3.0  workflowr_1.6.2 

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.4.6      lubridate_1.7.8   lattice_0.20-41   assertthat_0.2.1 
 [5] rprojroot_1.3-2   digest_0.6.25     R6_2.4.1          cellranger_1.1.0 
 [9] backports_1.1.7   reprex_0.3.0      evaluate_0.14     highr_0.8        
[13] httr_1.4.1        pillar_1.4.4      rlang_0.4.6       readxl_1.3.1     
[17] rstudioapi_0.11   whisker_0.4       blob_1.2.1        rmarkdown_2.5    
[21] webshot_0.5.2     htmlwidgets_1.5.1 munsell_0.5.0     broom_0.5.6      
[25] compiler_4.0.3    httpuv_1.5.3.1    modelr_0.1.8      xfun_0.19        
[29] pkgconfig_2.0.3   htmltools_0.5.0   tidyselect_1.1.0  fansi_0.4.1      
[33] viridisLite_0.3.0 crayon_1.3.4      dbplyr_1.4.4      withr_2.2.0      
[37] later_1.0.0       grid_4.0.3        nlme_3.1-149      jsonlite_1.7.0   
[41] gtable_0.3.0      lifecycle_0.2.0   DBI_1.1.0         git2r_0.27.1     
[45] magrittr_2.0.1    scales_1.1.1      cli_2.0.2         stringi_1.5.3    
[49] fs_1.4.1          promises_1.1.0    xml2_1.3.2        ellipsis_0.3.1   
[53] generics_0.0.2    vctrs_0.3.0       tools_4.0.3       glue_1.4.2       
[57] hms_0.5.3         crosstalk_1.1.0.1 yaml_2.2.1        colorspace_1.4-1 
[61] rvest_0.3.5       knitr_1.30        haven_2.3.1