# Binning a Metagenomic Assembly¶

A common approach following metagenome assembly is binning, a process by which assembled contigs are collected into groups or ‘bins’ that might then be assigned some taxonomic affiliation. There are many different tools that can be used for binning (see CAMI review for more details). Here, we will be using MaxBin and MetaBAT, which are both user friendly and highly cited. To use these binners, we will first need to map our data against the assembled metagenome using bwa and then estimate relative abundances by contig. We will then inspect the bins generated by MaxBin and MetaBAT using VizBin.

## Installing binners¶

MaxBin

cd
tar xzvf MaxBin-2.2.2.tar.gz
cd MaxBin-2.2.2/src
make
cd
git clone https://github.com/COL-IU/FragGeneScan.git
cd FragGeneScan
make clean
make fgs
cd
git clone https://github.com/loneknightpy/idba.git
cd idba
./build.sh
sudo apt-get install bowtie2 hmmer
export PATH=$PATH:~/idba/bin export PATH=$PATH:~/FragGeneScan
sed -e "/^>/ s/$/${num}/" mbin.$num.fasta >> maxbin_binned.concat.fasta done  And finally make an annotation file for visualization echo label > maxbin_annotation.list grep ">" maxbin_binned.concat.fasta |cut -f2 -d ' '>> maxbin_annotation.list  ## Binning 2 - MetaBAT¶ MetaBAT uses read coverage, coverage variance, & tetranucleotide frequencies for each contig. This is done with a custom script cd ~/binning mkdir metabat cd metabat ln -fs ~/mapping/*abundtrim*sorted.bam . ~/metabat/jgi_summarize_bam_contig_depths --outputDepth depth_var.txt *bam  Run MetaBAT script Note that we are outputting info to a logfile ~/metabat/metabat -i ~/mapping/subset_assembly.fa -a depth_var.txt --verysensitive -o metabat -v > log.txt  Make the .fasta file of all binned sequences for file in metabat.*.fa do num=${file//[!0-9]/}
sed -e "/^>/ s/$/${num}/" metabat.\$num.fa >> metabat_binned.concat.fasta
done


Make an annotation file of the bin numbers for annotation in VizBin

echo label > metabat_annotation.list
grep ">" metabat_binned.concat.fasta |cut -f2 -d ' '>> metabat_annotation.list


## Visualizing the bins¶

Now that we have our binned data from both MetaBAT and MaxBin there are several different things we can do. One thing we might want to do is check the quality of the binning– a useful tool for this is CheckM. Today, for the sake of time, we will visualize the bins that we just generated using VizBin.

First, install VizBin::

cd
sudo apt-get install libatlas3-base libopenblas-base default-jre
curl -L https://github.com/claczny/VizBin/blob/master/VizBin-dist.jar?raw=true > VizBin-dist.jar


VizBin can run in OSX, Linux, and Windows but is has specific Java requirements (> 7.0).

## Optional¶

To simplify things we are going to run VizBin in the desktop emulator through JetStream (which is ... a bit clunky). So, go back to the Jetstream and open up the web desktop simulator.

Open the terminal through the desktop simulator and open VizBin:

java -jar VizBin-dist.jar


This should prompt VizBin to open in another window. First we will look at the output of the MaxBin assembly. Click the choose button to open file browser to navigate to the binning folder (~/mapping/binning). There you will find the concatenated binned fasta file (maxbin_binned.concat.fasta). Upload this file and hit run.

What do you see? Read up a bit on VizBin to see how the visualization is generated.

Now, upload the maxbin_annotation.list file as an annotation file to VizBin. The annotation file contains the bin id for each of the contigs in the assembly that were binned.

Now, do the same for MetaBat!

Compare the results of the two binning methods-

• How many bins were found?
• How distinct are the bins?

LICENSE: This documentation and all textual/graphic site content is released under Creative Commons - 0 (CC0) -- fork @ github.