Unconfigured Ad

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nimrod337
    Member
    • Jun 2013
    • 22

    #1

    Partitioning or slicing up a BAM file

    Okay, I cannot for the life of me find any results on this site, or the internet as a whole about cutting up a BAM file to make a smaller BAM file.

    I want to send a chunk of my BAM file off to a developer because the program I am trying to use is giving me some errors. But he cannot recreate the error without my BAM file. Of course BAM files are huge, so I cannot just email him the whole thing, so I was hoping I could just cut it up, and maybe host a chunk of it on my Dropbox for him to download.

    Anyone have a clue as to how to do this? It doesn't need to be partitioned in a specific way, just reduced in size. I feel like there must be a simple solution out there, but I am in no way an expert, and my google-fu is lacking.

    Thanks
    A
  • GenoMax
    Senior Member
    • Feb 2008
    • 7142

    #2
    http://www.1000genomes.org/faq/how-d...ction-bam-file Change the chromosome range to suite your needs.

    Comment

    • kmcarr
      Senior Member
      • May 2008
      • 1181

      #3
      You can randomly subsample a BAM file with samtools (the view sub-command specifically). I believe this function was added in a later version of samtools but not sure exactly which release; I'm using version 0.1.19-44428cd.

      Code:
      Usage:   samtools view [options] <in.bam>|<in.sam> [region1 [...]]
      
      Options: -b       output BAM
               -h       print header for the SAM output
               -H       print header only (no alignments)
               -S       input is SAM
               -u       uncompressed BAM output (force -b)
               -1       fast compression (force -b)
               -x       output FLAG in HEX (samtools-C specific)
               -X       output FLAG in string (samtools-C specific)
               -c       print only the count of matching records
               -B       collapse the backward CIGAR operation
               -@ INT   number of BAM compression threads [0]
               -L FILE  output alignments overlapping the input BED FILE [null]
               -t FILE  list of reference names and lengths (force -S) [null]
               -T FILE  reference sequence file (force -S) [null]
               -o FILE  output file name [stdout]
               -R FILE  list of read groups to be outputted [null]
               -f INT   required flag, 0 for unset [0]
               -F INT   filtering flag, 0 for unset [0]
               -q INT   minimum mapping quality [0]
               -l STR   only output reads in library STR [null]
               -r STR   only output reads in read group STR [null]
               [COLOR="Red"]-s FLOAT fraction of templates to subsample; integer part as seed [-1][/COLOR]
               -?       longer help
      For example the following command will create file named subSample.bam with a random 1% sample taken from Sample.bam

      Code:
      samtools view -b -o subSample.bam -s 0.01 Sample.bam

      Comment

      • dpryan
        Devon Ryan
        • Jul 2011
        • 3478

        #4
        Just to add to what the others have mentioned, ensure that the subsampled BAM file reproduces the problem. It's never very fun to try and diagnose a problem when you receive a BAM file that can't reproduce it P

        Comment

        • nimrod337
          Member
          • Jun 2013
          • 22

          #5
          Wow, awesome. Thanks you guys.
          This site has really saved my A$$.

          Thanks again.

          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-15-2026, 10:52 AM
          0 responses
          14 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, 10-14-2026, 05:39 AM
          0 responses
          21 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, 10-13-2026, 09:56 AM
          0 responses
          19 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, 10-09-2026, 11:14 AM
          0 responses
          27 views
          0 reactions
          Last Post SEQadmin2  
          Working...