How to convert a file to vcf format
2
0
Entering edit mode
5.3 years ago
kamanovae ▴ 100

Hello, I have a file for each chromosome that represents the following format:

CHROM  POS     ID      REF     ALT     QUAL    FILTER  INFO    FORMAT Sample1 Sample2 Sample3  
10      62010  10:62010        C       T       999     PASS    SING;AA=NN;AN=CC;AD=CC  GT      0|0     0|0     0|0    

10      110548  10:110548       T       C       999     PASS    SING;AA=T;AN=TT;AD=TT   GT      0|0     0|0     0|0

10      110848  10:110848       T       C       999     PASS    SING;AA=T;AN=TT;AD=TT   GT      1|1     1|1     1|1

How can I combine all the files and convert this format to standard vcf file?

Thank you so much for your help!

vcf combine file • 4.7k views
ADD COMMENT
1
Entering edit mode
5.3 years ago

assuming the delimiter is a tab:

run the following script for each file

awk -f script .awk input.txt  | bcftools view -O z -o out.vcf.gz

with script.awk (add a '##contig' line for all your chromosomes)

BEGIN   {
    FS="\t";
    }
/^CHROM/ {
    printf("##fileformat=VCFv4.2\n");
    printf("##FORMAT=<ID=GT,Number=1,Type=String,Description=\"Genotype\">\n");
    printf("##INFO=<ID=AA,Number=1,Type=String,Description=\"TODO\">\n");
    printf("##INFO=<ID=AN,Number=1,Type=String,Description=\"TODO\">\n");
    printf("##INFO=<ID=AD,Number=1,Type=String,Description=\"TODO\">\n");
    printf("##INFO=<ID=SING,Number=0,Type=Flag,Description=\"TODO\">\n");
    printf("##INFO=<ID=SING,Number=0,Type=Flag,Description=\"TODO\">\n");
    printf("##contig=<ID=10,length=135534747,assembly=human_g1k_v37>\n");
    printf("#%s\n",$0);
    next;
    }
    {
    print;
    }

index with 'bctools index' and then merge the vcf with bcftools merge

ADD COMMENT
0
Entering edit mode

Thanks for the answer! I painted my question poorly. I need to create a file for each sample. It is necessary to get information about specific SNPs for a sample from each file of a certain chromosome and write it in a separate VCF file. I hope that there are ready-made programs for this

ADD REPLY
0

Login before adding your answer.

Traffic: 2498 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