Unconfigured Ad

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • 1500
    Junior Member
    • Oct 2011
    • 3

    #1

    Filtering bam files by index

    Dear all,

    Is there any possibility to filter bam files by indexes?
    I've create in R a txt file with needed sequences indexes and now I have to extract these sequences and rewrite it as a new bam file.

    Does anybody know if this is possible? Preferably in R or samtools.

    If these is not possible, is there any way to create pileup file with Rsamtools simmilar to samtools mpileup?

    Thanks for any response
  • maubp
    Peter (Biopython etc)
    • Jul 2009
    • 1544

    #2
    Are you aware that 'samtools view' can be called with region information to get a sub-file (SAM or BAM format) containing just the reads mapped in that region? That sounds like what you are asking for.

    Comment

    • StephanL
      Junior Member
      • Jul 2012
      • 1

      #3
      Thank your for your reply, unfortunately this is not what we are looking for.

      Maybe we should make more clear what kind of data we have and what we wish to accomplish.

      We sequenced a short plasmid fragment (50 bp) with a GAx2. We used 100K copies of that plasmid to generate a library and got approx. 1M reads, which we interpret that 1 copy of plasmid yielded 10 clusters on the flow cell that were detected by the sequencer. When we analyzed the reads that mapped to our 50bp reference sequence we found that there are ~190.000 different variants of reads, with ~170.000 variants occuring only 10 or less times. We want to remove those low frequency reads from the BAM file, since we think those are artifacts from PCR, and create a mpileup for future use with Varscan to detect reliable variants of that plasmid.
      So far we created an R script to make an index of those low frequency reads - how can we write a new BAM file without those reads using Rsamtools?

      Thank you
      Stephan

      Comment

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

        #4
        So essentially you have generated a list of about 170,000 read names you want to remove from the BAM file?

        In python I'd create a set object of the unwanted read names, then iterate over the SAM/BAM file in one pass filtering using this set. Python sets are much faster than the typically used list data structure because they use a hash for membership testing, rather than scanning the entire list. You could easily do this with pysam (the Python samtools API wrapper).

        I presume the same basic approach would work just as well in R, but I cannot give you any specific advice there.

        Comment

        • 1500
          Junior Member
          • Oct 2011
          • 3

          #5
          Thank you for Your response, we'll try Python

          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
          38 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, 10-22-2026, 10:48 AM
          0 responses
          28 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, 10-15-2026, 10:52 AM
          0 responses
          41 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...