Skip to content

rodrigopsav/conda

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

Getting started with Conda

Conda is an open source package and environment management system that runs on Windows, macOS and Linux. Conda easily creates, saves, loads and switches between environments on your local computer. It was created for Python programs, but it can package and distribute software for any language. Conda is widely used by python users to create personalized environments to run specific projects. Environments created by Conda can also be reproduced on other machines. You will learn how to use Conda, create environments, install packages and create environment backups.

Topics

Conda tutorials
Installing miniconda
Managing conda environments

Sharing and restoring Conda environment

Conda tutorials

miniconda vs anaconda
getting started with conda
managing conda environments
managing conda packages
conda cheat sheet

Installing miniconda

### Downloading miniconda
mkdir ~/softwares
cd ~/softwares
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh

### Making bash executable
chmod +x Miniconda3-latest-Linux-x86_64.sh

### Installing miniconda
./Miniconda3-latest-Linux-x86_64.sh -b -p ~/softwares/miniconda3 -f
source ~/softwares/miniconda3/bin/activate
conda init bash
rm Miniconda3-latest-Linux-x86_64.sh

Managing conda environments

Add conda channels

conda config --add channels defaults
conda config --add channels conda-forge 
conda config --add channels anaconda
conda config --add channels bioconda
conda config --add channels biobuilds
conda config --add channels R
conda config --add channels intel
conda config --add channels trent
conda config --add channels plotly

Creating conda environment

conda create --yes --name myEnvironment python=version

or

conda create -y -n myEnvironment python=version

Examples

### Bioinformatics environment
conda create -y -n bioinfo python=3.8
conda install -y -n bioinfo -c bioconda bwa-mem2
conda install -y -n bioinfo -c bioconda htslib=1.9
conda install -y -n bioinfo -c bioconda samtools=1.9
conda install -y -n bioinfo -c bioconda bcftools=1.9
conda install -y -n bioinfo -c bioconda gatk4

### Python environment for deep learning
conda create -y -n dl python=3.8
conda install -y -n dl numpy
conda install -y -n dl pandas
conda install -y -n dl statsmodels
conda install -y -n dl -c plotly  plotly
conda install -y -n dl plotnine
conda install -y -n dl matplotlib
conda install -y -n dl seaborn
conda install -y -n dl bokeh
conda install -y -n dl tensorflow
conda install -y -n dl keras
conda install -y -n dl scikit-learn
conda install -y -n dl pytorch

### R v3.6
conda search r-base
conda search r-essentials

conda create -y -n r3.6 -c conda-forge r-base=3.6.3 r-essentials=3.6 python=3.8
conda install -y -n r3.6 "libblas=*=*openblas" 

### R v4.1
conda create -y -n r4.1 -c conda-forge r-base=4.1.0 r-essentials=4.1 python=3.8
conda install -y -n r4.1 "libblas=*=*openblas" 

Changing MKL library in conda environments

https://conda-forge.org/docs/maintainer/knowledge_base.html?highlight

conda install -y -n r3.6 "libblas=*=*mkl" 
conda install -y -n r3.6 "libblas=*=*openblas" 
conda install -y -n r3.6 "libblas=*=*blis" 
conda install -y -n r3.6 "libblas=*=*netlib"

Listing conda environments

conda env list

Changing conda environment

### Activate r4.1 environment
conda activate r4.1

### Activate bioinfo environment
conda activate bioinfo

### Deactivate conda environments
conda deactivate
conda deactivate

### Activate more than one environment
conda activate r4.1
conda activate --stack  bioinfo

conda deactivate
conda deactivate

Sharing and restoring Conda environment

Sharing an environment

conda activate bioinfo
conda env export bioinfo > bioinfo.yml

or

conda env export -n bioinfo > bioinfo.yml

Sharing an environment across Mac OS, Windows, and Linux

conda env export -n bioinfo --from-history> bioinfo_fh.yml

Removing packages and conda environment

conda activate bioinfo

### Listing packages in bioinfo environment
conda list

### Removing a package: bwa-mem2
conda remove -y -n bioinfo bwa-mem2

### Removing bioinfo environment
conda remove -y -n bioinfo --all

Creating an environment from an .yml file

### Listing conda environments
conda env list

### Creating bioinfo environment from .yml
conda env create -f bioinfo.yml

About

Getting started with Conda

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published