Last updated: 2021-09-17
Checks: 6 1
Knit directory: nanoseq-rare-mutation-detection/
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(20210916)
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 c9324ad. 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: .Rproj.user/
Untracked files:
Untracked: analysis/model.Rmd
Untracked: rare-mutation-detection.Rproj
Unstaged changes:
Modified: analysis/_site.yml
Deleted: analysis/about.Rmd
Modified: analysis/index.Rmd
Deleted: nanoseq-rare-mutation-detection.Rproj
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.
library(ggplot2)
Q: what is the lowest % VAF of mutation we can reliably detect (at >95% confidence) using Nanoseq on bulk WES?
Let \(f\) be the probability of sequencing a mutation from a single fragment, on both strands.
\(f = (v / p) d.l\)
Where:
We assume the probability of selecting a mutant cell is binomially distributed. We want to know the probability of selecting at least one mutant cell:
\(P(Bin(f, m)) > 0)\) = 0.95
This is equivalent to:
\(P(Bin(f, m)) = 0)\) = 0.05
Where \(m\) is the number of mutant cells cells (\(15000 (v . 2)\)).
For a range of possible VAFs, \(V = \{0.001, 0.002 .. 0.05\}\), we can plot the probability of missing the mutant cell.
d = 0.81
l = 0.2
v = seq(0.001, 0.05, 0.001)
f = (v / 2) * d * l
n = 15000
m = n * (v * 2)
vafs <- data.frame(vaf=v,
p=dbinom(0, m, v))
ggplot(vafs, aes(vaf, p)) +
geom_point() +
theme_bw() +
geom_hline(yintercept=0.05, alpha=0.4)
For this range of VAFs, 0.01 (1%) is the smallest VAF for which the probability of missing the mutant is approximately 0.05.
deviation <- abs(0.05 - vafs$p)
print(vafs[which(deviation == min(deviation)),])
vaf p
10 0.01 0.04904089
sessionInfo()
R version 4.1.1 (2021-08-10)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Big Sur 10.16
Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRlapack.dylib
locale:
[1] en_AU.UTF-8/en_AU.UTF-8/en_AU.UTF-8/C/en_AU.UTF-8/en_AU.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] ggplot2_3.3.5 workflowr_1.6.2
loaded via a namespace (and not attached):
[1] Rcpp_1.0.7 highr_0.9 pillar_1.6.2 compiler_4.1.1
[5] later_1.3.0 jquerylib_0.1.4 git2r_0.28.0 tools_4.1.1
[9] digest_0.6.27 evaluate_0.14 lifecycle_1.0.0 tibble_3.1.4
[13] gtable_0.3.0 pkgconfig_2.0.3 rlang_0.4.11 yaml_2.2.1
[17] xfun_0.25 fastmap_1.1.0 withr_2.4.2 stringr_1.4.0
[21] dplyr_1.0.7 knitr_1.33 generics_0.1.0 fs_1.5.0
[25] vctrs_0.3.8 tidyselect_1.1.1 rprojroot_2.0.2 grid_4.1.1
[29] glue_1.4.2 R6_2.5.1 fansi_0.5.0 rmarkdown_2.11
[33] farver_2.1.0 purrr_0.3.4 magrittr_2.0.1 scales_1.1.1
[37] promises_1.2.0.1 ellipsis_0.3.2 htmltools_0.5.2 colorspace_2.0-2
[41] httpuv_1.6.3 labeling_0.4.2 utf8_1.2.2 stringi_1.7.4
[45] munsell_0.5.0 crayon_1.4.1