I'm not awesome at interpreting R functions and I'm using code from Callahan et al., 2017 to install Bioconductor packages. Their script is as follows:
.bioc_packages <- c("dada2", "phyloseq", "DECIPHER", "phangorn")
.inst <- .bioc_packages %in% installed.packages()
if(any(!.inst)) {
source("http://bioconductor.org/biocLite.R")
biocLite(.bioc_packages[!.inst], ask = F)
}
And I have two questions:
What does the syntax
if(any(!.inst))
accomplish? I understand the structure of a function, but I don't know specifically what this particular section "means".Bioconductor is using BiocManager with R versions greater than 3.5 (I'm on 4.1.2) so the above code gives me the error:
With R version 3.5 or greater, install Bioconductor packages using BiocManager; see https://bioconductor.org/install
How may I edit the function to address this error?
Thank you!
CodePudding user response:
Probably best to ask this on the Bioconductor support site https://support.bioconductor.org.
I'd suggest
## we need BiocManager from CRAN
if (!"BiocManager" %in% rownames(installed.packages()))
install.packages("BiocManager", repos = "https://cran.r-project.org")
## install or update required packages
.bioc_packages <- c("dada2", "phyloseq", "DECIPHER", "phangorn")
BiocManager::install(.bioc_packages)
This will install all packages (and their dependencies) that are not already installed, will update any packages that are not current (for the release of Bioconductor that you are using -- per Bioconductor guidelines, these will be bug fixes only), and will say that it will not re-install packages that are already installed with their current version.
Note that with R-4.1.2 you will not get the most recent version of Bioconductor. You might update to R-4.2.1 (because you want to be using current versions of these packages, and because you might want to do other analyses in Bioconductor involving packages that have been introduced since the Bioconductor version available with R-4.1.2) or downgrade to the R version used in the paper you cite (because you want to more closely reproduce results from the paper).