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
                The Factors Reshaping Genome Assembly
                by SEQadmin2



                When the Human Genome Project declared the human genome finished in 2003, portions of the sequence were still missing, including many of its most repetitive and structurally complex regions.1 Still, for the next two decades, researchers analyzed their sequencing data against the single linear reference that came out of this effort. Released in 2013 as GRCh38, that reference has powered countless discoveries, but it has gaps and cannot capture the genetic diversity of the world’s...
                Today, 07:04 AM
              • SEQadmin2
                16S/ITS Profiling vs. Shotgun Metagenomics: What Changes in Your Workflow?
                by SEQadmin2





                NGS has revolutionized clinical microbiology by offering new ways to identify and surveil pathogens without prior knowledge of the target. One popular approach is 16S rRNA and ITS amplicon sequencing, which targets specific microbial markers. But studies are increasingly incorporating shotgun metagenomics, a technique that sequences all DNA from a sample without targeting specific microbial markers. This approach allows more detailed taxonomic classification,...
                10-30-2026, 06:46 AM

              ad_right_rmr

              Collapse

              News

              Collapse

              Topics Statistics Last Post
              Started by SEQadmin2, Yesterday, 11:11 AM
              0 responses
              14 views
              0 reactions
              Last Post SEQadmin2  
              Started by SEQadmin2, 11-17-2026, 06:27 AM
              0 responses
              39 views
              0 reactions
              Last Post SEQadmin2  
              Started by SEQadmin2, 11-12-2026, 07:59 AM
              0 responses
              55 views
              0 reactions
              Last Post SEQadmin2  
              Started by SEQadmin2, 11-05-2026, 09:25 AM
              0 responses
              61 views
              0 reactions
              Last Post SEQadmin2  
              Working...