Unconfigured Ad

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • apredeus
    Senior Member
    • Jul 2012
    • 151

    #1

    Making a Constant-Step bedGraph File

    Hello all,

    I have two questions about making a bedGraph from an alignment file (bam or sam). I've used "bedtools genomecov" and then "bedtools map" (using a 200bp genome-wide "windows" file) to make a constant-step bedGraph file. This seems somewhat clumsy and also produces strange errors at times (that seem to be related to the chromosome order - despite both variable-step bedGraph and windows file being sorted with the same chr order, chromosomes 10 to 19 seem to get no mapping at all).

    So, first of all, what is the "right" way to get a constant-step bedGraph from a BAM/SAM file?

    And secondly, is there a way to do windowed mapping in which overlaps with bins would be considered? E.g. if certain read is 72% in bin 1 and 28% in bin2, bin 1 would get 0.72 added to its read count, and bin 2 would add 0.28?

    The best option I've found so far is -f option in "bedtools map", when a certain read only "counts" when more than a certain fraction of it belongs to a window.

    Thank you in advance for any input.
  • EricHaugen
    Member
    • Sep 2009
    • 13

    #2
    1. It sounds like your files are not sorted in the order "bedtools map" requires (both are in the same, unsupported order). Probably karyotypic chr1,chr2,chr3... instead of lexical chr1,chr10,chr11... ?
    See http://bedtools.readthedocs.org/en/l...tools/map.html


    2. If your reads are all the same length you could pull out read locations with "bedtools bamtobed", sort them, then use "bedmap" (http://code.google.com/p/bedops/) to report the total read bases overlapping each window, and divide by read length (36bp in this example):
    bedmap --ec --delim '\t' --echo --bases windows.bed read_locations.bed | awk 'BEGIN{OFS="\t"}{print $1,$2,$3,$4/36}'

    That "--ec" flag is for error checking, slower but tells you if the sort order is the problem instead of just omitting chromosomes 10-19.

    Comment

    • apredeus
      Senior Member
      • Jul 2012
      • 151

      #3
      Eric, thank you for you answer, it was very helpful.

      Yes I did suspect that sorting was a problem - however, no error messages were generated, and even with both .bed and .bedGraph files sorted alphabetically the mapping produced was plain wrong. Oh well.

      "bedmap" approach did work like a charm.

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