This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Metabat2 shows error

Hello,

I am trying to perform binning with metabat2 but it is showing error ' the order of contigs in abundance file is not the same as the assembly file: k141_5762'.

I first sorted my BAM file (base) pbaranw@enggpz1p23:~/parul/output$ samtools sort mapped.bam -o sorted.bam

I checked if BAM files is sorted (base) pbaranw@enggpz1p23:~/parul/output$ samtools view -H sorted.bam

@HD VN:1.4 SO:coordinate

*I generated the depth file* (base) pbaranw@enggpz1p23:~/parul/output$ jgi_summarize_bam_contig_depths --outputDepth depth.txt sorted.bam Output depth matrix to depth.txt jgi_summarize_bam_contig_depths v2.15-6-g8b5702b 2021-10-17T15:10:38 Output matrix to depth.txt 0: Opening bam: sorted.bam Processing bam files WARNING: your aligner reports an incorrect NM field. You should run samtools calmd! nm < ins + del: cmatch=0 nm=2 ( insert=0 + del=60 + mismatch=2 == 62) A00405:433:HHYFCDSX2:3:1176:5321:1376 1:N:0:ACGATCAG+ACGGAACA Thread 0 finished: sorted.bam with 15775901 reads and 14529494 readsWellMapped Creating depth matrix file: depth.txt Closing most bam files Closing last bam file Finished

The codes for metabat2 I ran is: (base) pbaranw@enggpz1p23:~/parul/output$ metabat2 -i final.contigs.fa -a depth.txt -o bins

MetaBAT 2 (v2.15-6-g8b5702b) using minContig 2500, minCV 1.0, minCVSum 1.0, maxP 95%, minS 60, maxEdges 200 and minClsSize 200000. with random seed=1643665071 [Error!] the order of contigs in abundance file is not the same as the assembly file: k141_5762

Please any help. Thank you so much

metabat

1 answer

The problem is with this command:

jgi_summarize_bam_contig_depths --outputDepth depth.txt sorted.bam

In order to sort the contigs properly, it needs to know the assembly FASTA file from which the .BAM file was created. Like so:

jgi_summarize_bam_contig_depths --outputDepth depth.txt --referenceFasta assembly.fa sorted.bam

The rest should work once you fix the depth file.

Thank you for quick reply.

I tried running this command but still error is showing

jgi_summarize_bam_contig_depths --outputDepth depth.txt --referenceFasta final.contigs.fa sorted.bam

I get following result:

Output depth matrix to depth.txt Reference fasta file final.contigs.fa jgi_summarize_bam_contig_depths v2.15-6-g8b5702b 2021-10-17T15:10:38 Output matrix to depth.txt Reading reference fasta file: final.contigs.fa ... 6008 sequences 0: Opening bam: sorted.bam Error: referenceFile: final.contigs.fa contig 0 is not the same as in the bam headers (bam reports k141_502 flag=1 multi=2.0000 len=306 with 306 len, reference loaded k141_4762 with 313 len)!

I created the BAM file with following code. should I use referenceFasta as g1_trimmed.fastq

bbmap.sh in= g1_trimmed.fastq out=mapped.bam

You need to map the reads to the same assembly file that will later be used by jgi_summarize_bam_contig_depths:

bbmap.sh ref=final.contigs.fa in=g1_trimmed.fastq out=mapped.bam nodisk

Next steps are to sort the files ( samtools sort mapped.bam -o sorted.bam ) and repeat the commands for depth file creation and metabat2.

Thank you so much. It worked for me. However, three bins are created. As I am working with one sample (i.e forward and reverse read of one pure bacterial culture), I should get only one bin (Please correct me if I am wrong). Does creation of 3 bins shows the sign of contamination.

Any help appreciated.

Don't know why you were even binning the contigs coming from a single-species assembly, but apparently that is something worth doing.

Yes, you should get a single bin, with some caveats:

  • that your culture is truly pure
  • that your bacterium doesn't have an intracellular parasite
  • that you have removed contigs smaller than at least 1.5 kb, and it may be worth going up to 2 kb
  • that this bacterium doesn't have plasmids or other extrachromosomal DNA elements
  • that this bacterial genome does not have any funky repeats, pathogenic islands, or other sequence regions of different sequence properties from the rest of genome
  • that you have done binning properly

Thank you so much for your explanation.

Log in to answer this question.