3
$\begingroup$

I have R installed and managed by conda (miniconda) on my MacBook Pro. The version of R I use most frequently (3.5.1) is installed on the base environment and I have other version-specific environments as well. I did this as it was easier than managing R on homebrew.

The downside I now face is that I cannot use install.packages(), BiocManager::install() or biocLite() to install most packages. devtools::install_github() seems to work fine for the few packages I have installed from GitHub.

I have to use conda install -c [conda-forge|bioconda] [r|bioconductor]-package_name to install my packages and it breaks my workflow and I need to step outside of R to install packages.

Am I doing anything wrong, or is this the only way packages can be managed when R in installed through conda?

A few sample packages that I needed to install using conda:

  • tidyverse
  • tximport
  • deseq2
  • apeglm
  • maftools
  • sva
$\endgroup$
4
  • $\begingroup$ A colleague pointed me to this post: stackoverflow.com/q/26185978/1394178, and I tried the top 2 solutions. The Mojave solution (that installs a bunch of headers) worked for a package (refGenome) where the file wchar.h was the problem. Not sure if this would work for every package that runs into a compiler error. $\endgroup$
    – Ram RS
    Jul 11 '19 at 15:11
  • $\begingroup$ What error message do you get when you try to install those bioconductor packages from R? $\endgroup$
    – llrs
    Jul 12 '19 at 7:34
  • 1
    $\begingroup$ It's mostly C/C++ make/compile error messages. It happened so often that I stopped looking at the exact error message. I'll create a new conda env and post exact error messages for these packages. $\endgroup$
    – Ram RS
    Jul 12 '19 at 14:14
  • $\begingroup$ I tried just with tidyverse. Here are the conda and R steps. The error messages in the R step are not complete, as there was only so much scroll-back history I could get to. Probably should have redirected STDERR to a file. $\endgroup$
    – Ram RS
    Jul 13 '19 at 14:23
3
$\begingroup$

Installing packages outside of an R session is arguably the point of using conda. Package management isn't something that should be done within scripts, only the loading of packages. Doing so ensures that your environment setup is somewhat robust, which should be set before you perform actual calculations.

Using conda install ... is the best way to ensure environment stability here, and, thankfully, lots of people at Bioconductor have worked very hard to make sure bioconda packages fit with the conda framework.

If you need to find packages, you can search online at https://anaconda.org, or from the command line via conda search <pkg>.

$\endgroup$
3
  • $\begingroup$ I'm really grateful to everyone creating conda install-able packages for R and bioconductor packages. I'm not looking to install packages in R scripts, only in interactive R sessions. It breaks the flow to step out of an R session and install a package. I should also mention that I do break environment stability with my habits, where my default R library is user-level (~/.Rlibs/), not environment-level. .libPaths()[2] is where the conda R library path sits. $\endgroup$
    – Ram RS
    Jul 12 '19 at 21:56
  • $\begingroup$ Hi, as a follow-up: What would be the recommended way to install packages that are not available in the conda channels? Which of the other options (install.packages() or BiocManager::install() or devtools::install_github()) should be the backup.. Thanks! $\endgroup$
    – Tapper
    Jun 22 '20 at 18:08
  • $\begingroup$ Conda does handle PyPI packages well, but unfortunately it doesn't handle R packages from CRAN as nicely. Bioconductor packages available through BiocManager::install should all be listed with the name bioconductor-<packagename> in the bioconda channel, but other R packages on CRAN might not be. Personally, I've found that the easiest way to deal with CRAN-only packages is to make my own conda package using conda skeleton cran <packagename>, then install your local packge, or upload it to Anaconda cloud first before installing $\endgroup$ Jun 22 '20 at 19:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.