This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Fastest Way To Rename Sample Name In 37 Gb Gzipped Vcf File Or Binary Ped File

Hi I have a project file for 2000 individuals, with SNPs from WGS. We have decided to change the sample names to a more uniform way of naming individuals from different sources.

I wish to do a quick check if there's inbuilt functions in plink or plink seq or vcftools to do this i.e. pass it a sample name remapping file to output a new set of fam ids and idv ids.

Otherwise, i might consider doing this using sqlite since there's a possibility I might have to slice the data in another way again

vcf ped bed

Hi, running into an identical problem here. Do you recall how you ended up doing this?

Thanks in advance,
Steve

2 answers

As long as you do NOT (i) change the order or (ii) remove/add individuals you can edit the FAM file for ids. My recommendation would be a script to do the correction on the FAM file.

Remember: the order and the number of individuals stay the same. Other than that, you can change the FAM ids

You could create a new vcf header with the final #CHROM line updated to reflect the new sample names. Then use tabix to replace the older header with the new one.

# Replace VCF header. The file must be compressed by bgzip. 
tabix -r header.txt big.vcf.bgz > big.vcf.new_header.bgz

More here: http://vcftools.sourceforge.net/docs.html#one-liners

Edit: To get your VCF in the correct format and to create the tbi index do something like...

gunzip -c big.vcf.gz | bgzip > big.vcf.bgz
tabix -p vcf big.vcf.bgz

Log in to answer this question.