Biostar Beta. Not for public use.
Question: bam file to .bedgraph
0
Entering edit mode

I have bam files and i need to convert them to .bedgraph format for my further analysis please help me in this issue?

ADD COMMENTlink 22 months ago praveenhcu131 • 0 • updated 22 months ago arup ♦ 1.3k
3
Entering edit mode

Your questions is lacking a couple of details such as what's the goal of obtaining the bedGraph file, do you want to normalize or scale the read counts, do you want the read counts for the entire genome, what type of data is this, have you tried any tools and found them lacking some options, ....

To answer your general question in a general manner: bedtools genomecov with -bg option or deepTools bamCoverage might be viable options.

ADD COMMENTlink 22 months ago Friederike 4.2k
Entering edit mode
0

If you want per-million scaled bg, use this command together with genomecov:

## Scaling factor for single-end data, counting every mapped read (bitwise flag = 0)
 TmpScale=$(bc <<< "scale=6;1000000/$(samtools view -f 0 -c in.bam)")

 ## Now get the actual bedGraph:
 echo '==> RPM scaling factor:' $TmpScale
 bedtools genomecov -bga -ibam in.bam -scale $TmpScale | sort -k1,1 -k2,2n > out.bedGraph
ADD REPLYlink 22 months ago
ATpoint
17k
1
Entering edit mode

Alfred is another option:

alfred tracks -o out.bedGraph.gz input.bam
ADD COMMENTlink 22 months ago trausch ♦ 1.3k
0
Entering edit mode

BEDOPS bam2bed can be useful:

$ bam2bed < reads.bam | cut -f1-3,5 > reads.bg

This puts the map quality signal into the fourth column of reads.bg. Other columns are available: http://bedops.readthedocs.io/en/latest/content/reference/file-management/conversion/bam2bed.html

If you're trying to count reads over regions, you could instead do something like:

$ bedmap --echo-ref-name --count --delim '\t' regions.bed <(bam2bed < reads.bam) | sed 's/[:-]/\t/g' > answer.bg
ADD COMMENTlink 22 months ago Alex Reynolds 28k
0
Entering edit mode

This can be done using bedtools genomecov or genomeCoverageBed .

bedtools genomecov [OPTIONS] -ibam < input file name> -g <genome> -bg <output name>
ADD COMMENTlink 22 months ago arup ♦ 1.3k

Login before adding your answer.

Similar Posts
Loading Similar Posts
Powered by the version 2.0