This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Converting narrowPeak to bed

Hi all,

I am trying to convert a regular narrowPeak file into a BED file for use with diffBind... any ideas?

Thanks.

narrowpeak bed

I know this is an old ticket however I am not able to create a DBA object with a narrowPeak file as it complains about the first line in the narrow peak file not having 10 columns which is true because it has a header like this:

track type=narrowPeak visibility=3 db=hg19 name="nPk" description="ENCODE narrowPeak Example"
browser position chr1:9356000-9365000
chr1    9356548 9356648 .       0       .       182     5.0945  -1  50
chr1    9358722 9358822 .       0       .       91      4.6052  -1  40
chr1    9361082 9361182 .       0       .       182     9.2103  -1  75

Only after removing the header, I was able to load it. Is this okay or something is off about my peak calling? Here's the code snippet

allsamples <- read.csv('meta/allsamples.csv')
gpparestTestbeta <- dba(sampleSheet=allsamples)

Please do not add an answer unless you're answering the top level question. You have a related question, which is best posted as either a comment on the top level question or as a new question referencing the existing question.

Also, please use the formatting bar (especially the code option) to present your post better. You can use backticks for inline code (`text` becomes text), or select a chunk of text and use the highlighted button to format it as a code block. I've done it for you this time.
code_formatting

2 answers

Do you really need to convert? narrowPeak already is in bed 6+4 format, see here, here and here.

edit: in case DiffBind if very strict, use this solution:

cut -f 1-6 macs_output.narrowPeak > macs_output.bed

I tried but it is not working, any other suggestion? Thanks for your help!

Yes, describe how it is not working. What have you been trying? Errors you got?

the sample sheet is the more likely problem....the narrowPeak file doesnt need any editing.

But then how can I obtain the count matrix? For that reason I wanted to convert the narrowPeak to bed because i already established the pipeline in that way. Any suggestion is very appreciated.

It worked for me, thank you very much

DiffBind supports narrowPeak format directly, Just specify "narrow" as the value for PeakCaller in your samplesheet.

-Rory

I have the narrowPeak files, I want to extract the counts to use the matrix with DESeq or EdgeR. That is why I was trying to convert the narrowPeak files into bed files. Any suggestion?

Log in to answer this question.