Unconfigured Ad

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lre1234
    Senior Member
    • Aug 2011
    • 110

    #1

    Sorting a very large bam file

    Hi all,
    I am doing some whole genomes. The samples were done by sequencing 1 sample on all 12 lanes of a solid 5500xl machine. From the output, I aligned each individual lane separately, then merged the 12 bam files together using picardtools mergeSam. This merged bam file is rather large, 200GB in size and has around 2billion sequence reads. My problem is that now I have to sort the file. Any method that I have tried so far has not worked. Samtools fails with an error saying that there are too many files, and picard tools gives an error that it is out of memory. The compute node that I am using has 256GB of memory, so that should be enough. I have even tried increasing the -m flag to 16G in samtools sort. Still not working.

    Any thoughts?

    Thanks
  • GenoMax
    Senior Member
    • Feb 2008
    • 7142

    #2
    Check the output of the
    Code:
    limit
    command to see if you are running into a constraint in user resources. If you are submitting the job using a scheduler (LSF/SGE) then it would be useful to check if the queue you are using has a memory limit (per job/user)?

    Comment

    • Richard Finney
      Senior Member
      • Feb 2009
      • 701

      #3
      Use as much memory as you can. Set it to 240 GB or so if you have 256 and nothing else is running. Make sure you are using the -m parameter properly.
      The line to parse the -m arg is

      case 'm': max_mem = atol(optarg); break;

      There's no "16GB" , it's got to be 16000000000 (if I counted the zeros right).

      Comment

      • lh3
        Senior Member
        • Feb 2008
        • 686

        #4
        More recent versions parse "16G". 0.1.18 definitely does not.

        Comment

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

          #5
          It might be worth presorting the 12 individual BAM files before merging, that should make the final sort quicker.

          (The extra IO might overall be slower)

          Comment

          • lre1234
            Senior Member
            • Aug 2011
            • 110

            #6
            So, my 12 original files were all pre-sorted before merging, but I did manage to get the file sorted.

            Originally, I was using samtools 0.1.18, and with the sort command I set the -m flag to 16000000000. This took ~12 hrs to finish.

            After updating to samtools 0.1.19 and using the sort command with -m 2G and -@ 32, the file sorted in about 4hrs...

            Much improvement

            Comment

            Latest Articles

            Collapse

            • kinpict.com
              Reply to 16S/ITS Profiling vs. Shotgun Metagenomics: What Changes in Your Workflow?
              by kinpict.com
              The part about this topic feels surprisingly grounded, and the details on the page is the bit that made me slow down. I’d keep <a href="https://kinpict.com/">ai family photo generator</a> bookmarked for later.
              Today, 06:37 PM
            • 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, 11-12-2026, 07:59 AM
            0 responses
            27 views
            0 reactions
            Last Post SEQadmin2  
            Started by SEQadmin2, 11-05-2026, 09:25 AM
            0 responses
            35 views
            0 reactions
            Last Post SEQadmin2  
            Started by SEQadmin2, 11-03-2026, 11:54 AM
            2 responses
            56 views
            0 reactions
            Last Post kinpict.com  
            Started by SEQadmin2, 10-28-2026, 09:57 AM
            0 responses
            175 views
            0 reactions
            Last Post SEQadmin2  
            Working...