<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.10.0">Jekyll</generator><link href="https://xindongnov.github.io/feed.xml" rel="self" type="application/atom+xml" /><link href="https://xindongnov.github.io/" rel="alternate" type="text/html" /><updated>2026-08-22T02:27:01+08:00</updated><id>https://xindongnov.github.io/feed.xml</id><title type="html">Xin’s Website</title><subtitle>A Self Introdution Website.</subtitle><author><name>Xin Dong</name></author><entry><title type="html">How to configure a bioinformatics environment</title><link href="https://xindongnov.github.io/blogs/bioinformatics/How-to-configure-a-bioinformatics-environment/" rel="alternate" type="text/html" title="How to configure a bioinformatics environment" /><published>2020-09-22T00:00:00+08:00</published><updated>2020-09-22T00:00:00+08:00</updated><id>https://xindongnov.github.io/blogs/bioinformatics/How-to-configure-a-bioinformatics-environment</id><content type="html" xml:base="https://xindongnov.github.io/blogs/bioinformatics/How-to-configure-a-bioinformatics-environment/"><![CDATA[<p>Installing bioinformatics software is often the first obstacle for beginners. However, even experienced users can face errors or warnings when installing new tools or trying new methods. Some old packages that are still needed for work - regenerate their paper’s results or use their subfunctions - can be extremely difficult to install. Here’s how I configure my working environment.</p>

<blockquote>
  <p>P.S. Since I use macOS and Linux in my daily work, I’ll explain these two systems more clearly. Maybe later, I will add Windows as well.</p>
</blockquote>

<p>A package manager is very helpful for your work. It can help you with package versioning, installation, uninstallation, environment variables, and more. Homebrew, Conda, and NPM are all great package managers. They are similar to app stores on your smartphone. Homebrew is a general-purpose software manager that is mostly used on macOS. NPM is a package manager for Javascript. Conda has become a new standard for bioinformatics software. If a new bioinformatics software does not have a conda version, I would think that it might be hard to install and uninstall completely later.</p>

<p>When you look for conda on google or other search engines, you will see two results: anaconda and miniconda.</p>

<blockquote>
  <p>Conda is an open source package management system and environment management system for installing multiple versions of software packages and their dependencies and switching easily between them. It works on Linux, OS X and Windows, and was created for Python programs but can package and distribute any software.</p>
</blockquote>

<p>Anaconda is a Python distribution that includes many packages related to scientific computation. Miniconda only includes the package manager, and you can install other packages later.</p>

<p><img src="/assets/images/posts_images/2020-09/python-package.png" alt="python packge" /></p>

<p>You can easily download miniconda here: <a href="https://docs.conda.io/en/latest/miniconda.html">https://docs.conda.io/en/latest/miniconda.html</a></p>

<p>Most computers nowadays have a 64-bit system installed, so choose the 64-bit version installation scripts to download. Python 2.X was deprecated in January 2020, so select the Python 3.x version and use it in the future. On macOS or Linux, I prefer downloading the bash (*.sh) file. Then type <code class="language-plaintext highlighter-rouge">bash Miniconda3-latest-*-x86_64.sh</code> in the terminal and follow the instructions. It will ask you to give a path where miniconda will be installed. When you are almost finished with the installation, conda will ask you whether you want to initialize conda. Type <code class="language-plaintext highlighter-rouge">yes</code> to confirm this. It will add several lines of code in your <code class="language-plaintext highlighter-rouge">~/.bashrc</code> (Linux) or <code class="language-plaintext highlighter-rouge">~/.bash_profile</code> (macOS) to initialize conda base environment when you log in to the terminal every time. If you typed <code class="language-plaintext highlighter-rouge">no</code>, you can find where conda is - you set it before - then type <code class="language-plaintext highlighter-rouge">path_to_conda/conda init</code> to initialize conda. After all of that, you will have miniconda installed.</p>

<p>You can use conda commands to build your environment. Here are the instructions:</p>

<p>I suggest using an independent environment for each project to avoid conflicts with different packages. To create a new conda environment, use <code class="language-plaintext highlighter-rouge">conda create -n env_name</code>. You can also specify the Python version here, e.g., <code class="language-plaintext highlighter-rouge">conda create -n env_name python=2.7</code>.</p>

<div class="language-md highlighter-rouge"><div class="highlight"><pre class="highlight"><code>conda is a tool for managing and deploying applications, environments and packages.

Options:

positional arguments:
  command
    clean        Remove unused packages and caches.
    compare      Compare packages between conda environments.
    config       Modify configuration values in .condarc. This is modeled
                 after the git config command. Writes to the user .condarc
                 file (/mnt/Storage/home/dongxin/.condarc) by default.
    create       Create a new conda environment from a list of specified
                 packages.
    help         Displays a list of available conda commands and their help
                 strings.
    info         Display information about current conda install.
    init         Initialize conda for shell interaction. [Experimental]
    install      Installs a list of packages into a specified conda
                 environment.
    list         List linked packages in a conda environment.
    package      Low-level conda package utility. (EXPERIMENTAL)
    remove       Remove a list of packages from a specified conda environment.
    uninstall    Alias for conda remove.
    run          Run an executable in a conda environment. [Experimental]
    search       Search for packages and display associated information. The
                 input is a MatchSpec, a query language for conda packages.
                 See examples below.
    update       Updates conda packages to the latest compatible version.
    upgrade      Alias for conda update.

optional arguments:
  -h, --help     Show this help message and exit.
  -V, --version  Show the conda version number and exit.

conda commands available from other packages:
  env
  server
</code></pre></div></div>

<p>You can switch between the environments with <code class="language-plaintext highlighter-rouge">conda activate env_name</code> and <code class="language-plaintext highlighter-rouge">conda deactivate</code>. And you can install packages by <code class="language-plaintext highlighter-rouge">conda install</code>. You also can search whether a package has a conda distribution here: <a href="https://anaconda.org">https://anaconda.org</a>.</p>

<p>Conda has many channels that collect a category of packages, like conda-forge, bioconda, r, etc. You can create your own channel with your packages as well. Conda can install most of the packages that you need. For example, you can install R by <code class="language-plaintext highlighter-rouge">conda install -c conda-forge r-base</code>.</p>

<p><img src="/assets/images/posts_images/2020-09/conda-r-base.png" alt="conda r base" /></p>

<p>Conda is a powerful tool for building environments and handling most of the tricky things in environment configuration. However, solving environment issues can sometimes take a lot of time and can be frustrating when errors occur. At least it is very useful. When building pipelines with Snakemake, it suggests good compatibility with many packages.</p>

<p>Highlight it as a checklist:</p>

<ul>
  <li>Download miniconda <a href="https://docs.conda.io/en/latest/miniconda.html">here</a></li>
  <li>Install miniconda</li>
  <li>Initialize conda with <code class="language-plaintext highlighter-rouge">conda init</code></li>
  <li>Build environment with <code class="language-plaintext highlighter-rouge">conda create</code></li>
  <li>Install packages you need with <code class="language-plaintext highlighter-rouge">conda install</code></li>
  <li>Enjoy</li>
</ul>

<p>Here are some software that bioinformaticians use and you may interest in as well. Besides, all of them can be installed by conda:</p>

<ul>
  <li>bwa (A mapping software)</li>
  <li>macs2 (Used for peak calling)</li>
  <li>STAR (A slice-aware mapping software)</li>
  <li>DESeq2 (An R package for differential expression analysis)</li>
  <li>bedtools (Useful tool to manipulate .BED file)</li>
  <li>samtools (Useful tool to manipulate .BAM/.SAM/.CRAM file)</li>
  <li>Seurat (An R package to analysis single-cell data)</li>
</ul>

<p>Have a try with the above and tell me any feedback in the comments.</p>

<hr />

<p>I wrote this blog because I encountered a lot of errors when I tried to update R in my base environment. The issue might be related to <a href="https://github.com/conda/conda/issues/9367">this</a>. No matter if I ran <code class="language-plaintext highlighter-rouge">conda install -c conda-forge r-base=4.0</code> or <code class="language-plaintext highlighter-rouge">conda update -c conda-forge r-base</code>, the errors and conflict warnings kept showing up.  Finally, I realized that the problem was that I had switched to another conda mirror before. When I tried to update software from the official sources, it conflicted with the previous mirror. After I uninstalled all software from the third-party mirror, the R packages were updated successfully.</p>

<p><img src="/assets/images/posts_images/2020-09/conda-tsinghua-conflict.png" alt="conda tsinghua conflict" /></p>]]></content><author><name>Xin Dong</name></author><category term="blogs" /><category term="bioinformatics" /><category term="software" /><summary type="html"><![CDATA[Installing bioinformatics software is often the first obstacle for beginners. However, even experienced users can face errors or warnings when installing new tools or trying new methods. Some old packages that are still needed for work - regenerate their paper’s results or use their subfunctions - can be extremely difficult to install. Here’s how I configure my working environment.]]></summary></entry><entry><title type="html">Start My Blogs</title><link href="https://xindongnov.github.io/blogs/Start-my-blog/" rel="alternate" type="text/html" title="Start My Blogs" /><published>2020-09-14T00:00:00+08:00</published><updated>2020-09-14T00:00:00+08:00</updated><id>https://xindongnov.github.io/blogs/Start-my-blog</id><content type="html" xml:base="https://xindongnov.github.io/blogs/Start-my-blog/"><![CDATA[<p>Hello! It took me some spare time to get this website working as I wanted. After building this website, I decided to write something sometimes. As a Ph.D. student, my supervisors told us that we should practice writing as early as possible. But it’s quite hard to persist with many daily works and tasks. However, writing blogs might be a good way to encourage me.</p>

<p>For blog content, I would like to share my daily life, new technology in biology/bioinformatics, some tricks I encountered in coding, new digital products that interest me, etc. Well, input makes output. I definitely still need to learn and read things as much as possible, which can help me write a lot with good quality. I’ll try to update this regularly and continually, hopefully.</p>]]></content><author><name>Xin Dong</name></author><category term="blogs" /><summary type="html"><![CDATA[Hello! It took me some spare time to get this website working as I wanted. After building this website, I decided to write something sometimes. As a Ph.D. student, my supervisors told us that we should practice writing as early as possible. But it’s quite hard to persist with many daily works and tasks. However, writing blogs might be a good way to encourage me.]]></summary></entry></feed>