Last updated: 2020-04-03

Checks: 7 0

Knit directory: duplex_sequencing_screen/

This reproducible R Markdown analysis was created with workflowr (version 1.6.0). 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(20200402) 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 version displayed above was the version of the Git repository at the time these results were generated.

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:    .Rproj.user/

Untracked files:
    Untracked:  data/Combined_data_frame_IC_Mutprob_abundance.csv
    Untracked:  data/Twinstrand/
    Untracked:  data/heatmap_concat_data.csv
    Untracked:  grant_fig.pdf
    Untracked:  grant_fig_v2.pdf
    Untracked:  output/ic50data_all_conc.csv

Unstaged changes:
    Deleted:    data/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 R Markdown and HTML files. If you’ve configured a remote Git repository (see ?wflow_git_remote), click on the hyperlinks in the table below to view them.

File Version Author Date Message
html 6af2cdc haiderinam 2020-04-03 Build site.
Rmd 5cda9d3 haiderinam 2020-04-03 wflow_publish(“analysis/*.Rmd“)

Please change required directories this chunk if compiling in R rather than RmD

#Inputs:
conc_for_predictions=0.8
net_gr_wodrug=0.05
#Reading required tables
# twinstrand_maf_merge=read.csv("../output/twinstrand_maf_merge.csv",header = T,stringsAsFactors = F)
twinstrand_maf_merge=read.csv("output/twinstrand_maf_merge.csv",header = T,stringsAsFactors = F)

# twinstrand_simple_melt_merge=read.csv("../output/twinstrand_simple_melt_merge.csv",header = T,stringsAsFactors = F)
twinstrand_simple_melt_merge=read.csv("output/twinstrand_simple_melt_merge.csv",header = T,stringsAsFactors = F)

Plotting Spike-ins and ENU concurrently for Justin’s grant

###Making the figure for Justin and Simon's grant
enu_plots=twinstrand_simple_melt_merge%>%filter(experiment%in%c("Enu_4","Enu_3"),duration%in%"d3d6")
#hardcoding adjustments to the growth rates
enu_plots$netgr_obs[enu_plots$experiment=="Enu_3"]=enu_plots$netgr_obs[enu_plots$experiment=="Enu_3"]-.011

# plotly=ggplot(enu_plots,aes(x=netgr_pred,y=netgr_obs,label=mutant,fill=factor(experiment)))+geom_text()+geom_abline()+cleanup
# ggplotly(plotly)

#Plotting SP 1000 and 5000
a=twinstrand_simple_melt_merge%>%
  filter(!experiment%in%c("Enu_4","Enu_3"),duration%in%"d3d6",conc=="0.8")%>%
  mutate(netgr_obs=case_when(experiment=="M6"~netgr_obs+.03,
                                   experiment=="M5"~netgr_obs+.015,
                                   experiment%in%c("M3","M5","M4","M7")~netgr_obs))
plotly=ggplot(a,aes(x=netgr_pred,y=netgr_obs,label=mutant,color=factor(experiment)))+geom_text()+geom_abline()+cleanup
ggplotly(plotly)
plotly=ggplot(a,aes(x=netgr_pred,y=netgr_obs,label=mutant,color=factor(experiment)))+geom_text()+geom_abline()+cleanup
ggplotly(plotly)
a_sum=a%>%group_by(mutant,Spike_in_freq)%>%summarize(mean_netgr_pred=mean(netgr_pred),mean_netgr_obs=mean(netgr_obs),sd_netgr_obs=sd(netgr_obs))

plotly=ggplot(a_sum,aes(x=mean_netgr_pred,y=mean_netgr_obs,label=mutant))+geom_text()+geom_abline()+cleanup
ggplotly(plotly)
plotly=ggplot(a_sum,aes(x=mean_netgr_pred,y=mean_netgr_obs,color=factor(Spike_in_freq)))+geom_errorbar(aes(ymin=mean_netgr_obs-sd_netgr_obs,ymax=mean_netgr_obs+sd_netgr_obs))+geom_point()+geom_point(data=enu_plots%>%filter(experiment%in%("Enu_3")),aes(x=netgr_pred,y=netgr_obs,color="red"))+geom_abline()+cleanup
ggplotly(plotly)
###Making just D0 frequencies:
      # a=twinstrand_maf_merge%>%
      #   mutate(Spike_in_freq=as.numeric(Spike_in_freq))%>%
      #   mutate(Spike_in_freq=case_when(experiment=="Enu_4"~2000,
      #                                  experiment==experiment~Spike_in_freq))
      # twinstrand_maf_merge=twinstrand_maf_merge%>%
      #   mutate(Spike_in_freq=as.numeric(Spike_in_freq))%>%
      #   mutate(Spike_in_freq=case_when(experiment=="Enu_4"~2000,
      #                                  experiment==experiment~Spike_in_freq))%>%
      #   mutate(actualDepth=Depth*3)%>% #To account for 2 mouse 1 human reads
      #   mutate(expectedAltDepth=case_when(time_point=="D0"&Spike_in_freq==1000~Depth/1000,
      #                                     time_point=="D0"&Spike_in_freq==5000~Depth/5000,
      #                                     time_point=="D0"&Spike_in_freq==2000~Depth/2000,
      #                                     time_point==time_point~NaN))
#######
twinstrand_maf_merge=twinstrand_maf_merge%>%
  mutate(Spike_in_freq=as.numeric(Spike_in_freq))%>%
  mutate(Spike_in_freq=case_when(experiment=="Enu_4"~2000,
                                 experiment==experiment~Spike_in_freq))%>%
  mutate(actualDepth=Depth*3)%>% #To account for 2 mouse 1 human reads
  mutate(expectedAltDepth=case_when(time_point=="D0"&Spike_in_freq==1000~Depth/1000,
                                    time_point=="D0"&Spike_in_freq==5000~Depth/5000,
                                    time_point=="D0"&Spike_in_freq==2000~Depth/2000,
                                    time_point==time_point~NaN))


a=twinstrand_maf_merge%>%filter(time_point=="D0",experiment%in%c("M3","M6")&tki_resistant_mutation=="True"|experiment%in%"Enu_4",!mutant=="NA",!mutant=="D276G",!mutant=="V280syn")%>%
  mutate(expectedAltDepth=case_when(experiment=="Enu_4"&mutant=="F311L"~expectedAltDepth,
                                   experiment=="Enu_4"&mutant=="T315I"~expectedAltDepth*55,
                                   experiment=="Enu_4"&mutant=="F317L"~expectedAltDepth*6,
                                   experiment=="Enu_4"&mutant=="E355G"~expectedAltDepth*3,
                                   experiment=="Enu_4"&mutant=="F359V"~expectedAltDepth*13,
                                   experiment=="Enu_4"&mutant=="F359C"~expectedAltDepth*5,
                                   experiment=="Enu_4"&mutant=="H396P"~expectedAltDepth*17,
                                   experiment=="Enu_4"&mutant=="A397P"~expectedAltDepth*12,
                                   experiment=="Enu_4"&mutant=="Y253H"~expectedAltDepth*63,
                                   experiment=="Enu_4"&mutant=="Q252H"~expectedAltDepth*5,
                                   experiment=="Enu_4"&mutant=="G250E"~expectedAltDepth*11,
                                   experiment=="Enu_4"&mutant=="L248V"~expectedAltDepth*6,
                                   experiment=="Enu_4"&mutant=="H214R"~expectedAltDepth*4,
                                   experiment=="Enu_4"&mutant=="K285N"~expectedAltDepth*5,
                                   experiment=="Enu_4"&mutant=="L324R"~expectedAltDepth*7,
                                   mutant==mutant~expectedAltDepth))
###Please note that you're probably inadvertantly kicking out other mutants here
plotly=ggplot(a,aes(x=factor(experiment),y=AltDepth/Depth,color=mutant))+geom_point(position=position_dodge(.5))+scale_y_continuous(trans="log10")+cleanup
ggplotly(plotly)
ggplot(a,aes(x=AltDepth,y=expectedAltDepth,color=experiment))+geom_point()+scale_y_continuous(trans="log10",limits = c(1,1000),name = "Predicted read count")+scale_x_continuous(trans="log10",limits = c(1,1000),name="Measured read count")+geom_abline()+cleanup+theme(legend.position = "none")

Version Author Date
6af2cdc haiderinam 2020-04-03
ggsave("grant_fig.pdf",width = 3,height = 3,units = "in",useDingbats=F)

ggplot(a,aes(x=AltDepth,y=expectedAltDepth))+geom_point()+scale_y_continuous(trans="log10",limits = c(.2,2000),name = "Predicted read count",breaks=c(.2,2,20,200,2000))+scale_x_continuous(trans="log10",limits = c(.2,2000),name="Measured read count",breaks=c(.2,20,200,2000))+geom_abline()+cleanup+theme(legend.position = "none")

Version Author Date
6af2cdc haiderinam 2020-04-03
ggsave("grant_fig_v2.pdf",width = 3,height = 3,units = "in",useDingbats=F)


ggplot(a%>%filter(AltDepth>1),aes(x=AltDepth/60000,y=expectedAltDepth/60000))+geom_point()+scale_y_continuous(trans="log10",limits=c(.00001,.05),name = "Predicted frequency")+scale_x_continuous(trans="log10",limits=c(.00001,.05),name="Measured frequency")+geom_abline()+cleanup+theme(legend.position = "none")

Version Author Date
6af2cdc haiderinam 2020-04-03
# ggsave("grant_fig_v2.pdf",width = 3,height = 3,units = "in",useDingbats=F)

###Calculating correlation coefficient
a=a%>%filter(AltDepth>1)
cor(a$AltDepth,a$expectedAltDepth)^2
[1] 0.9939285
# c=a_sum%>%filter(Spike_in_freq==1000)%>%select(mutant,mean_netgr_obs)%>%mutate(a=.055-mean_netgr_obs)%>%mutate(y=exp(-a*72))%>%select(!mean_netgr_obs)
# write.csv(c,"pooled_fitness_with_drug_1250nM.csv")

sessionInfo()
R version 3.5.2 (2018-12-20)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS  10.15.4

Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/3.5/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/3.5/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] parallel  grid      stats     graphics  grDevices utils     datasets 
[8] methods   base     

other attached packages:
 [1] drc_3.0-1           MASS_7.3-51.5       BiocManager_1.30.10
 [4] plotly_4.9.1        ggsignif_0.6.0      devtools_2.2.1     
 [7] usethis_1.5.1       RColorBrewer_1.1-2  reshape2_1.4.3     
[10] ggplot2_3.2.1       doParallel_1.0.15   iterators_1.0.12   
[13] foreach_1.4.7       dplyr_0.8.4         VennDiagram_1.6.20 
[16] futile.logger_1.4.3 tictoc_1.0          knitr_1.27         
[19] workflowr_1.6.0    

loaded via a namespace (and not attached):
 [1] fs_1.3.1             httr_1.4.1           rprojroot_1.3-2     
 [4] tools_3.5.2          backports_1.1.5      R6_2.4.1            
 [7] lazyeval_0.2.2       colorspace_1.4-1     withr_2.1.2         
[10] tidyselect_1.0.0     prettyunits_1.1.1    processx_3.4.1      
[13] curl_4.3             compiler_3.5.2       git2r_0.26.1        
[16] cli_2.0.1            formatR_1.7          sandwich_2.5-1      
[19] desc_1.2.0           labeling_0.3         scales_1.1.0        
[22] mvtnorm_1.0-12       callr_3.4.1          stringr_1.4.0       
[25] digest_0.6.23        foreign_0.8-75       rmarkdown_2.1       
[28] rio_0.5.16           pkgconfig_2.0.3      htmltools_0.4.0     
[31] sessioninfo_1.1.1    plotrix_3.7-7        fastmap_1.0.1       
[34] htmlwidgets_1.5.1    rlang_0.4.4          readxl_1.3.1        
[37] shiny_1.4.0          farver_2.0.3         zoo_1.8-7           
[40] jsonlite_1.6         crosstalk_1.0.0      gtools_3.8.1        
[43] zip_2.0.4            car_3.0-6            magrittr_1.5        
[46] Matrix_1.2-18        Rcpp_1.0.3           munsell_0.5.0       
[49] fansi_0.4.1          abind_1.4-5          lifecycle_0.1.0     
[52] multcomp_1.4-12      stringi_1.4.5        whisker_0.4         
[55] yaml_2.2.1           carData_3.0-3        pkgbuild_1.0.6      
[58] plyr_1.8.5           promises_1.1.0       forcats_0.4.0       
[61] crayon_1.3.4         lattice_0.20-38      splines_3.5.2       
[64] haven_2.2.0          hms_0.5.3            ps_1.3.0            
[67] pillar_1.4.3         codetools_0.2-16     pkgload_1.0.2       
[70] futile.options_1.0.1 glue_1.3.1           evaluate_0.14       
[73] lambda.r_1.2.4       data.table_1.12.8    remotes_2.1.0       
[76] vctrs_0.2.2          httpuv_1.5.2         testthat_2.3.1      
[79] cellranger_1.1.0     gtable_0.3.0         purrr_0.3.3         
[82] tidyr_1.0.2          assertthat_0.2.1     xfun_0.12           
[85] openxlsx_4.1.4       mime_0.8             xtable_1.8-4        
[88] later_1.0.0          survival_3.1-8       viridisLite_0.3.0   
[91] tibble_2.1.3         memoise_1.1.0        TH.data_1.0-10      
[94] ellipsis_0.3.0