| 109 | |
| 110 | Extract fields from a VCF file to a TXT, tab separated file with the [https://samtools.github.io/bcftools/howtos/query.html bcftools query] function |
| 111 | |
| 112 | {{{ |
| 113 | # Extract any fields that are in the INFO or other fields |
| 114 | bcftools query -f '%CHROM\t%POS\t%REF\t%ALT\t%AC\t%AN\t%AF\n' gnomad.genomes.r2.1.1.sites.21.vcf.bgz > gnomad.genomes.r2.1.1.sites.21.vcf.AC+AN+AF.txt |
| 115 | # Start by keeping only SNPs (so remove indels) |
| 116 | bcftools view --types snps gnomad.genomes.r2.1.1.sites.21.vcf.bgz | bcftools query -f '%CHROM\t%POS\t%REF\t%ALT\t%AC\t%AN\n' >| gnomad.genomes.r2.1.1.sites.21.vcf.SNPs_only.AC+AN+AF.txt |
| 117 | # Make a bedgraph file using an output value (such as AF for the score) |
| 118 | awk -F"\t" '{print "chr"$1 "\t" $2-1 "\t" $2 "\t" $7}' gnomad.genomes.r2.1.1.sites.21.vcf.AC+AN+AF.txt >| gnomad.genomes.r2.1.1.sites.21.AF.bedgraph |
| 119 | # Make output a bed file showing the REF and ALT alleles (like "G>C" for QC) |
| 120 | awk -F"\t" '{print "chr"$1 "\t" $2-1 "\t" $2 "\t" $3">"$4}' gnomad.genomes.r2.1.1.sites.21.vcf.AC+AN+AF.txt >| gnomad.genomes.r2.1.1.sites.21.bed |
| 121 | }}} |