Extract a chromosome from a WIG file
3
0
Entering edit mode
5.6 years ago
Fluorine ▴ 100

I have a large WIG files which are difficult to run in IGV, due to the size. I am only interested in chromosome M so I would like to extract signal from that chromosome and thus have a smaller file size. I found one solution on Stackoverflow (https://stackoverflow.com/questions/17354962/pcregrep-a-wiggle-file-to-extract-chromosome-multiple-line-regex-search), but that doesn't work at all. Any other ideas? I check UCSC utils and extensively searched online. I am also open to suggestions on bedgraph or similar formats.

WIG • 4.5k views
ADD COMMENT
0
Entering edit mode

but that doesn't work at all

Please specify what doesn't work.

The awksolution on stackoverflow looks fine to me.

fin swimmer

ADD REPLY
0
Entering edit mode

It produces an empty file. I checked with grep and the chromosome exists in the original file.

ADD REPLY
2
Entering edit mode
5.6 years ago

use one of the tools provided by the UCSC to extract a region of the chromosome : http://hgdownload.soe.ucsc.edu/admin/exe/linux.x86_64/

for example bigWigToWig :

   -chrom=chr1 - if set restrict output to given chromosome
   -start=N - if set, restrict output to only that over start
   -end=N - if set, restict output to only that under end
   -udcDir=/dir/to/cache - place to put cache for remote bigBed/bigWigs

and then convert back to bigwig with wigToBigWig

ADD COMMENT
0
Entering edit mode

Thank you. I knew there had to be a simple solution like this available.

ADD REPLY
1
Entering edit mode
4.1 years ago
haizi.zh ▴ 20

Here's another solution.

You can convert the wig file to a bedGraph using bedops and manually cutting it:

wig2bed < hg19.sometrack.chr21.wig | cut -f1-3,5 > hg19.sometrack.chr21.bedgraph

Then convert it back to bigWig:

bedGraphToBigWig hg19.sometrack.chr21.bedgraph hg19.sizes hg19.sometrack.chr21.bw
ADD COMMENT
0
Entering edit mode
5.6 years ago
EagleEye 7.5k

Try IGV 'toTDF' to convert your 'WIG' files into binary tiled data (TDF). This loads into IGV lot faster than 'WIG' files.

ADD COMMENT

Login before adding your answer.

Traffic: 1467 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6