This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Trying to edit VCF file

Hi,

I've been trying to take some samples out of a file but it appears its only taken some of the information out. When I tried to run a code I had in R that works for all the samples it gave me an error about the number of samples not matching the population map file which I also updated. When I opened the vcf in excel I noticed that there was still columns for what I removed from the file. perhaps I didn't properly remove everything? The file is smaller and a lot of snps are deleted however there's a bit of leftover data from the 3 files I thought I removed.

I used the following code

bcftools query -l filename.vcf| grep "file1\|file2\|etc\|"> Fall22C.txt #(For what I wanted to keep)
bcftools view -S Fall22C.txt Fall22beetle.vcf > Fall22C.vcf #To make a new file

Error in R:

Error in `pop<-`(`*tmp*`, value = c("AL", "AL", "VA", "VA", "VA", "GA",  : 
      Vector length does no match number of individuals"
vcf r bcftools snpsaurus

When I opened the vcf in excel I noticed that there was still columns for what I removed from the file.

please, explain, show the data.

I noticed that there was still columns for what I removed from the file.

so, what should we see in your image ??

Y Z and AA ideally wont be there or come up in the vcf file if I removed them proper so I'm wondering what the issue is in the initial code.

yes. They should be removed I imagine?

option -S in bcftools view is for the samples you want to KEEP.

I'm aware. I manually typed each one but those 3 when I submitted. I actually made that mistake the first time around and only kept the 3 I wanted to cut.

Got something to work after walking back through it and deleting them from that file manually so thanks!

0 answers

No answers yet.

Log in to answer this question.