Last updated: 2018-08-25

workflowr checks: (Click a bullet for more information)
  • R Markdown file: up-to-date

    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.

  • Environment: empty

    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.

  • Seed: set.seed(20180807)

    The command set.seed(20180807) 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.

  • Session information: recorded

    Great job! Recording the operating system, R version, and package versions is critical for reproducibility.

  • Repository version: a865fa3

    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:    .DS_Store
        Ignored:    .Rhistory
        Ignored:    .Rproj.user/
        Ignored:    .vscode/
        Ignored:    code/.DS_Store
        Ignored:    data/raw/
        Ignored:    src/.DS_Store
        Ignored:    src/.ipynb_checkpoints/
        Ignored:    src/Rmd/.Rhistory
    
    Untracked files:
        Untracked:  Snakefile_clonality
        Untracked:  Snakefile_somatic_calling
        Untracked:  code/analysis_for_garx.Rmd
        Untracked:  code/selection/
        Untracked:  code/yuanhua/
        Untracked:  data/canopy/
        Untracked:  data/cell_assignment/
        Untracked:  data/de_analysis_FTv62/
        Untracked:  data/donor_info_070818.txt
        Untracked:  data/donor_info_core.csv
        Untracked:  data/donor_neutrality.tsv
        Untracked:  data/exome-point-mutations/
        Untracked:  data/fdr10.annot.txt.gz
        Untracked:  data/human_H_v5p2.rdata
        Untracked:  data/human_c2_v5p2.rdata
        Untracked:  data/human_c6_v5p2.rdata
        Untracked:  data/neg-bin-rsquared-petr.csv
        Untracked:  data/neutralitytestr-petr.tsv
        Untracked:  data/sce_merged_donors_cardelino_donorid_all_qc_filt.rds
        Untracked:  data/sce_merged_donors_cardelino_donorid_all_with_qc_labels.rds
        Untracked:  data/sce_merged_donors_cardelino_donorid_unstim_qc_filt.rds
        Untracked:  data/sces/
        Untracked:  data/selection/
        Untracked:  data/simulations/
        Untracked:  data/variance_components/
        Untracked:  docs/figure/selection_models.Rmd/
        Untracked:  figures/
        Untracked:  output/differential_expression/
        Untracked:  output/donor_specific/
        Untracked:  output/line_info.tsv
        Untracked:  output/nvars_by_category_by_donor.tsv
        Untracked:  output/nvars_by_category_by_line.tsv
        Untracked:  output/variance_components/
        Untracked:  references/
        Untracked:  tree.txt
    
    
    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.
Expand here to see past versions:
    File Version Author Date Message
    Rmd d618fe5 davismcc 2018-08-25 Updating analyses
    html 090c1b9 davismcc 2018-08-24 Build site.
    html 02a8343 davismcc 2018-08-24 Build site.
    Rmd 43f15d6 davismcc 2018-08-24 Adding data pre-processing workflow and updating analyses.
    html 43f15d6 davismcc 2018-08-24 Adding data pre-processing workflow and updating analyses.


Load libraries and simulation results

dir.create("figures/simulations", showWarnings = FALSE, recursive = TRUE)
library(ggpubr)
library(tidyverse)
library(cardelino)
library(viridis)
library(cowplot)
lines <- c("euts", "fawm", "feec", "fikt", "garx", "gesg", "heja", "hipn", 
            "ieki", "joxm", "kuco", "laey", "lexy", "naju", "nusw", "oaaz", 
            "oilg", "pipw", "puie", "qayj", "qolg", "qonc", "rozh", "sehl", 
            "ualf", "vass", "vuna", "wahn", "wetu", "xugn", "zoxy", "vils")

Load simulation results

all_files <- paste0(lines, ".simulate.rds")
assign_0 <- matrix(0, nrow = 500, ncol = length(lines))
assign_1 <- matrix(0, nrow = 500, ncol = length(lines))
prob_all <- matrix(0, nrow = 500, ncol = length(lines))

for (i in seq_len(length(all_files))) {
  afile <- all_files[i]
  sim_dat <- readRDS(file.path("data", "simulations", afile))
  assign_0[, i] <- get_prob_label(sim_dat$I_sim)
  assign_1[, i] <- get_prob_label(sim_dat$prob_Gibbs)
  prob_all[, i] <- get_prob_value(sim_dat$prob_Gibbs, mode = "best")
}

Load results from real data

all_files <- paste0("cardelino_results.", lines, 
                    ".filt_lenient.cell_coverage_sites.rds")
n_sites <- rep(0, length(lines))
n_clone <- rep(0, length(lines))
recall_all <- rep(0, length(lines))
for (i in seq_len(length(all_files))) {
  afile <- all_files[i]
  carde_dat <- readRDS(file.path("data", "cell_assignment", afile))
  n_sites[i] <- nrow(carde_dat$D)
  n_clone[i] <- ncol(carde_dat$prob_mat)
  recall_all[i] <- mean(get_prob_value(carde_dat$prob_mat, mode = "best") > 0.5)
}

Overall correlation in assignment rates (recall) from simulated and observed data is 0.959.

precision_simu <- rep(0, length(lines))
for (i in seq_len(length(lines))) {
  idx <- prob_all[, i] > 0.5
  precision_simu[i] <- mean(assign_0[idx, i] == assign_1[idx, i])
}

df <- data.frame(line = lines, n_sites = n_sites, n_clone = n_clone, 
                 recall_real = recall_all, recall_simu = colMeans(prob_all > 0.5),
                 precision_simu = precision_simu)

Plot observed vs simulated assignment rates (recall)

df %>%
  dplyr::mutate(sites_per_clone = cut(n_sites / pmax(n_clone - 1, 1), 
                                      breaks = c(0, 3, 8, 15, 25, 60))) %>%
  ggplot(
         aes(x = recall_simu, y = recall_real, 
             fill = sites_per_clone)) +
  geom_abline(slope = 1, intercept = 0, colour = "gray40", linetype = 2) +
  geom_smooth(aes(group = 1), method = "lm", colour = "firebrick") +
  geom_point(size = 3, shape = 21) +
  xlim(0, 1) + ylim(0, 1) +
  scale_fill_manual(name = "mean\n# variants\nper clonal\nbranch", 
                    values = magma(6)[-1]) +
  guides(colour = FALSE, group = FALSE) +
  xlab("Assignment rate: simulated") +
  ylab("Assignment rate: observed")

Expand here to see past versions of unnamed-chunk-4-1.png:
Version Author Date
02a8343 davismcc 2018-08-24

ggsave("figures/simulations/assign_rate_obs_v_sim.png", 
       height = 4.5, width = 5)
ggsave("figures/simulations/assign_rate_obs_v_sim.pdf", 
       height = 4.5, width = 5)

Plot simulation precision-recall curve

df %>%
  dplyr::mutate(sites_per_clone = cut(n_sites / n_clone, 
                                      breaks = c(0, 5, 10, 20, 40))) %>%
  ggplot(
         aes(x = recall_simu, y = precision_simu, 
             fill = sites_per_clone)) +
  geom_hline(yintercept = 0.85, colour = "gray40", linetype = 2) +
  geom_smooth(aes(group = 1), method = "lm", colour = "firebrick") +
  geom_point(size = 3, shape = 21) +
  xlim(0, 1) + ylim(0, 1) +
  scale_fill_manual(name = "mean\n# variants\nper clone", 
                    values = magma(5)[-1]) +
  guides(colour = FALSE, group = FALSE) +
  xlab("Assignment rate (recall)") +
  ylab("Precision")

Expand here to see past versions of unnamed-chunk-5-1.png:
Version Author Date
02a8343 davismcc 2018-08-24

ggsave("figures/simulations/sim_precision_v_recall.png", 
       height = 4.5, width = 5.5)
ggsave("figures/simulations/sim_precision_v_recall.pdf", 
       height = 4.5, width = 5.5)

Clone statistics

Table showing the number of lines with 2, 3 and 4 clones.

table(df$n_clone)

 2  3  4 
 4 24  4 

Summary of the average number of mutations per clonal branch across lines.

summary(df$n_sites / (df$n_clone - 1))
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
   3.00    8.50   11.50   18.69   25.00   57.50 

Session information

devtools::session_info()
Session info -------------------------------------------------------------
 setting  value                       
 version  R version 3.5.1 (2018-07-02)
 system   x86_64, darwin15.6.0        
 ui       X11                         
 language (EN)                        
 collate  en_GB.UTF-8                 
 tz       Europe/London               
 date     2018-08-25                  
Packages -----------------------------------------------------------------
 package              * version   date       source        
 AnnotationDbi          1.42.1    2018-05-08 Bioconductor  
 ape                    5.1       2018-04-04 CRAN (R 3.5.0)
 assertthat             0.2.0     2017-04-11 CRAN (R 3.5.0)
 backports              1.1.2     2017-12-13 CRAN (R 3.5.0)
 base                 * 3.5.1     2018-07-05 local         
 bindr                  0.1.1     2018-03-13 CRAN (R 3.5.0)
 bindrcpp             * 0.2.2     2018-03-29 CRAN (R 3.5.0)
 Biobase                2.40.0    2018-05-01 Bioconductor  
 BiocGenerics           0.26.0    2018-05-01 Bioconductor  
 BiocParallel           1.14.2    2018-07-08 Bioconductor  
 biomaRt                2.36.1    2018-05-24 Bioconductor  
 Biostrings             2.48.0    2018-05-01 Bioconductor  
 bit                    1.1-14    2018-05-29 CRAN (R 3.5.0)
 bit64                  0.9-7     2017-05-08 CRAN (R 3.5.0)
 bitops                 1.0-6     2013-08-17 CRAN (R 3.5.0)
 blob                   1.1.1     2018-03-25 CRAN (R 3.5.0)
 broom                  0.5.0     2018-07-17 CRAN (R 3.5.0)
 BSgenome               1.48.0    2018-05-01 Bioconductor  
 cardelino            * 0.1.2     2018-08-21 Bioconductor  
 cellranger             1.1.0     2016-07-27 CRAN (R 3.5.0)
 cli                    1.0.0     2017-11-05 CRAN (R 3.5.0)
 colorspace             1.3-2     2016-12-14 CRAN (R 3.5.0)
 compiler               3.5.1     2018-07-05 local         
 cowplot              * 0.9.3     2018-07-15 CRAN (R 3.5.0)
 crayon                 1.3.4     2017-09-16 CRAN (R 3.5.0)
 datasets             * 3.5.1     2018-07-05 local         
 DBI                    1.0.0     2018-05-02 CRAN (R 3.5.0)
 DelayedArray           0.6.5     2018-08-15 Bioconductor  
 devtools               1.13.6    2018-06-27 CRAN (R 3.5.0)
 digest                 0.6.16    2018-08-22 CRAN (R 3.5.0)
 dplyr                * 0.7.6     2018-06-29 CRAN (R 3.5.1)
 evaluate               0.11      2018-07-17 CRAN (R 3.5.0)
 forcats              * 0.3.0     2018-02-19 CRAN (R 3.5.0)
 GenomeInfoDb           1.16.0    2018-05-01 Bioconductor  
 GenomeInfoDbData       1.1.0     2018-04-25 Bioconductor  
 GenomicAlignments      1.16.0    2018-05-01 Bioconductor  
 GenomicFeatures        1.32.2    2018-08-13 Bioconductor  
 GenomicRanges          1.32.6    2018-07-20 Bioconductor  
 ggplot2              * 3.0.0     2018-07-03 CRAN (R 3.5.0)
 ggpubr               * 0.1.7     2018-06-23 CRAN (R 3.5.0)
 ggtree                 1.12.7    2018-08-07 Bioconductor  
 git2r                  0.23.0    2018-07-17 CRAN (R 3.5.0)
 glue                   1.3.0     2018-07-17 CRAN (R 3.5.0)
 graphics             * 3.5.1     2018-07-05 local         
 grDevices            * 3.5.1     2018-07-05 local         
 grid                   3.5.1     2018-07-05 local         
 gridExtra              2.3       2017-09-09 CRAN (R 3.5.0)
 gtable                 0.2.0     2016-02-26 CRAN (R 3.5.0)
 haven                  1.1.2     2018-06-27 CRAN (R 3.5.0)
 hms                    0.4.2     2018-03-10 CRAN (R 3.5.0)
 htmltools              0.3.6     2017-04-28 CRAN (R 3.5.0)
 httr                   1.3.1     2017-08-20 CRAN (R 3.5.0)
 IRanges                2.14.11   2018-08-24 Bioconductor  
 jsonlite               1.5       2017-06-01 CRAN (R 3.5.0)
 knitr                  1.20      2018-02-20 CRAN (R 3.5.0)
 labeling               0.3       2014-08-23 CRAN (R 3.5.0)
 lattice                0.20-35   2017-03-25 CRAN (R 3.5.1)
 lazyeval               0.2.1     2017-10-29 CRAN (R 3.5.0)
 lubridate              1.7.4     2018-04-11 CRAN (R 3.5.0)
 magrittr             * 1.5       2014-11-22 CRAN (R 3.5.0)
 Matrix                 1.2-14    2018-04-13 CRAN (R 3.5.1)
 matrixStats            0.54.0    2018-07-23 CRAN (R 3.5.0)
 memoise                1.1.0     2017-04-21 CRAN (R 3.5.0)
 methods              * 3.5.1     2018-07-05 local         
 modelr                 0.1.2     2018-05-11 CRAN (R 3.5.0)
 munsell                0.5.0     2018-06-12 CRAN (R 3.5.0)
 nlme                   3.1-137   2018-04-07 CRAN (R 3.5.1)
 parallel               3.5.1     2018-07-05 local         
 pheatmap               1.0.10    2018-05-19 CRAN (R 3.5.0)
 pillar                 1.3.0     2018-07-14 CRAN (R 3.5.0)
 pkgconfig              2.0.2     2018-08-16 CRAN (R 3.5.0)
 plyr                   1.8.4     2016-06-08 CRAN (R 3.5.0)
 prettyunits            1.0.2     2015-07-13 CRAN (R 3.5.0)
 progress               1.2.0     2018-06-14 CRAN (R 3.5.0)
 purrr                * 0.2.5     2018-05-29 CRAN (R 3.5.0)
 R.methodsS3            1.7.1     2016-02-16 CRAN (R 3.5.0)
 R.oo                   1.22.0    2018-04-22 CRAN (R 3.5.0)
 R.utils                2.6.0     2017-11-05 CRAN (R 3.5.0)
 R6                     2.2.2     2017-06-17 CRAN (R 3.5.0)
 RColorBrewer           1.1-2     2014-12-07 CRAN (R 3.5.0)
 Rcpp                   0.12.18   2018-07-23 CRAN (R 3.5.0)
 RCurl                  1.95-4.11 2018-07-15 CRAN (R 3.5.0)
 readr                * 1.1.1     2017-05-16 CRAN (R 3.5.0)
 readxl                 1.1.0     2018-04-20 CRAN (R 3.5.0)
 rlang                  0.2.2     2018-08-16 CRAN (R 3.5.0)
 rmarkdown              1.10      2018-06-11 CRAN (R 3.5.0)
 rprojroot              1.3-2     2018-01-03 CRAN (R 3.5.0)
 Rsamtools              1.32.3    2018-08-22 Bioconductor  
 RSQLite                2.1.1     2018-05-06 CRAN (R 3.5.0)
 rstudioapi             0.7       2017-09-07 CRAN (R 3.5.0)
 rtracklayer            1.40.5    2018-08-20 Bioconductor  
 rvcheck                0.1.0     2018-05-23 CRAN (R 3.5.0)
 rvest                  0.3.2     2016-06-17 CRAN (R 3.5.0)
 S4Vectors              0.18.3    2018-06-08 Bioconductor  
 scales                 1.0.0     2018-08-09 CRAN (R 3.5.0)
 snpStats               1.30.0    2018-05-01 Bioconductor  
 splines                3.5.1     2018-07-05 local         
 stats                * 3.5.1     2018-07-05 local         
 stats4                 3.5.1     2018-07-05 local         
 stringi                1.2.4     2018-07-20 CRAN (R 3.5.0)
 stringr              * 1.3.1     2018-05-10 CRAN (R 3.5.0)
 SummarizedExperiment   1.10.1    2018-05-11 Bioconductor  
 survival               2.42-6    2018-07-13 CRAN (R 3.5.0)
 tibble               * 1.4.2     2018-01-22 CRAN (R 3.5.0)
 tidyr                * 0.8.1     2018-05-18 CRAN (R 3.5.0)
 tidyselect             0.2.4     2018-02-26 CRAN (R 3.5.0)
 tidytree               0.1.9     2018-06-13 CRAN (R 3.5.0)
 tidyverse            * 1.2.1     2017-11-14 CRAN (R 3.5.0)
 tools                  3.5.1     2018-07-05 local         
 treeio                 1.4.3     2018-08-13 Bioconductor  
 utils                * 3.5.1     2018-07-05 local         
 VariantAnnotation      1.26.1    2018-07-04 Bioconductor  
 viridis              * 0.5.1     2018-03-29 CRAN (R 3.5.0)
 viridisLite          * 0.3.0     2018-02-01 CRAN (R 3.5.0)
 whisker                0.3-2     2013-04-28 CRAN (R 3.5.0)
 withr                  2.1.2     2018-03-15 CRAN (R 3.5.0)
 workflowr              1.1.1     2018-07-06 CRAN (R 3.5.0)
 XML                    3.98-1.16 2018-08-19 CRAN (R 3.5.1)
 xml2                   1.2.0     2018-01-24 CRAN (R 3.5.0)
 XVector                0.20.0    2018-05-01 Bioconductor  
 yaml                   2.2.0     2018-07-25 CRAN (R 3.5.1)
 zlibbioc               1.26.0    2018-05-01 Bioconductor  

This reproducible R Markdown analysis was created with workflowr 1.1.1