basicBulk provides tidyverse functions, tables, and plots for end-to-end analyses of (pseudo)bulk RNA-seq data within the Bioconductor ecosystem, with a focus on comparing contrasts to each other. Starting from a SummarizedExperiment of counts, it covers normalization and quality control, differential expression, and gene set enrichment. Alongside per-contrast volcano, MA, and heatmap plots, it summarizes the overlap of differentially expressed genes across contrasts (UpSet plots), compares pairs of contrasts gene by gene (4-way plots), correlates their logFC profiles, and compares top pathways. basicBulk also includes a Claude Code skill that enables agentic end-to-end analyses.
if (!requireNamespace("BiocManager", quietly = TRUE)) {
install.packages("BiocManager")
}
BiocManager::install("basicBulk")To install the development version directly from GitHub:
We use the example RNA-seq dataset from the airway package (Himes et al. 2014), which contains four airway
smooth muscle cell lines with or without dexamethasone (dex) treatment.
The functions in this package operate on a SummarizedExperiment (Morgan et al. 2026) with a counts
assay, so we simply add an ID column to the
rowData.
library(basicBulk)
se0 <- augere.de::loadExampleDataset()
SummarizedExperiment::rowData(se0)$ID <- rownames(se0)Raw RNA-seq counts are normalized to create additional assays for
downstream analyses and visualization outside of differential expression
testing and pathway analysis. basicBulk::tidySE() filters
out lowly expressed genes with edgeR::filterByExpr() (Chen, Lun, and Smyth 2016), calculates TMM
normalization factors with edgeR (Robinson and
Oshlack 2010; Chen et al. 2025), and then adds the voom with
quality weights (Law et al. 2014; Liu et al.
2015) expression values as a logCPM assay, where the
filtered genes are NA (they are flagged in the
retained rowData column). When a batch effect
is present, adjustBatch = TRUE adds a ComBat
assay of voom values from counts adjusted with ComBat-seq (Zhang, Parmigiani, and Johnson 2020). The batch
variable must be a colData column named Batch.
Either assay can be selected in the downstream functions with the
assay argument.
A wrapper for functions from the PCAtools package (Blighe, Andrews, and Lun 2026) was utilized for
PCA based on the expression of the genes retained by
filterByExpr, aside from the 10% with the lowest variance.
The loadings represent the most positively (red) and negatively (blue)
correlated genes with each PC.
se %>%
basicBulk::PCAgrid(colby = "dex",
shape = "cell",
shapekey = c(16, 17, 15, 18),
selectLab = NA,
alpha = 0.8)The histograms show the mean expression within a group for the genes
retained by filterByExpr. An optional argument,
geneSymbol will add a red line for the mean expression of a
gene of interest within a group.
The expression values can also be plotted for any genes of interest.
The expression values for any features can also be extracted into a tidy tibble for custom plots or joins with external data.
se %>%
basicBulk::joinFeatures(c("RARRES1", "TMEM176B", "GBP3"),
symbol = TRUE)
## # A tibble: 24 × 15
## symbol ID Sample logCPM SampleName cell dex albut Run avgLength
## <chr> <chr> <chr> <dbl> <fct> <fct> <fct> <fct> <fct> <int>
## 1 RARRES1 ENSG0000… SRR10… 7.06 GSM1275862 N613… untrt untrt SRR1… 126
## 2 RARRES1 ENSG0000… SRR10… 7.02 GSM1275863 N613… trt untrt SRR1… 126
## 3 RARRES1 ENSG0000… SRR10… 7.74 GSM1275866 N052… untrt untrt SRR1… 126
## 4 RARRES1 ENSG0000… SRR10… 8.20 GSM1275867 N052… trt untrt SRR1… 87
## 5 RARRES1 ENSG0000… SRR10… 4.03 GSM1275870 N080… untrt untrt SRR1… 120
## 6 RARRES1 ENSG0000… SRR10… 3.67 GSM1275871 N080… trt untrt SRR1… 126
## 7 RARRES1 ENSG0000… SRR10… 6.67 GSM1275874 N061… untrt untrt SRR1… 101
## 8 RARRES1 ENSG0000… SRR10… 6.69 GSM1275875 N061… trt untrt SRR1… 98
## 9 TMEM176B ENSG0000… SRR10… 6.55 GSM1275862 N613… untrt untrt SRR1… 126
## 10 TMEM176B ENSG0000… SRR10… 6.86 GSM1275863 N613… trt untrt SRR1… 126
## # ℹ 14 more rows
## # ℹ 5 more variables: Experiment <fct>, BioSample <fct>, Group <fct>,
## # lib.size <dbl>, norm.factors <dbl>First, differential gene expression testing is performed using voom-limma (Law et al. 2014; Ritchie et al. 2015) through augere.de (Lun 2026a). Here we test between three pairs of cell lines, extending the multiple-comparisons example from the augere.de vignette.
comparisonList <- list(c("N061011", "N052611"),
c("N080611", "N052611"),
c("N61311", "N052611"))
voomList <- se %>%
augere.de::runVoom(groups = "cell",
block = "dex",
comparisons = comparisonList,
assay = "counts",
output.dir = tempfile(),
save.results = FALSE) %>%
magrittr::extract2("results")Then, for use with downstream functions, the results are tidied into
a named list of tibbles known as the DGEdata.
This sigTibble is a single tibble with all genes passing the FDR < 0.05 and absolute LogFC > 1 threshold and is also used in some of the downstream functions.
This plot provides an overview of the number and direction of DEGs (FDR < 0.05 and |LogFC| > 1) for each contrast.
Heatmaps are made using a wrapper for ComplexHeatmap (Gu, Eils, and Schlesner 2016).
You can also customize the column annotations through the
top_annotation argument.
col <- list("cell" = ggsci::pal_d3()(n = length(levels(se$Group))) %>%
purrr::set_names(se$Group %>% levels()),
"dex" = c("#8624F5", "#1FC3AA") %>%
purrr::set_names(unique(se$dex)))
top_annotation <- ComplexHeatmap::HeatmapAnnotation("cell" = se$Group,
"dex" = se$dex,
col = col,
annotation_legend_param = list(
labels_gp = grid::gpar(fontsize = 9)),
border = TRUE)
se %>%
basicBulk::basicHeatmap(sigTibble = sigTibble,
top_annotation = top_annotation)Heatmaps of genes of interest can be plotted with the
geneSet argument, which is exemplified here for the top
highly variable genes (HVGs) that can be used for further QC.
HVGs <- se %>%
basicBulk::getHVGs(n = 20)
se %>%
basicBulk::basicHeatmap(geneSet = HVGs,
show_row_names = TRUE)It is also possible to extract a tidy version of the matrix with annotations from the rowData and colData.
se %>%
basicBulk::extractHeatmap(heatmap)
## # A tibble: 1,418 × 10
## ID symbol `N61311 SRR1039508` `N61311 SRR1039509` `N052611 SRR1039512`
## <chr> <chr> <dbl> <dbl> <dbl>
## 1 ENSG0000… THSD4 0.701 -1.35 1.66
## 2 ENSG0000… CEACA… 0.0107 -0.901 1.45
## 3 ENSG0000… LEPRE… -0.349 -1.43 1.47
## 4 ENSG0000… PGA3 -0.496 -1.33 1.53
## 5 ENSG0000… PGA4 -0.517 -1.01 1.49
## 6 ENSG0000… MEST 0.436 -1.02 1.60
## 7 ENSG0000… PGA5 0.173 -0.706 1.52
## 8 ENSG0000… RIMS4 -0.532 -0.541 1.78
## 9 ENSG0000… TNFRS… 0.185 -1.62 1.17
## 10 ENSG0000… AC011… -0.181 -1.86 1.02
## # ℹ 1,408 more rows
## # ℹ 5 more variables: `N052611 SRR1039513` <dbl>, `N080611 SRR1039516` <dbl>,
## # `N080611 SRR1039517` <dbl>, `N061011 SRR1039520` <dbl>,
## # `N061011 SRR1039521` <dbl>The overlaps between significant genes are visualized below in an UpSet plot, an alternative to a Venn diagram (Lex et al. 2014), using a wrapper for ComplexUpset (Krassowski 2020). The bar plot on the left shows the set size (total number of DEGs) for a given contrast. The bar plot on the top shows the intersection size (number of DEGs) for different combinations of contrasts, which are indicated by the dots below.
DGEdata %>%
purrr::set_names(names(.) %>% stringr::str_remove(" vs .*")) %>%
basicBulk::basicUpset(width_ratio = 0.2, height_ratio = 0.5)It is also possible to extract any overlaps of interest shown in the UpSet plot.
DGEdata %>%
names() %>%
paste("Up") %>%
basicBulk::extractUpSet(DGEdata)
## [1] "ENSG00000006283" "ENSG00000099984" "ENSG00000100058" "ENSG00000100181"
## [5] "ENSG00000114480" "ENSG00000129646" "ENSG00000133433" "ENSG00000135750"
## [9] "ENSG00000153132" "ENSG00000154358" "ENSG00000160539" "ENSG00000164308"
## [13] "ENSG00000166342" "ENSG00000172061" "ENSG00000173376" "ENSG00000176597"
## [17] "ENSG00000180537" "ENSG00000196557" "ENSG00000197915" "ENSG00000205662"
## [21] "ENSG00000215781" "ENSG00000228914" "ENSG00000230734" "ENSG00000261105"
## [25] "ENSG00000270346"The per-gene logFC profiles can be correlated across all contrasts to
summarize their agreement. basicBulk::prepareCor() runs
gg4way::getCor() over every pair of contrasts and
basicBulk::corTriplot() renders the pairwise correlations
as a triangle.
First, we prepare a corTibble that specifies the pairs
of contrasts to compare.
corTibble <- tidyr::crossing(x = names(DGEdata),
y = names(DGEdata)) %>%
dplyr::filter(x != y) %>%
dplyr::mutate(name = glue::glue("{stringr::str_remove(x, ' vs .*')} vs \\
{stringr::str_remove(y, ' vs .*')}"))Then we generate the logFC correlation triangle plot.
corTibble %>%
basicBulk::prepareCor(DGEdata, cd = SummarizedExperiment::colData(se)) %>%
basicBulk::corTriplot() +
# Manual scaling is for the purpose of this vignette
ggplot2::scale_alpha(range = c(1, 1), guide = "none") +
ggplot2::scale_size(range = c(7, 7), guide = "none")The correlations can also be shown as a table, with one row per pair of contrasts.
The corTibble can also be used to make 4-way plots (Laufer and Friedman 2026) for all pairs of
contrasts in a functional way.
corTibble %>%
dplyr::filter(x < y) %>%
purrr::pmap(~ with(list(...),
gg4way::gg4way(DGEdata,
x = x,
y = y,
logFC = "LogFC",
FDR = "FDR"))) %>%
cowplot::plot_grid(plotlist = ., ncol = 2)You can also plot DEGs of interest with a bracket and asterisk for
each contrast where they passed the threshold (default is FDR < 0.05
and |LogFC| > 1). Setting a ref.group instead marks only
the comparisons with that group, with an asterisk above each of the
other groups.
genes <- DGEdata %>%
magrittr::extract2(1) %>%
dplyr::arrange(FDR) %>%
dplyr::slice(1:5) %>%
dplyr::pull(symbol)
se %>%
basicBulk::genePlot(genes = genes,
DGEdata = DGEdata,
ncol = 5)A competitive gene set test can be performed using CAMERA (Wu and Smyth 2012) through augere.gsea (Lun 2026b). The REACTOME pathways gene set
(Ragueneau et al. 2025) can be obtained
from MSigDB (Subramanian et al. 2005; Liberzon et
al. 2015) with basicBulk::getReactome().
gene.sets <- basicBulk::getReactome("Homo sapiens")
set.seed(100)
GSEAlist <- comparisonList %>%
purrr::set_names(sapply(., `[`, 1)) %>%
purrr::map(~ se %>%
augere.gsea::runContrast(sets = gene.sets,
groups = "cell",
block = "dex",
comparison = .x,
methods = "camera",
assay = "counts",
output.dir = tempfile(),
save.results = FALSE)) %>%
basicBulk::tidyGSEAlist()Here we plot the top terms from each contrast to see how they compare.
GSEAlist %>%
purrr::map(~ dplyr::mutate(.x, Term = stringr::str_trunc(Term, 44))) %>%
basicBulk::topGSEAplot(n_terms = 5)Here we plot the top terms for each contrast to focus on them in isolation.
GSEAlist %>%
basicBulk::GSEAplotList() %>%
purrr::imap(~ .x + ggplot2::labs(title = .y)) %>%
cowplot::plot_grid(plotlist = ., ncol = 1)The genes within pathways of interest can be visualized as an expression heatmap. Here we take two significant pathways from the N61311 vs N052611 contrast. Genes shared between pathways are shown once and assigned to the first matching pathway.
pathways <- c("CELL SURFACE INTERACTIONS AT THE VASCULAR WALL",
"DEVELOPMENTAL LINEAGE OF MAMMARY GLAND MYOEPITHELIAL CELLS") %>%
stringr::str_replace_all(" ", "_") %>%
paste0("REACTOME_", .)
pathways %>%
basicBulk::makePathwayTibble(gene.sets) %>%
dplyr::distinct(ID, .keep_all = TRUE) %>%
dplyr::mutate(Pathway = forcats::fct_drop(Pathway)) %>%
basicBulk::basicHeatmap(se = se,
sigTibble = .,
pathways = TRUE,
show_row_names = FALSE)Pathways can also be summarized as gene set scores, where
basicBulk::joinFeatures(score = TRUE) averages the
expression of each pathway’s genes for every sample and
basicBulk::genePlot() plots the scores. Only the genes
retained by filterByExpr contribute, since the others are
NA in the logCPM assay. These scores summarize
expression and are not an enrichment test. Here we plot the same two
pathways.
pathways %>%
magrittr::extract(gene.sets, .) %>%
purrr::set_names(~ .x %>%
stringr::str_remove("^REACTOME_") %>%
stringr::str_replace_all("_", " ") %>%
stringr::str_wrap(20)) %>%
purrr::map(~ basicBulk::joinFeatures(se, features = .x, score = TRUE)) %>%
purrr::list_rbind(names_to = "symbol") %>%
basicBulk::genePlot(genes = unique(.$symbol),
size = 3) +
ggplot2::labs(y = "Gene set score")basicBulk also provides a Claude Code plugin with a skill for bulk RNA-seq analyses that uses the functions shown in this vignette and can generate a complete R Markdown report for a dataset. The skill runs R, so basicBulk, augere.de, and augere.gsea need to be installed.
To install the plugin, add basicBulk’s Bioconductor GitHub mirror as a plugin marketplace and then install the plugin from within a Claude Code session:
/plugin marketplace add bioc/basicbulk
/plugin install basicbulk@basicbulk
The same plugin is also available from the development repository
(/plugin marketplace add genentech/basicbulk). Add only one
of the two marketplaces, since both are named basicbulk.
It’s recommended to enable auto-update for the basicbulk
marketplace (/plugin, under Marketplaces) so new versions
of the plugin install automatically.
The skill can then be used with a short prompt. For example, this prompt asks it to recreate the analysis in this vignette:
/basicbulk:basicbulk Analyze augere.de::loadExampleDataset() by comparing
the N061011, N080611, and N61311 cell lines to N052611, blocking on dex.
tidybulk (Mangiola et al. 2021) also brings bulk RNA-seq analysis to the tidyverse through modular, pipe-friendly functions. basicBulk differs in that it offers an end-to-end workflow focused on comparing multiple contrasts to each other.
The Bioconductor support
site is the preferred method to ask for help. Before posting, it’s
recommended to check previous
posts for the answer and look over the posting
guide. For the post, it’s important to use the
basicBulk tag and provide both a minimal reproducible
example and session information.
## R version 4.6.2 (2026-10-29)
## Platform: x86_64-pc-linux-gnu
## Running under: Ubuntu 26.04.1 LTS
##
## Matrix products: default
## BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
## LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.32.so; LAPACK version 3.12.0
##
## locale:
## [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
## [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
## [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
## [7] LC_PAPER=en_US.UTF-8 LC_NAME=C
## [9] LC_ADDRESS=C LC_TELEPHONE=C
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
##
## time zone: Etc/UTC
## tzcode source: system (glibc)
##
## attached base packages:
## [1] stats4 stats graphics grDevices utils datasets methods
## [8] base
##
## other attached packages:
## [1] limma_3.99.5 basicBulk_0.99.0
## [3] SummarizedExperiment_1.43.0 Biobase_2.73.2
## [5] GenomicRanges_1.67.0 Seqinfo_1.3.2
## [7] IRanges_2.47.5 S4Vectors_0.51.10
## [9] BiocGenerics_0.59.13 generics_0.1.4
## [11] MatrixGenerics_1.25.0 matrixStats_1.5.0
## [13] BiocStyle_2.41.0
##
## loaded via a namespace (and not attached):
## [1] tibble_3.3.1 janitor_2.2.1
## [3] lifecycle_1.0.5 rstatix_1.1.0
## [5] edgeR_4.99.16 doParallel_1.0.17
## [7] pals_1.10 lattice_0.23-1
## [9] MASS_7.3-66 crosstalk_1.2.2
## [11] alabaster.base_1.13.5 backports_1.5.1
## [13] magrittr_2.0.5 plotly_4.12.1
## [15] sass_0.5.0 rmarkdown_2.32
## [17] jquerylib_0.1.4 yaml_2.3.12
## [19] otel_0.3.0 mapproj_1.2.12
## [21] cowplot_1.2.0 DBI_1.3.0
## [23] buildtools_1.0.0 RColorBrewer_1.1-3
## [25] lubridate_1.9.5 maps_3.4.4
## [27] abind_1.4-8 purrr_1.2.2
## [29] msigdbr_26.1.1 augere.core_0.99.5
## [31] gdtools_0.6.0 circlize_0.4.18
## [33] ggrepel_0.9.8 augere.gsea_0.99.2
## [35] irlba_2.4.1 maketools_1.3.2
## [37] MetBrewer_0.2.0 dqrng_0.4.1
## [39] DelayedMatrixStats_1.35.0 codetools_0.2-20
## [41] DelayedArray_0.39.8 DT_0.34.0
## [43] tidyselect_1.2.1 shape_1.4.6.1
## [45] tidyprint_1.1.1 farver_2.1.2
## [47] ScaledMatrix_1.21.0 ComplexUpset_1.3.3
## [49] augere.de_0.99.5 jsonlite_2.0.0
## [51] GetoptLong_1.1.1 ellipsis_0.3.3
## [53] Formula_1.2-6 iterators_1.0.14
## [55] systemfonts_1.3.4 foreach_1.5.2
## [57] tools_4.6.2 Rcpp_1.1.2
## [59] glue_1.8.1 SparseArray_1.13.5
## [61] BiocBaseUtils_1.15.1 xfun_0.62
## [63] DESeq2_1.53.8 gg4way_1.11.0
## [65] dplyr_1.2.1 HDF5Array_1.43.0
## [67] withr_3.0.3 BiocManager_1.30.27
## [69] fastmap_1.2.0 rhdf5filters_1.25.5
## [71] fansi_1.0.7 ttservice_0.5.3
## [73] digest_0.6.39 rsvd_2.0.0
## [75] timechange_0.4.0 R6_2.6.1
## [77] ggprism_1.0.7 colorspace_2.1-4
## [79] tidySummarizedExperiment_1.23.2 dichromat_2.0-1
## [81] RSQLite_3.53.3 h5mread_1.5.7
## [83] utf8_1.2.6 ggsci_5.2.0
## [85] tidyr_1.3.2 fontLiberation_0.1.0
## [87] data.table_1.18.6.1 httr_1.4.9
## [89] htmlwidgets_1.6.4 S4Arrays_1.13.3
## [91] pkgconfig_2.0.3 gtable_0.3.6
## [93] blob_1.3.0 ComplexHeatmap_2.29.0
## [95] S7_1.0.0 XVector_0.53.0
## [97] sys_3.4.3 shadowtext_0.1.6
## [99] htmltools_0.5.9 fontBitstreamVera_0.1.1
## [101] carData_3.0-6 clue_0.3-68
## [103] scales_1.4.0 alabaster.matrix_1.13.4
## [105] png_0.1-9 snakecase_0.11.1
## [107] knitr_1.52 reshape2_1.4.5
## [109] rjson_0.2.23 curl_8.1.0
## [111] cachem_1.1.0 rhdf5_2.57.20
## [113] GlobalOptions_0.1.4 stringr_1.6.0
## [115] parallel_4.6.2 AnnotationDbi_1.77.0
## [117] pillar_1.11.1 grid_4.6.2
## [119] alabaster.schemas_1.13.0 vctrs_0.7.3
## [121] ggpubr_1.0.0 car_3.1-5
## [123] BiocSingular_1.29.3 beachmat_2.29.3
## [125] cluster_2.1.8.3 evaluate_1.0.5
## [127] corrr_0.4.5 cli_3.6.6
## [129] locfit_1.5-9.12 compiler_4.6.2
## [131] rlang_1.3.0 crayon_1.5.3
## [133] ggsignif_0.6.4 labeling_0.4.3
## [135] forcats_1.0.1 plyr_1.8.9
## [137] ggiraph_0.9.7 stringi_1.8.9
## [139] viridisLite_0.4.3 alabaster.se_1.13.1
## [141] BiocParallel_1.47.0 assertthat_0.2.1
## [143] Biostrings_2.81.9 fontquiver_0.2.1
## [145] PCAtools_2.25.1 Matrix_1.7-6
## [147] patchwork_1.3.2 sparseMatrixStats_1.25.0
## [149] bit64_4.8.6 ggplot2_4.0.4
## [151] Rhdf5lib_2.1.1 KEGGREST_1.53.6
## [153] statmod_1.5.2 alabaster.ranges_1.13.1
## [155] broom_1.0.13 memoise_2.0.1
## [157] bslib_0.12.0 bit_4.6.0