SEQanswers

SEQanswers (http://seqanswers.com/forums/index.php)
-   Bioinformatics (http://seqanswers.com/forums/forumdisplay.php?f=18)
-   -   Converter for vcf to bed format (http://seqanswers.com/forums/showthread.php?t=9132)

ketan_bnf 01-28-2011 02:13 AM

Converter for vcf to bed format
 
Hi all,

Is there any converter that can convert vcf format files obtained by samtools vcfutils.pl to bed format?

Because i want predict the variant effect using varian_effect_predictor of ensemble.

##fileformat=VCFv4.0
#CHROM POS ID REF ALT QUAL FILTER INFO FORMAT GKUNU9Q04_chr1_sort.bam
chr1 46707 . A G 7.59 . DP=2;AF1=1;CI95=0.5,1;DP4=0,0,0,2;MQ=60 PL:GT:GQ 38,6,0:1/1:49
chr1 168576 . C T 4.61 . DP=2;AF1=1;CI95=0.5,1;DP4=0,0,0,2;MQ=60 PL:GT:GQ 34,6,0:1/1:49
chr1 168635 . G A 17.1 . DP=3;AF1=1;CI95=0.5,1;DP4=0,0,0,3;MQ=60 PL:GT:GQ 49,9,0:1/1:63

To

1 46707 46707 A/G +
1 168576 168576 C/T +
1 168635 168635 G/A +

quinlana 01-28-2011 03:43 PM

The awesome power of awk and sed.

Code:

sed -e 's/chr//' file.vcf | awk '{OFS="\t"; if (!/^#/){print $1,$2-1,$2,$4"/"$5,"+"}}'
where you replace "file.vcf" with your file. Note this uses 0-based start coordinates, which are the proper BED format. If you want to use 1-based, change "$2-1" to just "$2".

ketan_bnf 01-28-2011 06:15 PM

Quote:

Originally Posted by quinlana (Post 33833)
The awesome power of awk and sed.

Code:

sed -e 's/chr//' file.vcf | awk '{OFS="\t"; if (!/^#/){print $1,$2-1,$2,$4"/"$5,"+"}}'
where you replace "file.vcf" with your file. Note this uses 0-based start coordinates, which are the proper BED format. If you want to use 1-based, change "$2-1" to just "$2".

Thanks for reply,

if suppose i want to put "-" reverse strand instead of "+", how can i put that using vcf file?

1 46707 46707 A/G +
1 168576 168576 C/T +
1 168635 168635 G/A +
1 195648 195648 T/G -

Tahir Mujtaba 12-18-2012 01:57 AM

GFF to BED
 
How to convert a GFF file intO BED format file?.

dagarfield 09-03-2013 04:43 AM

Maybe this will be useful?

https://code.google.com/p/bedops/wiki/vcf2bed


All times are GMT -8. The time now is 03:11 AM.

Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2020, vBulletin Solutions, Inc.