Unconfigured Ad

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Schelarina
    Member
    • Apr 2014
    • 18

    #1

    extracting identical reads from bam file

    Hello,
    I have an alignment file of smallRNAs in bam format.
    How can I extact from this file all the identical reads in a single sequence but mantaining the reads count?
    Thank you for the help!
  • Richard Finney
    Senior Member
    • Feb 2009
    • 701

    #2
    Are you trying to match a specific sequence ?

    samtools view x.bam | grep TTTTCTGCCTGTTGGGCTGGAG | awk '{print $10}' | uniq -c


    All reads with same sequence as another read, try this ...

    samtools view x.bam | awk '{print $10}' | sort --buffer-size=20G | uniq -c | awk '{if ($1!=1) print $0}'


    where x.bam is you bam file.
    fine tune the --buffer-size parameter to sort

    Comment

    • swbarnes2
      Senior Member
      • May 2008
      • 910

      #3
      It would take longer, but swap the second awk in Richard's command line with

      Code:
      sort -nr
      To get the most common reads in order, starting with the most abundant. Tack a

      Code:
      | head -n 100
      to get only the top 100

      Comment

      • Schelarina
        Member
        • Apr 2014
        • 18

        #4
        thank you! it worked!
        can I do the same from a fastq file?

        Comment

        • Richard Finney
          Senior Member
          • Feb 2009
          • 701

          #5
          Yes, you might want to use awk to only print every 4th line.
          Note 1) the "mod" operator and 2) "line count" intrinsic variable in awk.
          Perl/python/C/java if you prefer can address the issue of filtering for only the sequence also.

          Comment

          • Schelarina
            Member
            • Apr 2014
            • 18

            #6
            After I extracted the identical reads in a single sequence from the bam file I aligned them again to the genome. When I use igv to visualize the alignment now all the sequences are mapping in sense orientation.. even those sequences that are supposed to be antisense to the genome are shown in sense orientation. Why is that?

            Comment

            • Richard Finney
              Senior Member
              • Feb 2009
              • 701

              #7
              The sequence for the read in a bam files may be reverse complemented to align to the reference.
              Reads are supposed to be properly noted as reversed in the bitwise flags field in a line/entry of sam/bam.

              You may wish to interrogate this flag for special processing.

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