R how to install a specified version of a bioconductor package?

The version of DESeq2 package I wanted is 1.24 and is located in Bioconductor release version 3.9. The current release version of Bioconductor is 3.10 and DESeq2 version is 1.26.

Doing a BiocManager::install("DESeq2") would thus yield version 1.26. To get my desired version, I had to install packages compatible with Bioconductor release of 3.9 using

BiocManager::install(version = "3.9")

and then

BiocManager::install("DESeq2", version = "3.9")

This is from part of my sessionInfo(). Notice the correct version of DESeq2.

> sessionInfo()
R version 3.6.2 (2019-12-12)
Platform: x86_64-redhat-linux-gnu (64-bit)
Running under: Fedora 31 (Workstation Edition)

Matrix products: default
BLAS/LAPACK: /usr/lib64/R/lib/libRblas.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=sl_SI.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=sl_SI.UTF-8    LC_MESSAGES=en_US.UTF-8    LC_PAPER=sl_SI.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=sl_SI.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] parallel  stats4    stats     graphics  grDevices datasets  utils     methods   base     

other attached packages:
 [1] data.table_1.13.2           DESeq2_1.24.0               SummarizedExperiment_1.14.1 DelayedArray_0.10.0        
 [5] BiocParallel_1.18.1         matrixStats_0.57.0          Biobase_2.44.0              GenomicRanges_1.36.1       
 [9] GenomeInfoDb_1.20.0         IRanges_2.18.3              S4Vectors_0.22.1            BiocGenerics_0.30.0

Bioconductor stores the package archives here: https://bioconductor.org/packages/3.6/bioc/src/contrib/Archive/

1) Locate and download the version you would like to install.
2) Install it using R CMD INSTALL yourpackage_version_x.y.z.tar.gz as suggested by Eugène Adell in the comments.
If you cannot find the specific version on the bioconductor archive, then try to find it on the github repository of the package.


Try adding repos = c("https://bioconductor.org/packages/3.5/bioc", "other CRAN repos that might be needed") option to the install.packages call to install Bioconductor packages from previous releases. Installing specific version from tar.gz archive isn't recommended as you might end up with mutually incompatible packages in your Bioconductor installation.