Unconfigured Ad

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • genomeHunter
    Member
    • Apr 2013
    • 26

    Fast BAM sorting

    Hello,

    I have lots of unsorted BAM files and the sorting process is very slow. One solution I could think of was to run multiple instances of samtools:

    cat files.txt | xargs -n 1 -P $num_threads samtools sort

    The problem is that this method is I/O bound. Are there any (free) faster alternatives?

    Should I try novosort?

    Cheers
    GH
  • Heisman
    Senior Member
    • Dec 2010
    • 534

    #2
    Are you aware you can use samtools sort with multiple threads with the "-@" option?

    Comment

    • GenoMax
      Senior Member
      • Feb 2008
      • 7142

      #3
      If you are doing this on a cluster (with a storage subsystem that can support multiple I/O streams) Heisman's solution will work.

      If you are I/O bound on a single server then your only option is patience.
      Last edited by GenoMax; 07-19-2013, 11:58 AM.

      Comment

      • genomeHunter
        Member
        • Apr 2013
        • 26

        #4
        Originally posted by Heisman View Post
        Are you aware you can use samtools sort with multiple threads with the "-@" option?
        No, I was not. I saw the "-@" option in a fork of samtools, I guess it was called samtools-mt. I did not know it was added to samtools.

        Thanks,
        GH

        Comment

        • genomeHunter
          Member
          • Apr 2013
          • 26

          #5
          Originally posted by GenoMax View Post
          If you are doing this on a cluster (with a storage subsystem that can support multiple I/O streams) Heisman's solution will work.

          If you are I/O bound on a single server then your only option is patience.
          I tried it on a moderate-sized BAM file and it was not very fast on our mini-server (32 Cores and RAID-6 disk). I guess I will be using xargs :-)

          Cheers,
          GH

          Comment

          • Richard Finney
            Senior Member
            • Feb 2009
            • 701

            #6
            Please note the -m parameter for samtools sort , this is the amount of memory to use.
            Using available memory will speed up thing. This also works for novocraft's novosort. You may also wish to copy to a fast disk for any temp files that spill to disk.

            Comment

            • genomeHunter
              Member
              • Apr 2013
              • 26

              #7
              Originally posted by Richard Finney View Post
              Please note the -m parameter for samtools sort , this is the amount of memory to use.
              Using available memory will speed up thing. This also works for novocraft's novosort. You may also wish to copy to a fast disk for any temp files that spill to disk.
              Thanks. I am using 4GB/threads and 16 threads. Our main disk is a 12-disk RAID-6 arrays with enterprise-level HDDs.

              Do you know how does samtools sort compare to SortSam and NovoSort?

              Cheers,
              GH

              Comment

              • GenoMax
                Senior Member
                • Feb 2008
                • 7142

                #8
                Originally posted by genomeHunter View Post
                Our main disk is a 12-disk RAID-6 arrays with enterprise-level HDDs.

                Cheers,
                GH
                How is it connected to the server: 6 Gbps SAS/8 Gbps Fiber Channel HBA?

                Comment

                • genomeHunter
                  Member
                  • Apr 2013
                  • 26

                  #9
                  Originally posted by GenoMax View Post
                  How is it connected to the server: 6 Gbps SAS/8 Gbps Fiber Channel HBA?
                  I am not 100% sure but it must be 6 Gbps SAS.

                  GH

                  Comment

                  • lh3
                    Senior Member
                    • Feb 2008
                    • 686

                    #10
                    Multi-threading is available in the released package. Novosort is faster than samtools.

                    Comment

                    • genomeHunter
                      Member
                      • Apr 2013
                      • 26

                      #11
                      Originally posted by lh3 View Post
                      Multi-threading is available in the released package. Novosort is faster than samtools.
                      Do you have any rough speedup factors? I tried

                      samtools view -buS exp.sam | samtools sort -@ 16 -m 4G - sorted

                      And it takes 10 minutes for a moderate size SAM file.

                      Cheers,
                      GH

                      Comment

                      • GenoMax
                        Senior Member
                        • Feb 2008
                        • 7142

                        #12
                        GH: Here are some systems tools to check if any hardware bottlenecks exist on your system. Start with the "iostat": http://www.thegeekstuff.com/2011/07/...stat-examples/

                        Comment

                        Latest Articles

                        Collapse

                        • SEQadmin2
                          Advanced Sequencing Platforms Tackle Neuroscience’s Toughest Genomics Problems
                          by SEQadmin2



                          Genomics studies in neuroscience face a special challenge due to the brain’s complexity and scarcity of samples. Mapping changes in cell type and state using conventional next-generation sequencing methods remains challenging. Advances in technologies like single-cell sequencing, spatial transcriptomics, and long-read sequencing have opened the door to deeper studies of the brain and diseases like Alzheimer’s, amyotrophic lateral sclerosis (ALS), and schizophrenia.
                          ...
                          07-09-2026, 11:10 AM
                        • SEQadmin2
                          Cancer Drug Resistance: The Lingering Barrier to Rising Survival
                          by SEQadmin2



                          Cancer survival rates have significantly increased in the last few decades in the United States, reaching a combined 70% 5-year survival rate by 2021. Behind this number, there are years of research to find new therapies, drug targets, and early detection methods. But there is one core challenge that keeps slowing down these advances, and it’s about drug resistance.

                          There is no single reason why many patients don’t respond to treatment as expected. Cancer is...
                          07-08-2026, 05:17 AM
                        • GATTACAT
                          Reply to Nine Things a Sample Prep Scientist Thinks About Before Sequencing
                          by GATTACAT
                          Love this - good data definitely starts from good input, and poor input can only give relatively poor data. I particularly like the mention of Nanodrop/absorbance based methods for quantification. It's such a toss up if you'll get an accurate reading or what amounts to a randomly generated number, and a lot of library/sequencing related issues can be traced back to poor quant.
                          07-01-2026, 11:43 AM

                        ad_right_rmr

                        Collapse

                        News

                        Collapse

                        Topics Statistics Last Post
                        Started by SEQadmin2, 07-13-2026, 10:26 AM
                        0 responses
                        22 views
                        0 reactions
                        Last Post SEQadmin2  
                        Started by SEQadmin2, 07-09-2026, 10:04 AM
                        0 responses
                        32 views
                        0 reactions
                        Last Post SEQadmin2  
                        Started by SEQadmin2, 07-08-2026, 10:08 AM
                        0 responses
                        20 views
                        0 reactions
                        Last Post SEQadmin2  
                        Started by SEQadmin2, 07-07-2026, 11:05 AM
                        0 responses
                        34 views
                        0 reactions
                        Last Post SEQadmin2  
                        Working...