r-lib / devtools

Tools to make an R developer's life easier

Home Page:https://devtools.r-lib.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Check Bioconductor dependencies when running install_github?

zji90 opened this issue · comments

Hi,
I am trying to run install_github to install an R package hosted on Github. This package has a dependency package that is hosted on Bioconductor but not hosted on CRAN. It seems that install_github will not automatically detect the Bioconductor dependencies so the installation just fails because install_github can not find the denpendency package on CRAN. Now I have to install the Bioconductor package first and then install the Github package. This makes the installation process tedious and frustrated for other users. Is there a way that install_github can also detect the package dependencies on Bioconductor?

This works fine for me; can you please provide a reproducible example of when it's not working for you?

Does the following work for you?

devtools::install_github('PeteHaitch/BioCpkgA')

It should install a toy package BioCpkgA whose only dependency is GenomicTuples, which is available via Bioconductor and not CRAN.

# My sesion info
devtools::session_info()
Session info ---------------------------------------------------------------------
 setting  value                       
 version  R version 3.1.2 (2014-10-31)
 system   x86_64, darwin10.8.0        
 ui       RStudio (0.99.234)          
 language (EN)                        
 collate  en_AU.UTF-8                 
 tz       Australia/Melbourne         

Packages -------------------------------------------------------------------------
 package       * version  date       source                              
 Biobase       * 2.26.0   2014-10-14 Bioconductor                        
 BiocGenerics  * 0.12.1   2014-11-14 Bioconductor                        
 BioCpkgA        0.1      2015-03-02 Github (PeteHaitch/BioCpkgA@26d12ba)
 bitops        * 1.0-6    2013-08-17 CRAN (R 3.1.0)                      
 devtools      * 1.7.0    2015-01-17 CRAN (R 3.1.2)                      
 GenomeInfoDb  * 1.2.4    2014-12-19 Bioconductor                        
 GenomicRanges * 1.18.4   2015-01-07 Bioconductor                        
 GenomicTuples * 1.0.0    2014-10-14 Bioconductor                        
 httr          * 0.6.1    2015-01-01 CRAN (R 3.1.2)                      
 IRanges       * 2.0.1    2014-12-12 Bioconductor                        
 packrat       * 0.4.3    2015-01-29 CRAN (R 3.1.2)                      
 Rcpp          * 0.11.4   2015-01-24 CRAN (R 3.1.2)                      
 RCurl         * 1.95-4.5 2014-12-06 CRAN (R 3.1.2)                      
 rstudioapi    * 0.2      2014-12-31 CRAN (R 3.1.2)                      
 S4Vectors     * 0.4.0    2014-10-14 Bioconductor                        
 stringr       * 0.6.2    2012-12-06 CRAN (R 3.1.0)                      
 XVector       * 0.6.0    2014-10-14 Bioconductor

This example does not work for me:

devtools::install_github('PeteHaitch/BioCpkgA')
Downloading github repo PeteHaitch/BioCpkgA@master
Installing BioCpkgA
Installing dependencies for BioCpkgA:
GenomicTuples
Installing package into ‘/home/nsheffield/R’
(as ‘lib’ is unspecified)
'/usr/lib/R/bin/R' --vanilla CMD INSTALL  \
  '/tmp/Rtmp6GpfdN/devtools194d288e6252/PeteHaitch-BioCpkgA-26d12ba'  \
  --library='/home/nsheffield/R' --install-tests 

ERROR: dependency ‘GenomicTuples’ is not available for package ‘BioCpkgA’
* removing ‘/home/nsheffield/R/BioCpkgA’

If I first install GenomicTuples, then it works:

devtools::install_github('PeteHaitch/BioCpkgA')
Downloading github repo PeteHaitch/BioCpkgA@master
Installing BioCpkgA
'/usr/lib/R/bin/R' --vanilla CMD INSTALL  \
  '/tmp/Rtmp6GpfdN/devtools194d690d04ab/PeteHaitch-BioCpkgA-26d12ba'  \
  --library='/home/nsheffield/R' --install-tests 

* installing *source* package ‘BioCpkgA’ ...
** R
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (BioCpkgA)

Here is a package of mine with the same issue: https://github.com/sheffien/LOLA
It will not download and install IRanges, for example.

devtools::session_info()
Session info -------------------------------------------------------------------
 setting  value                       
 version  R version 3.2.0 (2015-04-16)
 system   x86_64, linux-gnu           
 ui       X11                         
 language en_US                       
 collate  en_US.UTF-8                 
 tz       <NA>                        

Packages -----------------------------------------------------------------------
 package       * version  date       source        
 BiocInstaller   1.19.3   2015-04-21 Bioconductor  
 bitops        * 1.0-6    2013-08-17 CRAN (R 3.2.0)
 devtools      * 1.7.0    2015-01-17 CRAN (R 3.2.0)
 httr          * 0.6.1    2015-01-01 CRAN (R 3.2.0)
 RCurl         * 1.95-4.5 2014-12-28 CRAN (R 3.2.0)
 rstudioapi    * 0.3.1    2015-04-07 CRAN (R 3.2.0)
 stringr       * 0.6.2    2012-12-06 CRAN (R 3.2.0)

Hmm, yes there does seem to be a problem. I just tried on a fresh installation of R 3.2 and confirmed that devtools::install_github('PeteHaitch/BioCpkgA') doesn't work unless GenomicTuples is first installed via

source("http://bioconductor.org/biocLite.R")
biocLite("GenomicTuples")

or BiocInstaller::biocLite('GenomicTuples') (if BiocInstaller is already installed).

I thought this used to work (i.e., in R 3.1), but I may be mistaken.

I won't have time to look into this until next week at the earliest, possibly the following week.

# Session info with BioC release
> devtools::session_info()
Session info ---------------------------------------------------------------------
 setting  value                       
 version  R version 3.2.0 (2015-04-16)
 system   x86_64, darwin13.4.0        
 ui       RStudio (0.99.235)          
 language (EN)                        
 collate  en_AU.UTF-8                 
 tz       Australia/Melbourne         

Packages -------------------------------------------------------------------------
 package       * version  date       source        
 BiocInstaller   1.18.1   2015-04-17 Bioconductor  
 bitops        * 1.0-6    2013-08-17 CRAN (R 3.2.0)
 devtools      * 1.7.0    2015-01-17 CRAN (R 3.2.0)
 httr          * 0.6.1    2015-01-01 CRAN (R 3.2.0)
 RCurl         * 1.95-4.5 2014-12-28 CRAN (R 3.2.0)
 rstudioapi    * 0.3.1    2015-04-07 CRAN (R 3.2.0)
 stringr       * 0.6.2    2012-12-06 CRAN (R 3.2.0)

# Session info with BioC devel, i.e., following BiocInstaller::useDevel(TRUE)
> devtools::session_info()
Session info ---------------------------------------------------------------------
 setting  value                       
 version  R version 3.2.0 (2015-04-16)
 system   x86_64, darwin13.4.0        
 ui       RStudio (0.99.235)          
 language (EN)                        
 collate  en_AU.UTF-8                 
 tz       Australia/Melbourne         

Packages -------------------------------------------------------------------------
 package       * version  date       source        
 BiocInstaller   1.19.3   2015-04-20 Bioconductor  
 bitops        * 1.0-6    2013-08-17 CRAN (R 3.2.0)
 devtools      * 1.7.0    2015-01-17 CRAN (R 3.2.0)
 httr          * 0.6.1    2015-01-01 CRAN (R 3.2.0)
 RCurl         * 1.95-4.5 2014-12-28 CRAN (R 3.2.0)
 rstudioapi    * 0.3.1    2015-04-07 CRAN (R 3.2.0)
 stringr       * 0.6.2    2012-12-06 CRAN (R 3.2.0)

Unfortunately I think this is just the reality of relying on bioconductor packages. If anyone has bright ideas about how to make it a bit better, I'd be happy to review a PR.

This is indeed a pity, now the installation instructions for a package of mine ("lamortenera/epicseg") have become more tedious and might scare users.
Maybe that's a very naive and stupid idea, but what argues against providing a flag for allowing installation from Bioconductor? Something like the bioc_required option provided by R-travis?
I guess this could be implemented by installing every dependency with
source("http://bioconductor.org/biocLite.R")
biocLite("pkgname")
instead of
install.packages("pkgname")

That said, devtools is still an awesome package and thanks so much for it.

Or is it possible to add the list of bioconductor repos as a repos source in package_deps??

http://bioconductor.org/packages/release/bioc/
http://bioconductor.org/packages/release/data/annotation
http://bioconductor.org/packages/release/data/experiment
http://bioconductor.org/packages/release/extra

These will return the list of available packages using available_packages, just checked on R 3.2.0 and devtools 1.8.0

This is awesome! My bad that I didn't see it.
Thanks so much!

But it looks like there would need to be a pull request to add these to the package_deps function before they would be useful in install_github??

Ah right, I celebrated too early. I thought that the ... in install_github were used in install, which has also some ... used in install.packages, which has option repos. But this is not working :(

One way to make devtools install dependencies from Bioconductor is like this:

# Install a cool package
devtools::install_github(repo="Bioconductor-mirror/CoolPkg1")
# Human: Error: CoolPkg1 require SomePkgA version x.10.10 ; only SomePkgA version x.9.9 is installed.
# Machine: Look for SomePkgA on gitbub?
# Human: Yes
# Machine: From which github users? 
# [1]  Bioconductor-mirror
# [2] Bioconductor-mirror (use as default)
# Human: Answer: 2
# Machine: Ok, now I will try to install required dependencies from this github user: Bioconductor-mirror
# Machine: Just sit back and relax.
# Mahcine: But beware that you will get all the risk of using unstable versions of packages.
# Human: What?!!! Ok, could you please roll back?
# Machine: No, it's too late. Joking :-)
# Human: Phew! 
# Machine: Rolling back ....

Continued...

# Machine: You know what, maybe you don't need this install_github() at all.
# Machine: To install Bioconductor development versions of packages
# Machine: Just run this:
source("http://bioconductor.org/biocLite.R")
BiocInstaller::useDevel()
biocLite("CoolPkg1")
# Human: Cool. What if things mess up so bad and I want to revert to stable version.
# Machine: No problem, do this:
# Quit current R session and open a new one
source("http://bioconductor.org/biocLite.R")
pkgs <- rownames(installed.packages())
BiocInstaller::useDevel(FALSE)
biocLite(pkgs) # this could take hours to finish.

There is a trick for this: add biocViews: to the package's DESCRIPTION and R will know to search the bioconductor repository automatically for package requirements. This trick is not documented anywhere.

commented

This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/