cooler icon indicating copy to clipboard operation
cooler copied to clipboard

Change order of chromosomes

Open lauradmartens opened this issue 4 years ago • 5 comments

Hi, I processed my HiC data using HiC-Pro but unfortunately the chromosomes were in a weird order. I was wondering if there is a way to change the order of the chromosomes of my cooler files? Thanks a lot!

lauradmartens avatar Jun 01 '20 15:06 lauradmartens

+1 to a potential feature request! My colleague had the same problem a week ago.

golobor avatar Jun 01 '20 17:06 golobor

Because the internal structure of the file is chromosome order sensitive, it does require exporting and reloading data.

For a single cooler, a simple bash one-liner can reorder chromosomes:

cooler dump --join {input.cool} | cooler load --format bg2 {new.chrom.sizes}:{binsize} - {output.cool}

That will re-encode the genomic bins according to the order in the new chrom sizes file.

To transfer balancing weights or to transfer multiple coolers to make a new mcool requires additional manual steps... I guess this is what the proposed feature request would handle.

As a simpler alternative for now, you can re-balance and zoomify the converted base resolution cooler with cooler zoomify --balance.

cooler dump --join {input.mcool}::resolutions/{binsize} | cooler load --format bg2 {new.chrom.sizes}:{binsize} - {output.cool}
cooler zoomify --balance {output.cool}

nvictus avatar Jun 01 '20 18:06 nvictus

thanks! this is very helpful and will save me a lot of time :)

SergejN avatar Jun 01 '20 20:06 SergejN

Thanks a lot! I agree, it saved a lot of time ;)

lauradmartens avatar Jun 02 '20 08:06 lauradmartens

i wonder if tricks like this one deserve an ipynb and/or a page in sphinx docs?..

On Tue, 2 Jun 2020 at 10:43, lauradmartens [email protected] wrote:

Thanks a lot! I agree, it saved a lot of time ;)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/mirnylab/cooler/issues/199#issuecomment-637388520, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAG64CRUQHB6XFQIKDVNDRTRUS3RPANCNFSM4NP53WCQ .

golobor avatar Jun 05 '20 12:06 golobor