How can I get all installed Bioconductor packages?
4
0
Entering edit mode
@ishenweiyan-16366
Last seen 3.5 years ago

In my all R packages, I want to find out which packages are installed by biocLite(), how could I do that ? Thank you.

bioconductor • 2.1k views
ADD COMMENT
2
Entering edit mode
Mike Smith ★ 5.3k
@mike-smith
Last seen 5 hours ago
EMBL Heidelberg / de.NBI

How about this, using the sessioninfo package:

library(sessioninfo)
library(dplyr)

## list all installed packages
pkgs <- installed.packages()[,'Package']

## read description files & parse using sessioninfo
desc <- lapply(pkgs, utils::packageDescription)
source <- vapply(desc, sessioninfo:::pkg_source, character(1))

## combine and filter for BioC only
bioc_pkgs <- data_frame(pkgs, source) %>%
    filter(source == "Bioconductor")

Output looks like:

> bioc_pkgs
# A tibble: 110 x 2
   pkgs             source      
   <chr>            <chr>       
 1 affy             Bioconductor
 2 affyio           Bioconductor
 3 airway           Bioconductor
 4 annotate         Bioconductor
 5 AnnotationDbi    Bioconductor
 6 AnnotationFilter Bioconductor
 7 AnnotationHub    Bioconductor
 8 Biobase          Bioconductor
 9 BiocGenerics     Bioconductor
10 BiocInstaller    Bioconductor
# ... with 100 more rows
ADD COMMENT
0
Entering edit mode

I think I wrote my piece of code before the nice sessioninfo came out, and sticked to that since it was working :D

ADD REPLY
2
Entering edit mode

I think yours has fewer steps and is easier to understand. This seems a rather neat combination:

installed.packages() %>% 
rownames() %>% 
devtools:::package_info() %>% 
filter(source == "Bioconductor")
ADD REPLY
0
Entering edit mode

I think the OP can be quite satisfied with the material over here, the latest one is nice & compact indeed
 

ADD REPLY
1
Entering edit mode
@federico-marini-6465
Last seen 9 months ago
Germany

Hi ishenweiyan,

this is part of a script I use to document every now and then the packages I have stored by major R version change

# using package_info for the extra info delivered
### -> you might need to change the lib.loc according to system/version
allpkgs <- (devtools:::package_info(rownames(installed.packages(lib.loc = "/Library/Frameworks/R.framework/Versions/3.5/Resources/library")),include_base = T))
allpkgs[grepl("Bioconductor",allpkgs$source),]

# in a similar fashion, for cran/CRAN packages, and leading edge packages you might have got from Github repos
allpkgs[grepl("cran",allpkgs$source,ignore.case = TRUE),]
allpkgs[grepl("Github",allpkgs$source),]

There might be other ways to do it, but I found this to be relatively robust. If others have alternative solutions, I'd be also happy to check them out ;)

ADD COMMENT
1
Entering edit mode
@martin-morgan-1513
Last seen 5 days ago
United States

A base R solution. These are the repositories that biocLite uses, filtered to exclude the CRAN repository

repos = BiocInstaller::biocinstallRepos()
repos = repos[startsWith(names(repos), "BioC")]

and the packages installed with biocLite

installed_pkgs = rownames(installed.packages())
available_pkgs = rownames(available.packages(repos = repos))
intersect(available_pkgs, installed_pkgs)

 

ADD COMMENT

Login before adding your answer.

Traffic: 470 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6