Last updated: 2021-12-16
Checks: 7 0
Knit directory: rare-mutation-detection-rmarkdown/
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.
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(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 7664b09. 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/
Untracked files:
Untracked: data/ecoli/
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/ecoli.Rmd
) and HTML (docs/ecoli.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 | 7664b09 | mcmero | 2021-12-16 | Updated to handle VCF output |
html | e5ed9a7 | Marek Cmero | 2021-12-15 | Build site. |
Rmd | ed42fa9 | Marek Cmero | 2021-12-15 | Added multiQC reports |
html | de277d9 | Marek Cmero | 2021-12-15 | Build site. |
Rmd | e610f97 | Marek Cmero | 2021-12-15 | Added ecoli analysis |
These are extra stats that are not available in the MultiQC reports. These reports can be found below:
library(ggplot2)
library(data.table)
library(dplyr)
library(R.utils)
library(UpSetR)
library(here)
load_data <- function(fdir, pattern, samples, read_func=read.delim) {
df <- list.files(
fdir,
full.names = TRUE,
recursive = TRUE,
pattern = pattern) %>%
lapply(., read_func)
for (i in seq(length(samples))) {
df[[i]]$Sample <- samples[i]
}
df <- rbindlist(df)
return(df)
}
extract_std <- function(genome_results) {
std <- genome_results[grep('std', genome_results$BamQC.report),] %>%
strsplit(., split='=') %>%
last() %>% last() %>%
gsub(' |X', '', .) %>% as.numeric()
return(std)
}
load_cov_stats <- function(cov, qualimap_dir, samples) {
cov_stats <- list.files(
qualimap_dir,
full.names = TRUE,
recursive = TRUE,
pattern = 'genome_results.txt') %>%
lapply(., read.delim) %>%
lapply(., extract_std) %>%
unlist()
cov_stats <- data.frame(cov_std=cov_stats, Sample=samples)
cov_stats <- data.table(cov)[,mean(Coverage), by=Sample] %>%
data.frame() %>% inner_join(., cov_stats, by='Sample')
colnames(cov_stats)[2] <- 'cov_mean'
return(cov_stats)
}
qualimap_dir <- here('data/ecoli/QC/qualimap/')
qualimap_cons_dir <- here('data/ecoli/QC/consensus/qualimap/')
variant_dir <- here('data/ecoli/variants')
family_size_stats <- here('data/ecoli/family_sizes.txt')
samples <- list.files(qualimap_dir)
cov <- load_data(qualimap_dir, 'coverage_across_reference.txt', samples)
ccov <- load_data(qualimap_cons_dir, 'coverage_across_reference.txt', samples)
clip <- load_data(qualimap_dir, 'mapped_reads_clipping_profile', samples)
cclip <- load_data(qualimap_cons_dir, 'mapped_reads_clipping_profile', samples)
vars <- load_data(variant_dir, '.vcf', samples, read.table)
cov_stats <- load_cov_stats(cov, qualimap_dir, samples)
ccov_stats <- load_cov_stats(ccov, qualimap_cons_dir, samples)
fam <- read.delim(family_size_stats, sep='\t')
Using coverage summary data from Qualimap (I assume these are summariesed to 10kb windows, though I coulnd’t find this in the documentation).
# order by median coverage
median_cov <- data.table(cov)[,median(Coverage), by=Sample]
cov$Sample <- factor(cov$Sample, levels=median_cov[order(median_cov$V1)]$Sample)
ggplot(cov, aes(Coverage, Sample)) + geom_boxplot() + theme_bw() + ggtitle('Pre-duplex coverage')
Version | Author | Date |
---|---|---|
de277d9 | Marek Cmero | 2021-12-15 |
median_cov <- data.table(ccov)[,median(Coverage), by=Sample]
ccov$Sample <- factor(ccov$Sample, levels=median_cov[order(median_cov$V1)]$Sample)
ggplot(ccov, aes(Coverage, Sample)) + geom_boxplot() + theme_bw() + ggtitle('Duplex coverage')
Version | Author | Date |
---|---|---|
de277d9 | Marek Cmero | 2021-12-15 |
ggplot(melt(cov_stats), aes(value, Sample, fill=variable)) +
geom_bar(stat='identity', position = 'dodge') +
theme_bw() +
ggtitle('Coverage std & mean (pre-duplex)')
Version | Author | Date |
---|---|---|
de277d9 | Marek Cmero | 2021-12-15 |
ggplot(melt(ccov_stats), aes(value, Sample, fill=variable)) +
geom_bar(stat='identity', position = 'dodge') +
theme_bw() +
ggtitle('Coverage std & mean (duplex)')
Version | Author | Date |
---|---|---|
de277d9 | Marek Cmero | 2021-12-15 |
cov_stats$cov_cv <- cov_stats$cov_std / cov_stats$cov_mean
ggplot(cov_stats, aes(cov_cv, Sample)) +
geom_bar(stat='identity', position = 'dodge') +
theme_bw() +
ggtitle('Coverage CV (pre-duplex)')
Version | Author | Date |
---|---|---|
de277d9 | Marek Cmero | 2021-12-15 |
ccov_stats$cov_cv <- ccov_stats$cov_std / ccov_stats$cov_mean
ggplot(ccov_stats, aes(cov_cv, Sample)) +
geom_bar(stat='identity', position = 'dodge') +
theme_bw() +
ggtitle('Coverage CV (duplex)')
Version | Author | Date |
---|---|---|
de277d9 | Marek Cmero | 2021-12-15 |
Pre-duplex reads prior to overlap clipping, but post-UMI removal.
ggplot(clip, aes(X.Read.position..bp., Clipping.profile)) +
geom_line() +
theme_bw() +
xlab('Read position') +
facet_wrap(~Sample) +
ggtitle('Pre-duplex clipping profile')
Version | Author | Date |
---|---|---|
de277d9 | Marek Cmero | 2021-12-15 |
Duplex reads have been clipped to remove read overlap.
ggplot(cclip, aes(X.Read.position..bp., Clipping.profile)) +
geom_line() +
theme_bw() +
xlab('Read position') +
facet_wrap(~Sample) +
ggtitle('Duplex clipping profile')
Version | Author | Date |
---|---|---|
de277d9 | Marek Cmero | 2021-12-15 |
ggplot(fam, aes(len, sample)) +
geom_bar(stat='identity') +
theme_bw() +
ggtitle('Total family count')
Version | Author | Date |
---|---|---|
de277d9 | Marek Cmero | 2021-12-15 |
mfam <- reshape2::melt(fam[,c('sample', 'min', 'max', 'mean', 'median')])
ggplot(mfam, aes(value, sample, colour=variable)) +
geom_point() +
theme_bw() +
coord_trans(x='log2') +
scale_x_continuous(breaks=seq(0, 25, 2)) +
theme(axis.text.x = element_text(size=6)) +
ggtitle('Family sizes')
Version | Author | Date |
---|---|---|
de277d9 | Marek Cmero | 2021-12-15 |
mfam <- reshape2::melt(fam[,colnames(fam) %like% 'frac|sample'])
ggplot(mfam, aes(value, sample, fill=variable)) +
geom_bar(stat='identity', position='dodge') +
theme_bw() +
ggtitle('Family reads + paired statistics')
Version | Author | Date |
---|---|---|
de277d9 | Marek Cmero | 2021-12-15 |
vars$Sample <- strsplit(vars$Sample, '\\.') %>% lapply(., head, 1) %>% unlist()
ulist <- NULL
for(sample in samples) {
ulist[[sample]] <- vars[vars$Sample %in% sample,]$V2
}
upset(fromList(ulist), order.by='freq', nsets=8)
Version | Author | Date |
---|---|---|
de277d9 | Marek Cmero | 2021-12-15 |
sessionInfo()
R version 4.1.2 (2021-11-01)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Big Sur 10.16
Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRblas.0.dylib
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] here_1.0.1 UpSetR_1.4.0 R.utils_2.11.0 R.oo_1.24.0
[5] R.methodsS3_1.8.1 dplyr_1.0.7 data.table_1.14.0 ggplot2_3.3.5
[9] workflowr_1.6.2
loaded via a namespace (and not attached):
[1] tidyselect_1.1.1 xfun_0.25 bslib_0.3.1 reshape2_1.4.4
[5] purrr_0.3.4 colorspace_2.0-2 vctrs_0.3.8 generics_0.1.0
[9] htmltools_0.5.2 yaml_2.2.1 utf8_1.2.2 rlang_0.4.11
[13] jquerylib_0.1.4 later_1.3.0 pillar_1.6.2 glue_1.4.2
[17] withr_2.4.2 DBI_1.1.1 lifecycle_1.0.0 plyr_1.8.6
[21] stringr_1.4.0 munsell_0.5.0 gtable_0.3.0 evaluate_0.14
[25] labeling_0.4.2 knitr_1.33 fastmap_1.1.0 httpuv_1.6.3
[29] fansi_0.5.0 highr_0.9 Rcpp_1.0.7 promises_1.2.0.1
[33] scales_1.1.1 jsonlite_1.7.2 farver_2.1.0 fs_1.5.0
[37] gridExtra_2.3 digest_0.6.27 stringi_1.7.4 grid_4.1.2
[41] rprojroot_2.0.2 tools_4.1.2 magrittr_2.0.1 sass_0.4.0
[45] tibble_3.1.4 crayon_1.4.1 whisker_0.4 pkgconfig_2.0.3
[49] ellipsis_0.3.2 assertthat_0.2.1 rmarkdown_2.11 R6_2.5.1
[53] git2r_0.28.0 compiler_4.1.2