Question: bam file to .bedgraph
0
gravatar for praveenhcu131
2.1 years ago by
praveenhcu1310 wrote:

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

rna-seq chip-seq galaxy R genome • 3.7k views
ADD COMMENTlink modified 2.1 years ago by Arup Ghosh2.4k • written 2.1 years ago by praveenhcu1310
3
gravatar for Friederike
2.1 years ago by
Friederike5.6k
United States
Friederike5.6k wrote:

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 written 2.1 years ago by Friederike5.6k

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 written 2.1 years ago by ATpoint34k
1
gravatar for trausch
2.1 years ago by
trausch1.5k
Germany
trausch1.5k wrote:

Alfred is another option:

alfred tracks -o out.bedGraph.gz input.bam
ADD COMMENTlink written 2.1 years ago by trausch1.5k
0
gravatar for Alex Reynolds
2.1 years ago by
Alex Reynolds30k
Seattle, WA USA
Alex Reynolds30k wrote:

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 modified 2.1 years ago • written 2.1 years ago by Alex Reynolds30k
0
gravatar for Arup Ghosh
2.1 years ago by
Arup Ghosh2.4k
India
Arup Ghosh2.4k wrote:

This can be done using bedtools genomecov or genomeCoverageBed .

bedtools genomecov [OPTIONS] -ibam < input file name> -g <genome> -bg <output name>
ADD COMMENTlink written 2.1 years ago by Arup Ghosh2.4k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1366 users visited in the last hour