Last updated: 2024-06-14
Checks: 6 1
Knit directory: NextClone-analysis/
This reproducible R Markdown analysis was created with workflowr (version 1.7.1). 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(20231011)
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 d3d9673. 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: data/.DS_Store
Ignored: data/cellranger_out/
Ignored: data/nextclone_out/.DS_Store
Untracked files:
Untracked: analysis/benchmarking_duration.Rmd
Untracked: data/benchmark_duration.csv
Unstaged changes:
Modified: analysis/DNAseq_data_analysis.Rmd
Modified: analysis/index.Rmd
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/DNAseq_data_analysis.Rmd
)
and HTML (docs/DNAseq_data_analysis.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 |
---|---|---|---|---|
html | 17e6e15 | Givanna Putri | 2023-11-17 | Build site. |
Rmd | 81b59b1 | Givanna Putri | 2023-11-17 | wflow_publish("analysis/*") |
html | 02dd0cb | Givanna Putri | 2023-11-15 | Build site. |
html | add7a8f | Givanna Putri | 2023-11-14 | Build site. |
Rmd | 872093b | Givanna Putri | 2023-11-14 | wflow_publish("analysis/*") |
html | 9fb414f | Givanna Putri | 2023-11-13 | Build site. |
Rmd | ca5457a | Givanna Putri | 2023-11-13 | update |
html | ca5457a | Givanna Putri | 2023-11-13 | update |
Rmd | 9a79d31 | Givanna Putri | 2023-11-13 | wflow_rename("analysis/NGS_data_analysis.Rmd", "analysis/DNAseq_data_analysis.Rmd") |
html | 9a79d31 | Givanna Putri | 2023-11-13 | wflow_rename("analysis/NGS_data_analysis.Rmd", "analysis/DNAseq_data_analysis.Rmd") |
Analysis for the DNA-seq 8k and 10k library of MCF7 cell line tagged with ClonMapper protocol.
library(CloneDetective)
library(data.table)
library(ggplot2)
library(scales)
NextClone and pycashier output.
The command used to generate NextClone output is available in
code
folder.
Pycashier is available on Github. The output used in this analysis was generated using the following configuration file:
[extract]
input = "./fastqs_trimmed"
skip_trimming = true
threads = 8
filter_count = 1
output = "outs"
pipeline = "pipeline"
error = 0.1
length = 20
upstream_adapter = "ATCTTGTGGAAAGGACGAAACACCG"
downstream_adapter = "GTTTTAGAGCTAGAAATAGCAAGTT"
quality = 30
unqualified_percent = 20
ratio = 3
distance = 1
# filter_percent = 0.005
offset = 1
# fastp_args =
clones_nxclone <- fread("data/nextclone_out/dnaseq_clone_barcode_counts_20231114.csv")
# The samples in the sample_name column is way too complicated.
# Let's create a new column.
clones_nxclone[, sample_name_simple := gsub("vexGFP-", "", gsub("_.*", "", sample_name))]
clones_nxclone[, sample_name_simple := factor(sample_name_simple, levels = c("8k", "10k"))]
clones_pycashier <- lapply(c("8k", "10k"), function(samp) {
# read_count as the count column so we can use count_retained_clones
dt <- fread(
file = paste0("data/pycashier_out/", samp, ".tsv"),
header = FALSE,
col.names = c("clone_barcode", "read_count")
)
dt[, sample := samp]
return(dt)
})
clones_pycashier <- rbindlist(clones_pycashier)
clones_pycashier[, sample := factor(sample, levels = c("8k", "10k"))]
Count the number of unique barcodes with at least x number of cells.
thresholds <- c(1, 20, 200, 1000)
n_barcodes_nxclone <- count_retained_clones(
count_data = clones_nxclone,
thresholds = thresholds,
grouping_col = "sample_name_simple",
count_column = "read_count"
)
n_barcodes_nxclone[, tool := 'NextClone']
setnames(n_barcodes_nxclone, "sample_name_simple", "sample")
n_barcodes_pycashier <- count_retained_clones(
count_data = clones_pycashier,
thresholds = thresholds,
grouping_col = "sample",
count_column = "read_count"
)
n_barcodes_pycashier[, tool := 'PyCashier']
n_barcodes <- rbind(n_barcodes_nxclone, n_barcodes_pycashier)
The reviewer believes 8k and 10k are not good name for datasets. Rename them to dataset A and B.
new_dataset_name <- data.table(
sample = c("8k", "10k"),
new_sample_name = c("DNA-seq (dataset A)", "DNA-seq (dataset B)")
)
Plot bar chart that compares the number of unique barcodes retrieved by both workflows.
n_barcodes_long <- melt(n_barcodes, id.vars = c("sample", "tool"),
variable.name = "filtering_threshold",
value.name = "n_barcode")
filtering_threshold_levels <- paste(">=", thresholds, "cells")
n_barcodes_long[, filtering_threshold := factor(
gsub("_"," ",gsub("at_least_", ">= ", filtering_threshold)),
levels = filtering_threshold_levels
)]
n_barcodes_long <- merge.data.table(n_barcodes_long, new_dataset_name, sort = FALSE)
ggplot(n_barcodes_long, aes(x=factor(filtering_threshold), y=n_barcode, fill=tool)) +
geom_bar(stat="identity", position=position_dodge()) +
theme_bw() +
theme(
axis.text.x = element_text(angle = 45, vjust = 1, hjust=1),
legend.position="bottom"
) +
facet_wrap(~ new_sample_name) +
scale_y_continuous(breaks = pretty_breaks(n=10), label = label_comma(accuracy = 1)) +
labs(
y = "No. of barcodes",
x = "Filtering thresholds",
fill = "Pipeline",
title = "No. of barcodes retrieved for DNA-seq data"
)
To show the proportion of barcode’s frequency.
clones_nxclone_filtered <- remove_clones_below_threshold(
count_data = clones_nxclone,
threshold = 20,
count_column = "read_count"
)
clones_nxclone_filtered <- convert_count_to_proportion(
count_data = clones_nxclone_filtered,
grouping_col = "sample_name_simple",
count_column = "read_count"
)
clones_nxclone_filtered <- merge.data.table(
clones_nxclone_filtered,
new_dataset_name,
by.x = "sample_name_simple",
by.y = "sample",
sort = FALSE
)
plt <- draw_ordered_abundance_plot(
count_data = clones_nxclone_filtered,
facet_column = "new_sample_name",
y_axis_column = "read_proportion"
)
plt <- plt +
geom_point(size=0.5, colour='red') +
labs(
title = "Proportion of cells assigned to each barcode",
subtitle = "Barcode IDs are numerically assigned in order of read proportion",
x = "Numerical barcode ID",
y = "Proportion of cells per sample"
)
plt
Let’s say we want to sequence 10,000 cells. Based on our NGS data, can we predict what will happen to our clone barcodes? Will we get enough representations?
Do projection by calculating proportion and multiply by amount of cells to be projected to.
How many cells we will get per clone?
clones_nxclone_proportion <- project_clones(
count_data = clones_nxclone,
grouping_col = "sample_name_simple",
count_column = "read_count",
project_amnt = c(10000, 20000)
)
clones_nxclone_proportion <- merge.data.table(
clones_nxclone_proportion,
new_dataset_name,
by.x = "sample_name_simple",
by.y = "sample",
sort = FALSE
)
plt <- draw_ordered_abundance_plot(
count_data = clones_nxclone_proportion,
y_axis_column = 'projected_20000_confidence_1',
facet_column = 'new_sample_name'
) +
geom_point(size = 0.5, colour='forestgreen') +
labs(
y = 'Number of cells',
title = 'Number of cells assigned to each barcode',
subtitle = 'Cell counts computed after projection to 20,000 cells'
)
plt
plt <- draw_ordered_abundance_plot(
count_data = clones_nxclone_proportion,
y_axis_column = 'projected_10000_confidence_1',
facet_column = 'new_sample_name'
) +
geom_point(size = 0.5, colour='blue') +
labs(
y = 'Number of cells',
title = 'Number of cells assigned to each barcode',
subtitle = 'Cell counts computed after projection to 10,000 cells'
)
plt
How many clones that contain at least 10, 20, 50, 100 cells?
thresholds <- seq(10, 30, 5)
proj_n_clones_retained <- count_retained_clones(
count_data = clones_nxclone_proportion,
thresholds = thresholds,
grouping_col = "new_sample_name",
count_column = "projected_10000_confidence_1"
)
names(proj_n_clones_retained) <- c("sample", paste(">=", thresholds, "cells"))
proj_n_clones_retained_long <- melt(proj_n_clones_retained, id.vars = c("sample"),
variable.name = "filtering_threshold",
value.name = "n_barcode")
ggplot(proj_n_clones_retained_long, aes(x=factor(filtering_threshold), y=n_barcode)) +
geom_bar(stat="identity", position=position_dodge(), fill="darkorange") +
theme_bw() +
theme(
axis.text.x = element_text(angle = 45, vjust = 1, hjust=1),
legend.position="bottom"
) +
facet_wrap(~ sample) +
scale_y_continuous(breaks = pretty_breaks(n=6),label = label_comma(accuracy = 1)) +
labs(
y = "No. of barcodes",
x = "Filtering thresholds",
fill = "Pipeline",
title = "No. of barcodes estimated for DNA-seq data",
subtitle = "When capturing 10,000 cells"
)
What are the frequency of top 200 clone barcodes? We can present this by computing the number of cells tagged by top 200 clone barcodes.
top_threshold <- 200
top_barcodes <- get_top_barcodes_and_cum_sum(
count_data = clones_nxclone_proportion,
count_column = "projected_10000_confidence_1",
grouping_col = "new_sample_name",
top_threshold = top_threshold
)
Create a line chart that show cumulative number of cells.
ggplot(top_barcodes, aes(x=barcode_rank, y=cum_sum_projected_10000_confidence_1,
group=new_sample_name, colour = new_sample_name)) +
geom_line(linewidth=1) +
theme_bw(base_size = 16) +
scale_y_continuous(breaks = pretty_breaks(n=10), labels = label_comma(accuracy = 1)) +
scale_x_continuous(breaks = pretty_breaks(n=10)) +
theme(
axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1),
legend.position = "bottom"
) +
labs(
y = "Number of cells",
x = "Barcode Ranking",
title = paste("Projected no. of cells for top", top_threshold, "most abundant clones"),
subtitle = "When capturing 10,000 cells",
colour = "Dataset"
)
sessionInfo()
R version 4.4.0 (2024-04-24)
Platform: x86_64-apple-darwin20
Running under: macOS Sonoma 14.0
Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/4.4-x86_64/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.4-x86_64/Resources/lib/libRlapack.dylib; LAPACK version 3.12.0
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
time zone: Australia/Melbourne
tzcode source: internal
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] scales_1.3.0 ggplot2_3.5.1 data.table_1.15.4
[4] CloneDetective_0.1.0 workflowr_1.7.1
loaded via a namespace (and not attached):
[1] tidyselect_1.2.1 viridisLite_0.4.2
[3] farver_2.1.2 vipor_0.4.7
[5] dplyr_1.1.4 viridis_0.6.5
[7] fastmap_1.2.0 SingleCellExperiment_1.26.0
[9] promises_1.3.0 digest_0.6.35
[11] rsvd_1.0.5 lifecycle_1.0.4
[13] processx_3.8.4 magrittr_2.0.3
[15] compiler_4.4.0 rlang_1.1.3
[17] sass_0.4.9 tools_4.4.0
[19] utf8_1.2.4 yaml_2.3.8
[21] knitr_1.46 S4Arrays_1.4.1
[23] DelayedArray_0.30.1 abind_1.4-5
[25] BiocParallel_1.38.0 withr_3.0.0
[27] purrr_1.0.2 BiocGenerics_0.50.0
[29] grid_4.4.0 stats4_4.4.0
[31] fansi_1.0.6 git2r_0.33.0
[33] beachmat_2.20.0 colorspace_2.1-0
[35] SummarizedExperiment_1.34.0 cli_3.6.2
[37] rmarkdown_2.27 crayon_1.5.2
[39] generics_0.1.3 rstudioapi_0.16.0
[41] httr_1.4.7 DelayedMatrixStats_1.26.0
[43] scuttle_1.14.0 ggbeeswarm_0.7.2
[45] cachem_1.1.0 stringr_1.5.1
[47] zlibbioc_1.50.0 parallel_4.4.0
[49] XVector_0.44.0 matrixStats_1.3.0
[51] vctrs_0.6.5 Matrix_1.7-0
[53] jsonlite_1.8.8 BiocSingular_1.20.0
[55] callr_3.7.6 IRanges_2.38.0
[57] S4Vectors_0.42.0 BiocNeighbors_1.22.0
[59] ggrepel_0.9.5 irlba_2.3.5.1
[61] beeswarm_0.4.0 scater_1.32.0
[63] jquerylib_0.1.4 glue_1.7.0
[65] codetools_0.2-20 ps_1.7.6
[67] stringi_1.8.4 gtable_0.3.5
[69] later_1.3.2 GenomeInfoDb_1.40.0
[71] GenomicRanges_1.56.0 UCSC.utils_1.0.0
[73] ScaledMatrix_1.12.0 munsell_0.5.1
[75] tibble_3.2.1 pillar_1.9.0
[77] htmltools_0.5.8.1 ggfittext_0.10.2
[79] treemapify_2.5.6 GenomeInfoDbData_1.2.12
[81] R6_2.5.1 sparseMatrixStats_1.16.0
[83] rprojroot_2.0.4 evaluate_0.23
[85] Biobase_2.64.0 lattice_0.22-6
[87] highr_0.10 httpuv_1.6.15
[89] bslib_0.7.0 Rcpp_1.0.12
[91] gridExtra_2.3 SparseArray_1.4.3
[93] whisker_0.4.1 xfun_0.44
[95] fs_1.6.4 MatrixGenerics_1.16.0
[97] getPass_0.2-4 pkgconfig_2.0.3