This is a test version of Biostars. For the public version, visit https://www.biostars.org.
.fai file generation for a vcf file containing snps

I would like to generate a .fai file for all the snps belonging to a specific gene. How I'll be able to do that?

Do I have to download all the sequences belonging to each snps (e.g. rs124536) from NCBI and make a .fa file and then use samtools to convert it to .fai?

fai snps

2 answers

Your question is confusing.

  1. Fasta indexing generates .fai files. There are several tools to index fasta files.
  2. If you want to generate fasta file from VCF (using a reference), the same question is answered several times in this forum. E.g., Introducing Known Mutations (From A Vcf) Into A Fasta File
  3. If you are looking for indexing VCF (standard format for storing SNVs/MNVs/DIVs), there are several tools.

Downloading all SNVs (in general as VCF) and indexing won't generate a sequence file (.fasta) with all the SNPs.

The software I am working with (ANGSD) requires .fai file along with a .vcf file as input.

Would you please tell me how I will be able to get the .fai file for a .vcf file?

The .fai file mentioned in page: http://www.popgen.dk/angsd/index.php/Input corresponds to reference fasta file. Index your reference fasta file and this would create a fai file. This fai file should be supplied to the command. Example command would be (assuming that your reference sequence used in alignment is reference.fa and vcf file is sample.vcf):

#for using GL tags
./angsd -vcf-gl sample.vcf -fai reference.fa.fai -nind <sample numbers in your VCF> -domaf 1 -out <output_file_name>
#for using GP tags
./angsd -vcf-gp sample.vcf -fai reference.fa.fai -nind <sample numbers in your VCF> -domaf 1 -out <output_file_name>

One cannot create a fai from VCF file. VCF indexing produces idx files and fasta indexing generates fai files, in general.

.fai files are specific to fasta files. If you have a VCF file then google "tabix".

Log in to answer this question.