Conda package manager

Installing Miniconda package manager

Why Conda

Briefly, Anaconda, or conda, is a software package manager. Anaconda will make your scientific programming life easier by facilitating software installations for many programs or packages. You can google conda install for software X, and often find a single line command to install the most recent version of that software.

Even better, Anaconda allows you to create compartmentalized computational environments (called conda environments) where you can install any mixture of things you require without accidentally messing up other software downloads on your computer. You can use these conda environments in any number of ways– they can be program-specific (for the running of one specific tool) or project-specific (to store versions for a whole workflow). For instance, you may working on a collaborative project which requires building bioinformatic pipelines with several different programs. It is key that your collaborator and you maintain the same versions of software, so code that you write individually can be easily shared. For this, you can create and share a conda environment. More info on getting started with conda here.

Conda environments have been widely adopted as a means of facilitating reproducible computation across the Python ecosystem– but is now expanding to include other programming languages such as R more here.

Creating a Conda environment for R

Note

The flag -n is for environment name, the flag -c is for channel name.

Tip

You can also search for any R package if you know the name, such as conda search -f r-EXACTNAME. Replace EXACTNAME with the desired CRAN or MRAN R package name. For example, for rbokeh, you would use conda search -f r-rbokeh. Also, Find out what versions of r-factominer are available in the bioconda channel using conda search -c conda-forge r-factominer you can seek more details by using conda search --help.

Note

For more details on managing packages see here

Note

to remove a channel type

conda config --remove channels `channel-name`

Note

If you already have Miniconda or Anaconda installed, and you just want to upgrade, you should not use the installer. Just use conda update.

Opening RStudio within the R conda environment

Note

You can now remove the environments you created.

How to make your project reproducible with Conda environment

We have up until now specified which Conda packages to install directly on the command line using the conda create and conda install commands. For working in projects this is not the recommended way. Instead, for increased control and reproducibility, it is better to use a file (in yaml format) specifying packages, versions, and channels needed to create the environment for a project.

Tip

  • Restoring environment to a previous revision: Conda keeps a history of all the changes made to your environment, so you can easily "roll back" to a previous version. (this is very import in case you make some error by installing a wrong package or mess up with something instead of removing the environment and state from the beginning).

  • To list the history of each change to the current environment:

    conda list --revisions
    
  • To restore environment to a previous revision:

    conda install --rev REVNUM
    
  • NOTE: Replace REVNUM with the revision number.

Conda cheat sheet

Conda cheat sheet

Conda cheat sheet