Unconfigured Ad

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • plumb_r
    Junior Member
    • Nov 2012
    • 6

    #1

    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
  • dnusol
    Senior Member
    • Jul 2009
    • 136

    #2
    You could try Picard's SortSam.

    HTH

    Comment

    • maubp
      Peter (Biopython etc)
      • Jul 2009
      • 1544

      #3
      What version of samtools do you have? Older versions of samtools never bothered to update the @HD line during 'samtools sort'.

      Comment

      • plumb_r
        Junior Member
        • Nov 2012
        • 6

        #4
        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?

        Comment

        • plumb_r
          Junior Member
          • Nov 2012
          • 6

          #5
          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

          Comment

          • ksw9
            Member
            • May 2013
            • 32

            #6
            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!

            Comment

            • rkizen
              Member
              • Jun 2013
              • 20

              #7
              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

              Comment

              Latest Articles

              Collapse

              • SEQadmin2
                Multiomic Liquid Biopsy: What DNA/RNA Panels Reveal That DNA Alone Can’t
                by SEQadmin2



                Tumors contain complex mixtures of cell populations that evolve in response to treatment and host-specific factors. Tissue biopsies provide only static snapshots of a tumor’s state. But what if we could follow that evolution over time using a minimally invasive technique?

                Liquid biopsies can detect tumor-derived material circulating in the bloodstream, providing a way to study treatment response, detect emerging resistance, and discover new biomarkers. Circulating
                ...
                10-14-2026, 09:55 AM
              • SEQadmin2
                New Genomics Technologies Take Aim at Long-Standing Limits
                by SEQadmin2


                Researchers using sequencing and genomics tools often have to make trade-offs. They can choose between speed or scale, short reads or long-range information, or targeted panels or a view of the whole transcriptome. New technologies that have been released this year are built to address those tough choices.

                We asked six companies the same four questions to learn about their latest products. The new technologies bring a lot to the table, including rethinking sequencing
                ...
                09-28-2026, 10:25 AM

              ad_right_rmr

              Collapse

              News

              Collapse

              Topics Statistics Last Post
              Started by SEQadmin2, 10-22-2026, 11:13 AM
              0 responses
              42 views
              0 reactions
              Last Post SEQadmin2  
              Started by SEQadmin2, 10-22-2026, 10:48 AM
              0 responses
              32 views
              0 reactions
              Last Post SEQadmin2  
              Started by SEQadmin2, 10-15-2026, 10:52 AM
              0 responses
              44 views
              0 reactions
              Last Post SEQadmin2  
              Started by SEQadmin2, 10-14-2026, 05:39 AM
              0 responses
              45 views
              0 reactions
              Last Post SEQadmin2  
              Working...