Last updated: 2021-07-01

Checks: 6 1

Knit directory: sars-cov2-gisaid/

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 file has unstaged changes. 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(20210408) 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 9c3698e. 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/.Rhistory
    Ignored:    data/.DS_Store

Untracked files:
    Untracked:  analysis/1_working_with_the_data.snpeff.v2.gisaid_v2.0.rmd
    Untracked:  analysis/2_human_lineage_mutations.snpeff.v1.rmd
    Untracked:  analysis/hard_coded_params.R
    Untracked:  code/make_debug_miniature_dataset.R
    Untracked:  code/make_genome_positions.R
    Untracked:  data/2021-04-09/
    Untracked:  data/MutCounts_with_covariates.csv
    Untracked:  data/proteins_sarscov2_genome_positions.rds
    Untracked:  how_to_work_together.md
    Untracked:  output/README.html

Unstaged changes:
    Modified:   README.md
    Modified:   _workflowr.yml
    Deleted:    analysis/S0_creating_data_bywindows_lineages_OBSOLETE.Rmd
    Modified:   analysis/S0_creating_data_bywindows_lineages_byphase.Rmd
    Modified:   analysis/S1_adding_covariates_multiple_lineage_early_late.Rmd
    Modified:   analysis/S1_adding_covariates_multiple_lineage_period2.Rmd
    Modified:   analysis/S1_adding_covariates_multiple_lineage_period3.Rmd
    Modified:   analysis/S2_mutations_counts_covs_exploration_visuals.Rmd
    Modified:   analysis/S2_mutations_counts_covs_exploration_visuals_period2.Rmd
    Modified:   analysis/S2_mutations_counts_covs_exploration_visuals_period3.Rmd
    Modified:   analysis/S4_mutation_counts_models_period1.Rmd
    Modified:   analysis/S4_mutation_counts_models_period2.Rmd
    Modified:   analysis/S4_mutation_counts_models_period3.Rmd
    Modified:   analysis/_site.yml
    Modified:   analysis/about.Rmd
    Modified:   analysis/index.Rmd
    Modified:   code/README.md
    Modified:   data/README.md
    Modified:   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/S2_mutations_counts_covs_exploration_visuals.Rmd) and HTML (docs/S2_mutations_counts_covs_exploration_visuals.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 9c3698e tbata 2021-06-30 Added 100 nt windows for 3 periods on downsized 300k data. and update of all analysis

# data_path <- "data/2021-06-18/"
source("analysis/hard_coded_params.R")

Using data version: data/2021-06-18/

Loading data from bins and covariates

suppressPackageStartupMessages(library(tidyverse)) # to avoid messy 
library(ggsci)
library(ggrepel)
library(cowplot)

data100_annotated<- readRDS( "output/data_100pb_pangolin_period1_withCovs.rds")
dim(data100_annotated)
[1] 2456   24
names(data100_annotated)
 [1] "gene_name"           "gene_bin"            "type"               
 [4] "W.R.dS"              "W.G.dS"              "R.G.dS"             
 [7] "ii.CD4"              "ii.CD8"              "ii.CD4.max"         
[10] "ii.CD8.max"          "ENC"                 "ENC_STD"            
[13] "GC"                  "CAI"                 "CAI_STD"            
[16] "PPI"                 "GO"                  "Prot.Dom"           
[19] "pangolin_lineage"    "gene"                "unique_mutations"   
[22] "max_genomes_mutated" "window_start"        "window_start_gis"   

Overview dataset

data100_annotated %>%
  select(gene_name, gene_bin, type, unique_mutations, W.G.dS) %>%
  slice(400:410) %>%
  knitr::kable(digits = 2)
gene_name gene_bin type unique_mutations W.G.dS
nsp8 3 S 0 0.39
nsp8 4 NS 3 0.45
nsp8 4 S 1 0.45
nsp8 5 NS 1 0.52
nsp8 5 S 0 0.52
nsp8 6 S 1 0.57
nsp8 6 NS 0 0.57
nsp9 1 NS 0 0.65
nsp9 1 S 2 0.65
nsp9 2 S 0 0.75
nsp9 2 NS 2 0.75
data100_annotated %>%
  select(gene, gene_bin, type, unique_mutations, W.G.dS) %>%
  slice(400:410) %>%
  knitr::kable(digits = 2)
gene gene_bin type unique_mutations W.G.dS
NA 3 S 0 0.39
nsp8 4 NS 3 0.45
nsp8 4 S 1 0.45
nsp8 5 NS 1 0.52
NA 5 S 0 0.52
nsp8 6 S 1 0.57
NA 6 NS 0 0.57
NA 1 NS 0 0.65
nsp9 1 S 2 0.65
NA 2 S 0 0.75
nsp9 2 NS 2 0.75

Overview counts

checking distributions

summary(data100_annotated$unique_mutations)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
 0.0000  0.0000  0.0000  0.3799  0.0000 11.0000 

mutations along the genome

ggplot(data100_annotated, aes(x=window_start_gis, y=unique_mutations, size=max_genomes_mutated, color=type)) + 
  geom_point() +
  ylim(c(0,NA)) +
  xlim(c(0,NA)) +
  xlab("Genome position") +
  ylab("Number of unique mutations in 100bp") +
  scale_color_aaas(name="") +
  scale_size("Max genomes mutated", range=c(1,5)) +
  # theme(legend.position = c(0.5,1),legend.justification = c(0.5,1))+
  # theme(legend.box.background = element_rect(fill="#F0F0F0")) +
  NULL

histogram of counts

ggplot(data100_annotated, aes(x=unique_mutations,  fill=type)) + 
  geom_histogram() +
  ylim(c(0,NA)) +
  xlim(c(0,NA)) +
  ylab("Number of windows") +
  xlab("Number of unique mutations in 100bp") +
  scale_fill_aaas(name="") +
  facet_wrap(~ pangolin_lineage + type, ncol = 2, scales = "free_y")+
  # theme(legend.position = c(0.5,1),legend.justification = c(0.5,1))+
  # theme(legend.box.background = element_rect(fill="#F0F0F0")) +
  NULL
`stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
Warning: Removed 8 rows containing missing values (geom_bar).

Counts of mutations versus immunogenicity index

data100_annotated %>%
  filter(gene %in% c("N","M","S")) %>%
  filter(type == "NS") %>%
ggplot(aes(x=ii.CD8.max, y=unique_mutations, size=max_genomes_mutated, color=gene_name)) + 
  geom_point() +
  geom_smooth(method = "lm", se=T, color= "black")+
  ylim(c(0,NA)) +
  xlim(c(0,NA)) +
  xlab("ii.CD8max") +
  ylab("Number of non syn mutations in 100bp") +
  scale_color_aaas(name="") +
  scale_size("Max genomes mutated", range=c(0.8,3)) +
  facet_wrap(~ gene + pangolin_lineage , ncol = 2, scales = "free_y")+
  # theme(legend.position = "none")+
  theme(legend.position = c(0.5,1),legend.justification = c(0.5,1))+
  # theme(legend.box.background = element_rect(fill="#F0F0F0")) +
  NULL
`geom_smooth()` using formula 'y ~ x'
Warning in qt((1 - level)/2, df): NaNs produced

Warning in qt((1 - level)/2, df): NaNs produced
Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning -
Inf

Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning -
Inf

Warning in max(ids, na.rm = TRUE): no non-missing arguments to max; returning -
Inf

dS versus unique mutations

names(data100_annotated)
 [1] "gene_name"           "gene_bin"            "type"               
 [4] "W.R.dS"              "W.G.dS"              "R.G.dS"             
 [7] "ii.CD4"              "ii.CD8"              "ii.CD4.max"         
[10] "ii.CD8.max"          "ENC"                 "ENC_STD"            
[13] "GC"                  "CAI"                 "CAI_STD"            
[16] "PPI"                 "GO"                  "Prot.Dom"           
[19] "pangolin_lineage"    "gene"                "unique_mutations"   
[22] "max_genomes_mutated" "window_start"        "window_start_gis"   
data100_annotated %>%
  filter(type == "NS") %>%
ggplot(aes(x= log10(1+W.G.dS) , y=unique_mutations, size=max_genomes_mutated, color=gene_name)) + 
  geom_jitter(height = 0.2) +
  ylim(c(0,NA)) +
  xlim(c(0,NA)) +
  xlab("log10(dS) ") +
  ylab("Number of non syn mutations in 100bp") +
  scale_size("Max genomes mutated", range=c(0.8,3)) +
  scale_color_viridis_d(direction = -1)+
  facet_wrap(~ pangolin_lineage , ncol = 1, scales = "free_y")+
  geom_smooth(method = "loess", aes(color=NULL), color= "black", size=0.5)+
  # theme(legend.position = "none")+
  # theme(legend.position = c(0.5,1),legend.justification = c(0.5,1))+
  # theme(legend.box.background = element_rect(fill="#F0F0F0")) +
  NULL
`geom_smooth()` using formula 'y ~ x'
Warning: Removed 443 rows containing missing values (geom_point).
Warning: Removed 57 rows containing missing values (geom_smooth).


sessionInfo()
R version 4.0.2 (2020-06-22)
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_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
 [1] cowplot_1.1.0   ggrepel_0.9.1   ggsci_2.9       forcats_0.5.0  
 [5] stringr_1.4.0   dplyr_1.0.2     purrr_0.3.4     readr_1.3.1    
 [9] tidyr_1.1.1     tibble_3.0.3    ggplot2_3.3.2   tidyverse_1.3.0
[13] workflowr_1.6.2

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.5        lattice_0.20-41   lubridate_1.7.9   assertthat_0.2.1 
 [5] rprojroot_2.0.2   digest_0.6.25     R6_2.4.1          cellranger_1.1.0 
 [9] backports_1.1.9   reprex_0.3.0      evaluate_0.14     httr_1.4.2       
[13] highr_0.8         pillar_1.4.6      rlang_0.4.7       readxl_1.3.1     
[17] rstudioapi_0.11   whisker_0.4       blob_1.2.1        Matrix_1.2-18    
[21] rmarkdown_2.3     splines_4.0.2     labeling_0.3      munsell_0.5.0    
[25] broom_0.7.0       compiler_4.0.2    httpuv_1.5.4      modelr_0.1.8     
[29] xfun_0.16         pkgconfig_2.0.3   mgcv_1.8-31       htmltools_0.5.0  
[33] tidyselect_1.1.0  viridisLite_0.4.0 fansi_0.4.1       crayon_1.3.4     
[37] dbplyr_1.4.4      withr_2.2.0       later_1.1.0.1     grid_4.0.2       
[41] nlme_3.1-148      jsonlite_1.7.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     farver_2.0.3      fs_1.5.0         
[53] promises_1.1.1    xml2_1.3.2        ellipsis_0.3.1    generics_0.0.2   
[57] vctrs_0.3.2       tools_4.0.2       glue_1.4.1        hms_0.5.3        
[61] yaml_2.2.1        colorspace_1.4-1  rvest_0.3.6       knitr_1.29       
[65] haven_2.3.1