Last updated: 2023-01-13

Checks: 6 1

Knit directory: ChromatinSplicingQTLs/analysis/

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(20191126) 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 5e6b611. 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:    analysis/.20221202_ProcessSmallMolecule.Rmd.swp
    Ignored:    analysis/.Rhistory
    Ignored:    code/.DS_Store
    Ignored:    code/.RData
    Ignored:    code/._.DS_Store
    Ignored:    code/._README.md
    Ignored:    code/._report.html
    Ignored:    code/.ipynb_checkpoints/
    Ignored:    code/.snakemake/
    Ignored:    code/APA_Processing/
    Ignored:    code/Alignments/
    Ignored:    code/ChromHMM/
    Ignored:    code/ENCODE/
    Ignored:    code/ExpressionAnalysis/
    Ignored:    code/FastqFastp/
    Ignored:    code/FastqFastpSE/
    Ignored:    code/Genotypes/
    Ignored:    code/H3K36me3_CutAndTag.pdf
    Ignored:    code/IntronSlopes/
    Ignored:    code/Metaplots/
    Ignored:    code/Misc/
    Ignored:    code/MiscCountTables/
    Ignored:    code/Multiqc/
    Ignored:    code/Multiqc_chRNA/
    Ignored:    code/NonCodingRNA/
    Ignored:    code/NonCodingRNA_annotation/
    Ignored:    code/PeakCalling/
    Ignored:    code/Phenotypes/
    Ignored:    code/PlotGruberQTLs/
    Ignored:    code/PlotQTLs/
    Ignored:    code/ProCapAnalysis/
    Ignored:    code/QC/
    Ignored:    code/QTL_SNP_Enrichment/
    Ignored:    code/QTLs/
    Ignored:    code/RPKM_tables/
    Ignored:    code/ReferenceGenome/
    Ignored:    code/Rplots.pdf
    Ignored:    code/Session.vim
    Ignored:    code/SmallMolecule/
    Ignored:    code/SplicingAnalysis/
    Ignored:    code/TODO
    Ignored:    code/Tehranchi/
    Ignored:    code/bigwigs/
    Ignored:    code/bigwigs_FromNonWASPFilteredReads/
    Ignored:    code/config/.DS_Store
    Ignored:    code/config/._.DS_Store
    Ignored:    code/config/.ipynb_checkpoints/
    Ignored:    code/config/config.local.yaml
    Ignored:    code/dag.pdf
    Ignored:    code/dag.png
    Ignored:    code/dag.svg
    Ignored:    code/debug.ipynb
    Ignored:    code/debug_python.ipynb
    Ignored:    code/deepTools/
    Ignored:    code/featureCounts/
    Ignored:    code/featureCountsBasicGtf/
    Ignored:    code/gwas_summary_stats/
    Ignored:    code/hyprcoloc/
    Ignored:    code/igv_session.xml
    Ignored:    code/log
    Ignored:    code/logs/
    Ignored:    code/notebooks/.ipynb_checkpoints/
    Ignored:    code/pi1/
    Ignored:    code/rules/.ipynb_checkpoints/
    Ignored:    code/rules/OldRules/
    Ignored:    code/rules/notebooks/
    Ignored:    code/scratch/
    Ignored:    code/scripts/.FitSmallMoleculeModels.R.swp
    Ignored:    code/scripts/.ipynb_checkpoints/
    Ignored:    code/scripts/GTFtools_0.8.0/
    Ignored:    code/scripts/__pycache__/
    Ignored:    code/scripts/liftOverBedpe/liftOverBedpe.py
    Ignored:    code/snakemake.dryrun.log
    Ignored:    code/snakemake.log
    Ignored:    code/snakemake.sbatch.log
    Ignored:    code/test.introns.bed
    Ignored:    code/test.introns2.bed
    Ignored:    data/.DS_Store
    Ignored:    data/._.DS_Store
    Ignored:    data/._20220414203249_JASPAR2022_combined_matrices_25818_jaspar.txt
    Ignored:    data/GWAS_catalog_summary_stats_sources/._list_gwas_summary_statistics_6_Apr_2022-10.csv
    Ignored:    data/GWAS_catalog_summary_stats_sources/._list_gwas_summary_statistics_6_Apr_2022-11.csv
    Ignored:    data/GWAS_catalog_summary_stats_sources/._list_gwas_summary_statistics_6_Apr_2022-2.csv
    Ignored:    data/GWAS_catalog_summary_stats_sources/._list_gwas_summary_statistics_6_Apr_2022-3.csv
    Ignored:    data/GWAS_catalog_summary_stats_sources/._list_gwas_summary_statistics_6_Apr_2022-4.csv
    Ignored:    data/GWAS_catalog_summary_stats_sources/._list_gwas_summary_statistics_6_Apr_2022-5.csv
    Ignored:    data/GWAS_catalog_summary_stats_sources/._list_gwas_summary_statistics_6_Apr_2022-6.csv
    Ignored:    data/GWAS_catalog_summary_stats_sources/._list_gwas_summary_statistics_6_Apr_2022-7.csv
    Ignored:    data/GWAS_catalog_summary_stats_sources/._list_gwas_summary_statistics_6_Apr_2022-8.csv
    Ignored:    data/GWAS_catalog_summary_stats_sources/._list_gwas_summary_statistics_6_Apr_2022.csv
    Ignored:    data/Metaplots/.DS_Store

Untracked files:
    Untracked:  analysis/20230110_eQTL_sQTL_hQTL_Colocalization.Rmd
    Untracked:  analysis/20230112_AreGenesWithMoreUnannotatedLessInPolyA.Rmd
    Untracked:  code/scripts/FitSmallMoleculeModels.R
    Untracked:  code/snakemake_profiles/slurm/__pycache__/

Unstaged changes:
    Modified:   analysis/Figures_BensTasksFromOutline.Rmd
    Modified:   code/rules/common.py
    Modified:   code/rules/featureCounts.smk
    Modified:   code/scripts/GenometracksByGenotype

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.


Intro

That stacked bar graph of the number of eQTLs that coloc with an hQTL vs sQTL vs neither vs both…

Analysis

library(tidyverse)
library(data.table)

PhenotypeAliases <- read_tsv("../data/Phenotypes_recode_for_Plotting.txt")

PC.ShortAliases <- PhenotypeAliases %>%
  dplyr::select(PC, ShorterAlias) %>% deframe()

coloc.results <- read_tsv("../code/hyprcoloc/Results/ForColoc/MolColocStandard/results.txt.gz")

coloc.results.tidycolocalized <- read_tsv("../code/hyprcoloc/Results/ForColoc/MolColocStandard/tidy_results_OnlyColocalized.txt.gz") %>%
  separate(phenotype_full, into=c("PC", "P"), sep=";")

# Get all the phenotype classes
coloc.results.tidycolocalized$PC %>% unique()
 [1] "polyA.Splicing"                   "MetabolicLabelled.30min"         
 [3] "MetabolicLabelled.60min"          "H3K27AC"                         
 [5] "H3K4ME3"                          "H3K4ME1"                         
 [7] "chRNA.IER"                        "ProCap"                          
 [9] "polyA.Splicing.Subset_YRI"        "CTCF"                            
[11] "chRNA.Expression_ncRNA"           "chRNA.Splicing.Order"            
[13] "Expression.Splicing"              "Expression.Splicing.Subset_YRI"  
[15] "chRNA.Splicing"                   "MetabolicLabelled.30min.Splicing"
[17] "MetabolicLabelled.60min.Splicing" "chRNA.Expression.Splicing"       
[19] "H3K36ME3"                         "APA_Nuclear"                     
[21] "APA_Total"                        "polyA.IER"                       
[23] "MetabolicLabelled.30min.IER"      "MetabolicLabelled.60min.IER"     
[25] "polyA.IER.Subset_YRI"             "chRNA.Slopes"                    
eQTLs <- read_delim("../code/QTLs/QTLTools/Expression.Splicing.Subset_YRI/PermutationPassForColoc.txt.gz", delim=' ') %>%
  separate(phe_id, into=c("phe_id", "Locus"), sep=":") %>%
  filter(adj_beta_pval < 0.01)

bind_rows(
  coloc.results.tidycolocalized %>%
    group_by(Locus, snp) %>%
    filter(any(PC=="Expression.Splicing.Subset_YRI")) %>%
    summarise(
      ContainsChromatinEqtl = any(PC %in% c("H3K27AC", "H3K4ME1", "H3K4ME3")),
      ContainsSqtl = any(PC %in% c("polyA.Splicing_Subset.YRI", "chRNA.Splicing"))
      ) %>%
    right_join(eQTLs) %>%
    replace_na(list(ContainsChromatinEqtl=F, ContainsSqtl=F)) %>%
    mutate(SplicingDataset = "YRI Only"),
  coloc.results.tidycolocalized %>%
    group_by(Locus, snp) %>%
    filter(any(PC=="Expression.Splicing.Subset_YRI")) %>%
    summarise(
      ContainsChromatinEqtl = any(PC %in% c("H3K27AC", "H3K4ME1", "H3K4ME3")),
      ContainsSqtl = any(PC %in% c("polyA.Splicing", "chRNA.Splicing"))
      ) %>%
    right_join(eQTLs) %>%
    replace_na(list(ContainsChromatinEqtl=F, ContainsSqtl=F)) %>%
    mutate(SplicingDataset = "All geuvadis")
) %>%
  mutate(fill=paste(ContainsChromatinEqtl, ContainsSqtl)) %>%
  mutate(fill=recode(fill, !!!c("FALSE FALSE"="Neither", "FALSE TRUE"="sQTL only", "TRUE FALSE"="chromatinQTL only", "TRUE TRUE"="sQTL + chromatinQTL"))) %>%
  mutate(SplicingDataset = factor(SplicingDataset, levels=c("YRI Only","All geuvadis"))) %>%
  mutate(fill = factor(fill, levels=rev(c("sQTL + chromatinQTL","chromatinQTL only", "sQTL only", "Neither")))) %>%
  ggplot(aes(x=SplicingDataset, fill=fill)) +
  geom_bar() +
  scale_x_discrete(labels=c("YRI only\nn=85", "All geauvadis\nn=450")) +
  scale_fill_brewer(type="qual", palette="Set2") +
  labs(title="More chromatin localization with eQTLs than splicing", y="Number of colocalizing eQTLs", x="sQTL source dataset", fill=NULL) +
  theme_classic()

ggsave("../../../carlos_and_ben_shared/rough_figs/OriginalSubplots/NumberOfColocalizing_eQTLs_sQTLs_hQTLs.pdf", height=4, width=4)

same plot but now consider all eQTLs from all geuvadis. but still the two axis groups as sQTLs as called from either YRI only or all geuvadis

eQTLs <- read_delim("../code/QTLs/QTLTools/Expression.Splicing/PermutationPassForColoc.txt.gz", delim=' ') %>%
  separate(phe_id, into=c("phe_id", "Locus"), sep=":") %>%
  filter(adj_beta_pval < 0.01)

bind_rows(
  coloc.results.tidycolocalized %>%
    group_by(Locus, snp) %>%
    filter(any(PC=="Expression.Splicing")) %>%
    summarise(
      ContainsChromatinEqtl = any(PC %in% c("H3K27AC", "H3K4ME1", "H3K4ME3")),
      ContainsSqtl = any(PC %in% c("polyA.Splicing_Subset.YRI", "chRNA.Splicing"))
      ) %>%
    right_join(eQTLs) %>%
    replace_na(list(ContainsChromatinEqtl=F, ContainsSqtl=F)) %>%
    mutate(SplicingDataset = "YRI Only"),
  coloc.results.tidycolocalized %>%
    group_by(Locus, snp) %>%
    filter(any(PC=="Expression.Splicing")) %>%
    summarise(
      ContainsChromatinEqtl = any(PC %in% c("H3K27AC", "H3K4ME1", "H3K4ME3")),
      ContainsSqtl = any(PC %in% c("polyA.Splicing", "chRNA.Splicing"))
      ) %>%
    right_join(eQTLs) %>%
    replace_na(list(ContainsChromatinEqtl=F, ContainsSqtl=F)) %>%
    mutate(SplicingDataset = "All geuvadis")
) %>%
  mutate(fill=paste(ContainsChromatinEqtl, ContainsSqtl)) %>%
  mutate(fill=recode(fill, !!!c("FALSE FALSE"="Neither", "FALSE TRUE"="sQTL only", "TRUE FALSE"="chromatinQTL only", "TRUE TRUE"="sQTL + chromatinQTL"))) %>%
  mutate(SplicingDataset = factor(SplicingDataset, levels=c("YRI Only","All geuvadis"))) %>%
  mutate(fill = factor(fill, levels=rev(c("sQTL + chromatinQTL","chromatinQTL only", "sQTL only", "Neither")))) %>%
  ggplot(aes(x=SplicingDataset, fill=fill)) +
  geom_bar() +
  scale_x_discrete(labels=c("YRI only\nn=85", "All geauvadis\nn=450")) +
  scale_fill_brewer(type="qual", palette="Set2") +
  labs(title="More chromatin localization with eQTLs than splicing", y="Number of colocalizing eQTLs", x="sQTL source dataset", fill=NULL) +
  theme_classic()


sessionInfo()
R version 3.6.1 (2019-07-05)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS/LAPACK: /software/openblas-0.2.19-el7-x86_64/lib/libopenblas_haswellp-r0.2.19.so

locale:
 [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C         LC_TIME=C           
 [4] LC_COLLATE=C         LC_MONETARY=C        LC_MESSAGES=C       
 [7] LC_PAPER=C           LC_NAME=C            LC_ADDRESS=C        
[10] LC_TELEPHONE=C       LC_MEASUREMENT=C     LC_IDENTIFICATION=C 

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] data.table_1.14.2 forcats_0.4.0     stringr_1.4.0     dplyr_1.0.9      
 [5] purrr_0.3.4       readr_1.3.1       tidyr_1.2.0       tibble_3.1.7     
 [9] ggplot2_3.3.6     tidyverse_1.3.0  

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.5         lubridate_1.7.4    assertthat_0.2.1   rprojroot_2.0.2   
 [5] digest_0.6.20      utf8_1.1.4         R6_2.4.0           cellranger_1.1.0  
 [9] backports_1.4.1    reprex_0.3.0       evaluate_0.15      highr_0.9         
[13] httr_1.4.4         pillar_1.7.0       rlang_1.0.5        readxl_1.3.1      
[17] rstudioapi_0.14    rmarkdown_1.13     labeling_0.3       munsell_0.5.0     
[21] broom_1.0.0        compiler_3.6.1     httpuv_1.5.1       modelr_0.1.8      
[25] xfun_0.31          pkgconfig_2.0.2    htmltools_0.5.3    tidyselect_1.1.2  
[29] workflowr_1.6.2    fansi_0.4.0        crayon_1.3.4       dbplyr_1.4.2      
[33] withr_2.5.0        later_0.8.0        grid_3.6.1         jsonlite_1.6      
[37] gtable_0.3.0       lifecycle_1.0.1    DBI_1.1.0          git2r_0.26.1      
[41] magrittr_1.5       scales_1.1.0       cli_3.3.0          stringi_1.4.3     
[45] farver_2.1.0       fs_1.5.2           promises_1.0.1     xml2_1.3.2        
[49] ellipsis_0.3.2     generics_0.1.3     vctrs_0.4.1        RColorBrewer_1.1-2
[53] tools_3.6.1        glue_1.6.2         hms_0.5.3          fastmap_1.1.0     
[57] yaml_2.2.0         colorspace_1.4-1   rvest_0.3.5        knitr_1.39        
[61] haven_2.3.1