Sign inSign up

koszullab/metator

By koszullab

•Updated about 5 years ago

Metagenomic binning based on Hi-C data

Image
1

10K+

koszullab/metator repository overview

⁠MetaTOR

PyPI version PyPI - Python Version Build Status codecov Docker Cloud Build Status Read the docs License: GPLv3 Code style: black

Metagenomic Tridimensional Organisation-based Reassembly - A set of scripts that streamlines the processing and binning of metagenomic metaHiC datasets.

⁠Table of contents

⁠Installation

⁠Requirements
  • Python 3.6 or later is required.
  • The following librairies are required but will be automatically installed with the pip installation: numpy, scipy, sklearn, pandas, docopt, networkx biopython pyfastx and pysam.
  • The following software should be installed separately if you used the pip installation:
⁠Using pip
   pip3 install metator

or, to use the latest version:

   pip3 install -e git+https://github.com/koszullab/metator.git@master#egg=metator

In order to use Louvain or Leiden it's necessary to set a global variable LOUVAIN_PATH and LEIDEN_PATH depending on which algorithm you wan to use with the absolute path where the executable are.

For Louvain algorithm in the directory where you have the archive file (available in the external directory of this repository):

YOUR_DIRECTORY=$(pwd)
tar -xvzf louvain-generic.tar.gz
cd gen-louvain
make
export LOUVAIN_PATH=$YOUR_DIRECTORY/gen-louvain/

For Leiden algorithm, clone the networkanalysis repository from github and build the Java script. Then you can export the Leiden path:

export LEIDEN_PATH=/networkanalysis_repository_path/build/libs/networkanalysis-1.2.0.jar
⁠Using docker container

A dockerfile is also available if that is of interest. You may fetch the image by running the following:

    docker pull koszullab/metator

⁠Usage

    metator {network|partition|validation|pipeline} [parameters]

A metaTOR command takes the form metator action --param1 arg1 --param2 arg2 #etc.

There are three actions/steps in the metaTOR pipeline, which must be run in the following order:

  • network : Generate metaHiC contigs network from fastq reads or bam files and normalize it.

  • partition : Perform the Louvain or Leiden community detection algorithm many times to bin contigs according to the metaHiC signal between contigs.

  • validation : Use CheckM to validate the bins, then do a recursive decontamination step to remove contamination.

There are a number of other, optional, miscellaneous actions:

  • pipeline : Run all three of the above actions sequentially or only some of them depending on the arguments given. This can take a while.

  • contactmap : Generates a contact map from one bin from the final ouptut of metaTOR.

  • version : display current version number.

  • help : display help message.

A tutorial is available here⁠ to explain how to use metaTOR. More advanced tutorials to analyze the output files are also available:

  • Anvio⁠ manual curation of the contaminated bins. Available here⁠.
  • Visualization and scaffolding of the MAGs with the contactmap modules of MetaTOR. Available here⁠.

Principle of MetaTOR pipeline:

metator_pipeline

⁠Output files

The output files will be in the ouput directory given as parmater or in working directory if no paramater were given. Depending on the command used, different files will be in the ouptut:

Files/Commandsdescriptionnetworkpartitionvalidationpipeline
alignment_N_for.bamBam file of the forward alignmentXX
alignment_N_rev.bamBam file of the reverse alignmentXX
alignment_N.pairsPairs of the merge alignmentXX
network.txtNormalized network of the metaHiC libraryXX
contig_data_network.txtInformation on contigs after network stepX
clustering_matrix_partition.txtMatrix of clustering from the partition iterationsX
contig_data_partition.txtInformation on contigs after partition stepX
overlapping_checkm_results.txtCheckM results summary file from the partition stepXX
overlapping_checkm_taxonomy.txtCheckM taxonomy file from the partition stepXX
recursive_checkm_results.txtCheckM results summary file from the recursive stepXX
recursive_checkm_taxonomy.txtCheckM taxonomy file from the recursive stepXX
clustering_matrix_validation.txtMatrix of clustering from the recursive iterationsX
clustering_matrix.txtMatrix of clustering from the partition and recursive iterationsX
contig_data_final.txtInformation on contigs after whole pipelineXX
bin_summary.txtInformation on the final binsXX
binning.txtFile with contigs names and their final clusteringXX
overlapping_binDirectory with the fasta of the partition binsXXX
recursive_binDirectory with the fasta of the recursive binsXX
final_binDirectory with the fasta of the final binsXX

Bam alignment files For the bam alignments files, only the aligned reads are kept and the bam are sorted by name. The N value correspond to the id (order of the given fastq started at 0)

Pairs aligment files This format is used to store the relevant information of mapping of the merged alignment. It's a s The N value correspond to the id (order of the given fastq started at 0). It is a tab-separated format holding informations about Hi-C pairs. It has an official specification⁠ defined by the 4D Nucleome data coordination and integration center. Here we kept 7 columns readID-chr1-pos1-chr2-pos2-strand1-strand2.

Network file This is a tsv file of the network with edgelist form: Id of the first contig, id of the second contig and the weigth of edge normalized.

Contig data files These are the files with all the informations from the contigs:

IDNameSizeGC_contentHitShotgun_coverageRestriction_siteCore_bin_IDCore_bin_contigsCore_bin_sizeOverlapping_bin_IDOverlapping_bin_contigsOverlapping_bin_sizeRecursive_bin_IDRecursive_bin_contigsRecursive_bin_sizeFinal_bin
1NODE_164231138.6876450815882383741.156520061652175226139663223531522158803MetaTOR_1_1
2NODE_257635630.235826468363303172424.5091256240173541924017354190--MetaTOR_2_0
3NODE_354057142.305266098255366218814.585534053127640948434311361548011126385126MetaTOR_3_1

They have to have the header when they are use as input but the order of the columns nd if they are others columns doesn't matter when they are used as input files. Depending on which step of the pipeline have been launch they just have some of these columns:

  • contig_data_network.txt: columns: ID, Name, Size, GC content, Hit, Shotgun_coverage and Restriction Site only.
  • contig_data_partition.txt: The same as the previous with the information of core bins and overlapping bins.
  • contig_data_final.txt: All the columns.

The shotgun coverage will be filled only if the depth.txt file is given, otherwise it will be filled with -. This column is only necessarry for the abundance and the theoritical_hit normalization. The restriction will also be filled with - if no enzyme are given. This column is only necessary for the RS and the theoritical_hit normalization. Moreover, if the contig is not binned (no HiC reads mapped on it) all the columns with binning information will be filled with -, and if a bin is not recursively decontamined because it's smaller than the size threshold or it doesn't have any contamination the recusive bin information will be filled 0, -, -. Finally, if the bin is not in a final bin, it will be annotated ND in the last column (for not determined).

clustering matrix files The clustering matrix files are at the .npz format which is a compresed foramt for sparsed matrix. This sparsed matrix contains the ratio of time each pairs of contigs are clusterize together by the algorithm of clustering (either Louvain or Leiden). The partition matrix contains the information for the partition step, the recursive one for the recursive step and the general one is the mean of both matrices. Be careful the index of the contigs are zero-based and not one-based as in the contig data file.

It's possible to read them in python using the scipy.sparse.load_npz() function. If the users wants a tsv file instead, he or she could load the matrix in python using load_npz and make sure to transform the matrix in the scipy.sparse.coo_matrix function and used the function from metator metator.io.save_sparse_matrix to save it as tsv file.

CheckM results Files from checkM⁠ output. Two types of files one with the main results of checkM checkm_results.txt and one with the taxonomy checkm_taxonomy.txt for both the partition and the recurisve bins.

binning.txt file This is a tsv file with two columns: the contig name and the final were the contig is. It only contains contigs which are binned. It could be use a an input to import a binning results in anvio.

Bin summary file This is the summary of the data of the final bins build with all the step of metaTOR. The HiC coverage is the number of contacts (intra and inter contigs) per kilobase in the whole bin. The Shotgun coverage is the mean coverage normalized by the size of the shotgun reads from the depth file.

lineagecompletnesscontaminationsizecontigsN50longest_contigGCcoding_densitytaxonomyCoverage
MetaTOR_8_1o__Clostridiales68.292.4614316121511612929162026.3687.97k__Bacteria;p__Firmicutes;c__Clostridia;o__Clostridiales146.46719755483332
MetaTOR_8_2o__Clostridiales58.422.011396934584129017468228.8983.70k__Bacteria;p__Firmicutes;c__Clostridia;o__Clostridiales22.252416224710686
MetaTOR_8_3o__Clostridiales49.370.94142082182330958996430.2983.24k__Bacteria;p__Firmicutes;c__Clostridia;o__Clostridiales;f__Peptostreptococcaceae_3;g__Clostridium_344.27369196532141

⁠References

⁠Contact

⁠Authors
⁠Research lab

Spatial Regulation of Genomes⁠ (Institut Pasteur, Paris)

Tag summary

Content type

Image

Digest

Size

1.3 GB

Last updated

about 5 years ago

docker pull koszullab/metator