knitr::opts_chunk$set( collapse = TRUE, comment = "#>", crop = NULL ## Related to https://stat.ethz.ch/pipermail/bioc-devel/2020-April/016656.html )
## Track time spent on making the vignette startTime <- Sys.time() ## Bib setup library("RefManageR") ## Write bibliography information bib <- c( R = citation(), BiocStyle = citation("BiocStyle")[1], knitr = citation("knitr")[1], RefManageR = citation("RefManageR")[1], rmarkdown = citation("rmarkdown")[1], sessioninfo = citation("sessioninfo")[1], testthat = citation("testthat")[1], DeconvoBuddies = citation("DeconvoBuddies")[1] )
DeconvoBuddies
R
is an open-source statistical environment which can be easily modified to enhance its functionality via packages. r Biocpkg("DeconvoBuddies")
is a R
package available via the Bioconductor repository for packages. R
can be installed on any operating system from CRAN after which you can install r Biocpkg("DeconvoBuddies")
by using the following commands in your R
session:
if (!requireNamespace("BiocManager", quietly = TRUE)) { install.packages("BiocManager") } BiocManager::install("DeconvoBuddies") ## Check that you have a valid Bioconductor installation BiocManager::valid()
r Biocpkg("DeconvoBuddies")
is based on many other packages and in particular in those that have implemented the infrastructure needed for dealing with snRNA-seq data. That is, packages like r Biocpkg("SingleCellExperiment")
.
If you are asking yourself the question "Where do I start using Bioconductor?" you might be interested in this blog post.
As package developers, we try to explain clearly how to use our packages and in which order to use the functions. But R
and Bioconductor
have a steep learning curve so it is critical to learn where to ask for help. The blog post quoted above mentions some but we would like to highlight the Bioconductor support site as the main resource for getting help: remember to use the DeconvoBuddies
tag and check the older posts. Other alternatives are available such as creating GitHub issues and tweeting. However, please note that if you want to receive help you should adhere to the posting guidelines. It is particularly critical that you provide a small reproducible example and your session information so package developers can track down the source of the error.
DeconvoBuddies
We hope that r Biocpkg("DeconvoBuddies")
will be useful for your research. Please use the following information to cite the package and the overall approach. Thank you!
## Citation info citation("DeconvoBuddies")
DeconvoBuddies
library("DeconvoBuddies") library("SummarizedExperiment") library("dplyr") library("tidyr") library("tibble") # library("ggplot2")
Accurate deconvolution requires highly specific marker genes for each cell type
to be defined. To select genes specific for each cell type, you can evaluate the
mean ratio
for each gene x each cell type, where mean ratio = mean(Expression
of target cell type)/mean(Expression of highest non-target cell type)
. These
values can be calculated for a single cell RNA-seq dataset using get_mean_ratio2()
.
my_mean_ratios <- get_mean_ratio2(sce.test, cellType_col = "cellType") my_mean_ratios
As you work with single-cell data and deconovoltion outputs, it is very useful
to establish a consistent color pallet to use across different plots. The
function create_cell_colors()
returns a named vector of hex values,
corresponding to the names of cell types. This list is compatible with functions
like ggplot2::scale_color_manual()
.
There are three pallets to choose from to generate colors:
* "classic" (default): Set1 from RColorBrewer
- max 9 colors
* "gg": Equi-distant hues, same process for selecting colors as ggplot
- no maximum number
* "tableau": tableau20 color set (TODO cite this) - max 20 colors
test_cell_types <- c("cell_A", "cell_B", "cell_C", "cell_D", "cell_E") test_cell_colors_classic <- create_cell_colors(cell_types = test_cell_types, pallet = "classic", preview = TRUE) test_cell_colors_gg <- create_cell_colors(cell_types = test_cell_types, pallet = "gg", preview = TRUE) test_cell_colors_tableau <- create_cell_colors(cell_types = test_cell_types, pallet = "tableau", preview = TRUE) test_cell_colors_tableau
If there are sub-cell types with consistent delimiters, the split
argument
creates a scale of related colors. This helps expand on the maximum number of
colors and makes your pallet flexible when considering different 'resolutions' of
cell types.
my_cell_types <- levels(sce.test$cellType) my_cell_colors <- create_cell_colors(cell_types = my_cell_types, pallet = "classic", preview = TRUE, split = "\\.")
The function plot_marker_express()
helps quickly visualize expression of top
marker genes, by ordering and annotating violin plots of expression over cell type.
plot_marker_express( sce = sce.test, stats = my_mean_ratios, cell_type = "Astro", n_genes = 5, rank_col = "rank_ratio", anno_col = "anno_ratio", color_pal = my_cell_colors )
Visualize deconvolution results with a stacked barplot showing the average cell type proportion for a group.
pd <- colData(rse_bulk_test) |> as.data.frame() ## need to pivot data to long format est_prop_long <- est_prop |> rownames_to_column("RNum") |> pivot_longer(!RNum, names_to = "cell_type", values_to = "prop") |> left_join(pd |> dplyr::select(RNum, Dx)) est_prop_long plot_composition_bar(est_prop_long, x_col = "Dx") + ggplot2::scale_fill_manual(values = test_cell_colors_classic)
The r Biocpkg("DeconvoBuddies")
package r Citep(bib[["DeconvoBuddies"]])
was made possible thanks to:
r Citep(bib[["R"]])
r Biocpkg("BiocStyle")
r Citep(bib[["BiocStyle"]])
r CRANpkg("knitr")
r Citep(bib[["knitr"]])
r CRANpkg("RefManageR")
r Citep(bib[["RefManageR"]])
r CRANpkg("rmarkdown")
r Citep(bib[["rmarkdown"]])
r CRANpkg("sessioninfo")
r Citep(bib[["sessioninfo"]])
r CRANpkg("testthat")
r Citep(bib[["testthat"]])
This package was developed using r BiocStyle::Biocpkg("biocthis")
.
Code for creating the vignette
## Create the vignette library("rmarkdown") system.time(render("DeconvoBuddies.Rmd", "BiocStyle::html_document")) ## Extract the R code library("knitr") knit("DeconvoBuddies.Rmd", tangle = TRUE)
Date the vignette was generated.
## Date the vignette was generated Sys.time()
Wallclock time spent generating the vignette.
## Processing time in seconds totalTime <- diff(c(startTime, Sys.time())) round(totalTime, digits = 3)
R
session information.
## Session info library("sessioninfo") options(width = 120) session_info()
This vignette was generated using r Biocpkg("BiocStyle")
r Citep(bib[["BiocStyle"]])
with r CRANpkg("knitr")
r Citep(bib[["knitr"]])
and r CRANpkg("rmarkdown")
r Citep(bib[["rmarkdown"]])
running behind the scenes.
Citations made with r CRANpkg("RefManageR")
r Citep(bib[["RefManageR"]])
.
## Print bibliography PrintBibliography(bib, .opts = list(hyperlink = "to.doc", style = "html"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.