Thursday, August 25, 2016

Extract chromosome specific ChIA-PET interaction from joint file

If you have ChIA-PET output file (in this example downloaded from UCSC Genome Browser) with inter- and intra- chromosomal interactions:

mpjanic@valkyr:~/EMES/ChIA-PET_bed_files$ cut -f4 wgEncodeGisChiaPetK562CtcfInteractionsRep1.bed | head
chr1:121484520..121485419-chr10:42530561..42531081,2
chr1:121484520..121485419-chr10:42530561..42531081,2
chr1:214066326..214066826-chr10:72518556..72519163,2
chr1:214066326..214066826-chr10:72518556..72519163,2
chr1:31180640..31181156-chr11:66049646..66050541,2
chr1:31180640..31181156-chr11:66049646..66050541,2
chr1:68651784..68652284-chr11:1100945..1101530,2
chr1:68651784..68652284-chr11:1100945..1101530,2
chr1:121484496..121485051-chr11:48865024..48865528,2
chr1:121484496..121485051-chr11:48865024..48865528,2

And want to extract only intra- chromosomal interactions use the code:

mpjanic@valkyr:~/EMES/ChIA-PET_bed_files$ cut -f4 wgEncodeGisChiaPetK562CtcfInteractionsRep1.bed | grep chr1.*chr1: | head
chr1:839717..840790-chr1:872838..874070,6
chr1:839813..840540-chr1:998738..999431,2
chr1:839841..840733-chr1:855600..856780,3
chr1:839974..840594-chr1:847929..848569,2
chr1:913753..914320-chr1:1199829..1200629,2
chr1:919077..920172-chr1:998023..999932,8
chr1:919212..920171-chr1:1219377..1219906,2
chr1:919215..919720-chr1:1027180..1027941,2
chr1:919216..919764-chr1:936906..937428,2

Loop for all chromosomes:

mpjanic@valkyr:~/EMES/ChIA-PET_bed_files$ cat commands 
for i in {1..22} X Y;
do
echo chr$i specific interaction
cut -f4 wgEncodeGisChiaPetK562CtcfInteractionsRep1.bed | grep chr$i.*chr$i: | wc -l
done

No comments:

Post a Comment