This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to create a new bigwig file defined by a subset of bed file?

Hello, I have a ChIP-seq bigwig file and a bed file that is a subset of the binding peaks defined from the bigwig file. I want to create a new (sub) bigwig file to use the subset of bed file. How can I do it? Many thanks! Xiaoyong

chip-seq

1 answer

Convert from bigwig to wiggle:

$ bigWigToWig data.bw data.wig

Convert from wiggle to bed:

$ wig2bed < data.wig > data.bed

Filter the bed file based on your peak subset, and make a bedgraph file from the subset:

$ sort-bed peak_subset.unsorted.bed > peak_subset.bed
$ bedops --element-of 1 data.bed peak_subset.bed | awk 'BEGIN{ OFS="\t"; }{ print $1, $2, $3, $5 }' > data_subset.bedgraph

Convert the bedgraph file to a bigwig file, e.g. for reference genome hg19:

$ fetchChromSizes hg19 > hg19.sizes
$ bedGraphToBigWig data_subset.bedgraph hg19.sizes data_subset.bw

Sounds cool. I will definitely try. Thank you, Alex! Xiaoyong

Log in to answer this question.