SEQanswers

Go Back   SEQanswers > Bioinformatics > Bioinformatics



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to convert sorted.txt files from the Illumina pipeline v1.3.4 to bam or sam? crazyhottommy Bioinformatics 7 04-20-2015 06:54 AM
convert sorted bam to sorted sam for htseq-count ugolino Bioinformatics 3 10-19-2012 06:30 AM
badly sorted BAM Filippo Bioinformatics 3 12-29-2011 12:39 PM
How to get all contig boundaries from a sorted bam file dustar1986 Bioinformatics 3 09-30-2011 12:31 AM
Sorted bam wangzkai Bioinformatics 3 05-07-2010 01:37 AM

Reply
 
Thread Tools
Old 06-05-2013, 04:25 AM   #1
plumb_r
Junior Member
 
Location: London

Join Date: Nov 2012
Posts: 6
Default Smatools mpileup thinks my sorted bam files are not sorted

Hi
I am trying to run samtools mpileup on a large list of bam files
Code:
samtools mpileup -d 5000 -f /path/to/ref.fa \
/path/to/first.bam \
/path/to/second.bam \
| gzip > output.piledup
However, I get a log file which features a list saying
Code:
[bam_pileup_core] the input is not sorted (reads out of order
[bam_pileup_core] the input is not sorted (chromosomes out of order)
Corresponding, to each of my original input bam files and then a further list of
Code:
[bam_plp_destroy] memory leak: 2. Continue anyway.
With a line for each input file.
I have definitely used the samtools sort command to sort these files prior to using mpileup. However, if I use:
Code:
samtools view -H sorted.bam
I still get a header of @HD VN:1.0 SO:unsorted
So my questions are:
  • Are my "sorted" bam files actually sorted?
  • If they are not, how can I sort them if samtools sort doesn't seem to sort them?
  • If they are sorted where else could the error be?
These bam files were intially aligned using bwa and converted from sam to bam with bwa
Thanks in advance for any help
plumb_r is offline   Reply With Quote
Old 06-05-2013, 06:49 AM   #2
dnusol
Senior Member
 
Location: Spain

Join Date: Jul 2009
Posts: 133
Default

You could try Picard's SortSam.

HTH
dnusol is offline   Reply With Quote
Old 06-05-2013, 08:20 AM   #3
maubp
Peter (Biopython etc)
 
Location: Dundee, Scotland, UK

Join Date: Jul 2009
Posts: 1,542
Default

What version of samtools do you have? Older versions of samtools never bothered to update the @HD line during 'samtools sort'.
maubp is offline   Reply With Quote
Old 06-05-2013, 08:32 AM   #4
plumb_r
Junior Member
 
Location: London

Join Date: Nov 2012
Posts: 6
Default

0.1.18
I found an old thread which seemed to suggest that the @HD line might be being left as saying unsorted by samtools.
Is the mpileup totally dependent on this line saying unsorted or sorted?
plumb_r is offline   Reply With Quote
Old 06-07-2013, 03:00 AM   #5
plumb_r
Junior Member
 
Location: London

Join Date: Nov 2012
Posts: 6
Default

For the benefit of closing this thread: the files sorted successfully with Picard SortSam. I have no idea why they wouldn't sort with samtools
plumb_r is offline   Reply With Quote
Old 03-18-2014, 09:05 AM   #6
ksw9
Member
 
Location: US

Join Date: May 2013
Posts: 31
Default

Hi,
I am having a similar problem using samtools phase on sorted and indexed BAM files and I keep getting the errors:

[bam_pileup_core] the input is not sorted (reads out of order)
[bam_plp_destroy] memory leak: 19. Continue anyway.

My bam file is sorted. I have also tried to use Picard SortSam, but get the error:
Error: Unable to access jarfile INPUT=Sample_Bbcap31_L002.bam

Does anyone have advice on how to proceed? Thank you!
ksw9 is offline   Reply With Quote
Old 04-28-2014, 08:22 AM   #7
rkizen
Member
 
Location: Edinburgh

Join Date: Jun 2013
Posts: 20
Default

I was having the same problem with mpileup not recognizing that my bam file was sorted. I had tried sorting with samtools and with picardtools but neither seemed to solve the problem.

For my case it appears that the issue was that one read pair had a read mapping at the very beginning of the contig and the other read not mapping. These were on the reverse strand. This meant that the first two reads are shown with a coordinate of 0. I am not sure what is causing the error exactly but removing this pair of reads resolves the issue.

Perhaps someone else has seen this as well?

Version is 1.18
rkizen is offline   Reply With Quote
Reply

Tags
bam files, bwa, samtools, sort

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off




All times are GMT -8. The time now is 05:42 PM.


Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Single Sign On provided by vBSSO