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

          • 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...