ribiosNGS provides a streamlined workflow for
differential gene expression (DGE) analysis of RNA-seq count data. It
wraps edgeR and limma-voom pipelines into a
consistent interface built around the EdgeObject and
EdgeResult S4 classes. The package supports count
filtering, normalization, dispersion estimation, generalized linear
model fitting, and visualization.
The starting point of any analysis is an EdgeObject,
which bundles a count matrix with an experimental design and contrast
specification. We use simulated data here for illustration.
library(ribiosNGS)
set.seed(1887)
## Simulate count data: 200 genes, 6 samples in 2 groups
counts <- matrix(rpois(1200, lambda = 10), nrow = 200, ncol = 6)
rownames(counts) <- paste0("Gene", seq_len(200))
colnames(counts) <- paste0("Sample", seq_len(6))
## Define experimental groups
groups <- gl(2, 3, labels = c("Control", "Treatment"))
## Create design and contrast matrices
design <- model.matrix(~ 0 + groups)
colnames(design) <- levels(groups)
contrast <- matrix(c(-1, 1), ncol = 1,
dimnames = list(levels(groups),
"Treatment.vs.Control"))
## Bundle into a DesignContrast object
descon <- DesignContrast(design, contrast, groups = groups)
## Feature and sample annotation
fdata <- data.frame(Identifier = rownames(counts))
pdata <- data.frame(Name = colnames(counts), Group = groups)
## Create the EdgeObject
edgeObj <- EdgeObject(counts, descon, fData = fdata, pData = pdata)
edgeObj
#> An object of class "EdgeObject"
#> Slot "dgeList":
#> A DGEList object with 200 features and 6 samples
#> - Following items are available: counts,samples,genes
#>
#> Slot "designContrast":
#> DesignContrast object:
#> - 6 samples in 2 groups
#> Levels: Control, Treatment
#> - Design matrix (6 samples x 2 variables)
#> Variables: Control, Treatment
#> Call 'designMatrix(object)' to get the design matrix.
#> - Contrast matrix (2 variables x 1 contrasts)
#> Contrasts: Treatment.vs.Control
#> Call 'contrastMatrix(object)' to get the contrast matrix.
#> Call 'contrastAnnotation(object) to get the contrast annotation.The dgeWithEdgeR() function performs the complete DGE
pipeline: CPM filtering, normalization, dispersion estimation, GLM
fitting, and likelihood ratio testing.
edgeResult <- dgeWithEdgeR(edgeObj)
#> calcNormFactors has been renamed to normLibSizes
edgeResult
#> Significantly Differentially Expressed Genes Filter
#> * posLogFC filter set: logFC>=0.500000
#> * negLogFC filter set: logFC<=-0.500000
#> * FDR filter set: FDR<=0.050000
#> EdgeResult object: 200 genes, 6 samples, 1 contrasts
#> Call plotBCV() to visualize biological coefficient of variance
#> ----------------------------------------
#> * Significant DGE filter (call updateSigFilter() to update the settings):
#> Significantly Differentially Expressed Genes Filter
#> * posLogFC filter set: logFC>=0.500000
#> * negLogFC filter set: logFC<=-0.500000
#> * FDR filter set: FDR<=0.050000The dgeTable() function returns the results as a
data.frame, sorted by statistical significance.
res <- dgeTable(edgeResult)
head(res)
#> Contrast Identifier logFC logCPM LR PValue
#> 1 Treatment.vs.Control Gene143 -0.9151946 12.61566 6.198196 0.01278806
#> 2 Treatment.vs.Control Gene20 0.7930279 12.82978 5.542582 0.01855918
#> 3 Treatment.vs.Control Gene149 0.8159387 12.53659 4.631758 0.03138538
#> 4 Treatment.vs.Control Gene115 -0.9195697 12.24483 4.608727 0.03180963
#> 5 Treatment.vs.Control Gene92 -0.7563992 12.63477 4.362786 0.03673219
#> 6 Treatment.vs.Control Gene45 0.8078618 12.47430 4.319144 0.03768587
#> FDR
#> 1 0.769547
#> 2 0.769547
#> 3 0.769547
#> 4 0.769547
#> 5 0.769547
#> 6 0.769547An alternative pipeline uses limma-voom for the
analysis, which is particularly useful when the sample size is
large.
voomResult <- dgeWithLimmaVoom(edgeObj)
#> calcNormFactors has been renamed to normLibSizes
voomRes <- dgeTable(voomResult)
head(voomRes)
#> Contrast Feature AveExpr t logFC PValue
#> 1 Treatment.vs.Control Gene20 12.59273 2.305776 0.7480858 0.02137806
#> 2 Treatment.vs.Control Gene26 12.56587 -1.819629 -0.5566570 0.06918908
#> 3 Treatment.vs.Control Gene143 12.33316 -2.137082 -0.8670631 0.03289396
#> 4 Treatment.vs.Control Gene92 12.39792 -1.996748 -0.7427164 0.04619095
#> 5 Treatment.vs.Control Gene136 12.38734 1.940153 0.7369065 0.05271214
#> 6 Treatment.vs.Control Gene160 12.43519 1.859483 0.6693301 0.06332565
#> FDR B Identifier CIL CIR
#> 1 0.824758 -4.409865 Gene20 0.111231776 1.38493989
#> 2 0.824758 -4.486059 Gene26 -1.157153410 0.04383933
#> 3 0.824758 -4.493828 Gene143 -1.663470050 -0.07065608
#> 4 0.824758 -4.495640 Gene92 -1.472855014 -0.01257774
#> 5 0.824758 -4.506624 Gene136 -0.008652394 1.48246537
#> 6 0.824758 -4.508422 Gene160 -0.037237689 1.37589796The exampleEdgeObject() function generates a
ready-to-use EdgeObject for quick testing and
demonstration.
set.seed(42)
exObj <- exampleEdgeObject(nfeat = 100, nsample = 9, ngroup = 3)
exObj
#> An object of class "EdgeObject"
#> Slot "dgeList":
#> A DGEList object with 100 features and 9 samples
#> - Following items are available: counts,samples,genes
#>
#> Slot "designContrast":
#> DesignContrast object:
#> - 9 samples in 3 groups
#> Levels: Group1, Group2, Group3
#> - Design matrix (9 samples x 3 variables)
#> Variables: Group1, Group2, Group3
#> Call 'designMatrix(object)' to get the design matrix.
#> - Contrast matrix (3 variables x 2 contrasts)
#> Contrasts: Group2.vs.Group1, Group3.vs.Group1
#> Call 'contrastMatrix(object)' to get the contrast matrix.
#> Call 'contrastAnnotation(object) to get the contrast annotation.sessionInfo()
#> R version 4.6.0 (2026-04-24)
#> Platform: x86_64-pc-linux-gnu
#> Running under: Ubuntu 24.04.4 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.26.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] stats graphics grDevices utils datasets methods base
#>
#> other attached packages:
#> [1] ribiosNGS_1.0.0 BiocStyle_2.41.0
#>
#> loaded via a namespace (and not attached):
#> [1] RColorBrewer_1.1-3 sys_3.4.3
#> [3] jsonlite_2.0.0 shape_1.4.6.1
#> [5] magrittr_2.0.5 farver_2.1.2
#> [7] rmarkdown_2.31 GlobalOptions_0.1.4
#> [9] fs_2.1.0 vctrs_0.7.3
#> [11] memoise_2.0.1 htmltools_0.5.9
#> [13] S4Arrays_1.13.0 mongolite_4.0.0
#> [15] SparseArray_1.13.2 sass_0.4.10
#> [17] KernSmooth_2.23-26 bslib_0.11.0
#> [19] plyr_1.8.9 cachem_1.1.0
#> [21] gt_1.3.0 buildtools_1.0.0
#> [23] lifecycle_1.0.5 iterators_1.0.14
#> [25] pkgconfig_2.0.3 Matrix_1.7-5
#> [27] R6_2.6.1 fastmap_1.2.0
#> [29] MatrixGenerics_1.25.0 clue_0.3-68
#> [31] digest_0.6.39 colorspace_2.1-2
#> [33] AnnotationDbi_1.75.0 S4Vectors_0.51.3
#> [35] GenomicRanges_1.65.0 RSQLite_3.53.1
#> [37] ribiosArg_1.5.0 httr_1.4.8
#> [39] abind_1.4-8 mgcv_1.9-4
#> [41] compiler_4.6.0 bit64_4.8.2
#> [43] doParallel_1.0.17 S7_0.2.2
#> [45] BiocParallel_1.47.0 DBI_1.3.0
#> [47] UpSetR_1.4.1 ribiosAnnotation_3.8.0
#> [49] ribiosPlot_1.3.0 gplots_3.3.0
#> [51] MASS_7.3-65 DelayedArray_0.39.3
#> [53] rjson_0.2.23 scatterplot3d_0.3-45
#> [55] gtools_3.9.5 caTools_1.18.3
#> [57] ribiosUtils_1.7.10 tools_4.6.0
#> [59] ribiosIO_1.1.0 otel_0.2.0
#> [61] zip_3.0.0 glue_1.8.1
#> [63] nlme_3.1-169 grid_4.6.0
#> [65] cluster_2.1.8.2 reshape2_1.4.5
#> [67] ade4_1.7-24 generics_0.1.4
#> [69] sva_3.61.0 gtable_0.3.6
#> [71] preprocessCore_1.75.0 tidyr_1.3.2
#> [73] xml2_1.5.2 XVector_0.53.0
#> [75] BiocGenerics_0.59.7 ggrepel_0.9.8
#> [77] foreach_1.5.2 pillar_1.11.1
#> [79] stringr_1.6.0 limma_3.69.2
#> [81] genefilter_1.95.0 circlize_0.4.18
#> [83] splines_4.6.0 dplyr_1.2.1
#> [85] lattice_0.22-9 survival_3.8-6
#> [87] bit_4.6.0 annotate_1.91.0
#> [89] tidyselect_1.2.1 made4_1.87.0
#> [91] ComplexHeatmap_2.29.0 locfit_1.5-9.12
#> [93] maketools_1.3.2 Biostrings_2.81.3
#> [95] knitr_1.51 gridExtra_2.3
#> [97] IRanges_2.47.2 Seqinfo_1.3.0
#> [99] edgeR_4.11.1 SummarizedExperiment_1.43.0
#> [101] stats4_4.6.0 xfun_0.58
#> [103] Biobase_2.73.1 statmod_1.5.2
#> [105] matrixStats_1.5.0 stringi_1.8.7
#> [107] yaml_2.3.12 evaluate_1.0.5
#> [109] codetools_0.2-20 tibble_3.3.1
#> [111] BiocManager_1.30.27 cli_3.6.6
#> [113] affyio_1.83.0 xtable_1.8-8
#> [115] jquerylib_0.1.4 Rcpp_1.1.1-1.1
#> [117] png_0.1-9 XML_3.99-0.23
#> [119] ribiosExpression_1.3.5 parallel_4.6.0
#> [121] ggplot2_4.0.3 blob_1.3.0
#> [123] bitops_1.0-9 scales_1.4.0
#> [125] affy_1.91.0 openxlsx_4.2.8.1
#> [127] purrr_1.2.2 crayon_1.5.3
#> [129] GetoptLong_1.1.1 rlang_1.2.0
#> [131] vsn_3.81.0 KEGGREST_1.53.0