Unconfigured Ad

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ronton
    Member
    • Jun 2014
    • 34

    #1

    Sort/create list of locations with highest # of reads?

    Hello,

    Hopefully there is a simple way to do this that I am unaware of.

    I have fastq and bam files (100bp paired end Illumina). In the alignment files there are lots of areas with one or a few reads spread throughout the genome.

    What I would like to do is either sort results to visualize, for example in Integrative Genomics Viewer, or generate a list that will show in descending order the locations that have the greatest number of reads or the greatest coverage. This would most likely be within a window, say 50bp.

    For example:

    chr21:33,031,597 has 58 reads
    chr21:33,031,200 has 56 reads
    chr21:33,025,000 has 42 reads

    and so on.

    Any advice or guidance on different ways I might achieve this is very appreciated.

    Thank you
  • Richard Finney
    Senior Member
    • Feb 2009
    • 701

    #2
    Check out samtools ...

    $ samtools depth

    Usage: samtools depth [options] in1.bam [in2.bam [...]]
    Options:
    -b <bed> list of positions or regions
    -f <list> list of input BAM filenames, one per line [null]
    -l <int> minQLen
    -q <int> base quality threshold
    -Q <int> mapping quality threshold
    -r <chr:from-to> region

    Example:
    $ samtools depth -r chr1:1-100000 1221792.bam | head
    chr1 10033 1
    chr1 10034 1
    chr1 10035 1
    chr1 10036 1
    chr1 10037 1
    chr1 10038 1
    chr1 10039 1
    chr1 10040 1
    chr1 10041 1
    chr1 10042 1


    Use "awk" to filter on column 3 and "sort" on column 3 and "tail" it.
    Like this ...
    samtools depth 1221792.bam | awk '{if ($3>300) print $0}' | sort -k3n | tail
    Last edited by Richard Finney; 06-06-2014, 06:43 AM.

    Comment

    • ronton
      Member
      • Jun 2014
      • 34

      #3
      Thanks so much Richard,

      So if I use:

      samtools depth 1221792.bam | awk '{if ($3>50) print $0}' | sort -k3n | tail

      for example, this will give me a list of all locations with more than 50 reads, correct?

      But no 'window,' or in other words, it will likely print the individual locations for each block of reads, rather than one result for each bin or chunk of 50 bases or something like that. Meaning, at chr1 10038 +/- 25bp, there are max 50 reads.

      Certainly a start, thank you for the help.

      Comment

      • swbarnes2
        Senior Member
        • May 2008
        • 910

        #4
        Code:
        samtools view -F 4 sorted.bam | cut -f 3,4 | uniq -c | sort -nr | head -n 20 > most_common.txt
        That'll give you the top 20 most common start sites for your reads.

        Comment

        Latest Articles

        Collapse

        • SEQadmin2
          The Factors Reshaping Genome Assembly
          by SEQadmin2



          When the Human Genome Project declared the human genome finished in 2003, portions of the sequence were still missing, including many of its most repetitive and structurally complex regions.1 Still, for the next two decades, researchers analyzed their sequencing data against the single linear reference that came out of this effort. Released in 2013 as GRCh38, that reference has powered countless discoveries, but it has gaps and cannot capture the genetic diversity of the world’s...
          Today, 07:04 AM
        • 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, Yesterday, 11:11 AM
        0 responses
        14 views
        0 reactions
        Last Post SEQadmin2  
        Started by SEQadmin2, 11-17-2026, 06:27 AM
        0 responses
        39 views
        0 reactions
        Last Post SEQadmin2  
        Started by SEQadmin2, 11-12-2026, 07:59 AM
        0 responses
        55 views
        0 reactions
        Last Post SEQadmin2  
        Started by SEQadmin2, 11-05-2026, 09:25 AM
        0 responses
        61 views
        0 reactions
        Last Post SEQadmin2  
        Working...