Question: How To Split Vcf Files
0
gravatar for mayara_salvian
2.1 years ago by
mayara_salvian0 wrote:

I have a vcf file with 60 animals (columns) and I would like to split these animals in 10 subset with 6 animals chosen randomly per group. I'm using the following script, but it's not working:

head -n 60 my.vcf | grep "^#" > header

grep -v "^#" out.subgrupos.vcf > animals

split -l 6 animals

for i in x*;do cat header $i >$i.vcf && rm -f $i;done

rm -f header animals

I need to keep the header in each file. Is there another way to do that?

vcftools vcf • 477 views
ADD COMMENTlink modified 2.1 years ago by Pierre Lindenbaum129k • written 2.1 years ago by mayara_salvian0
1
gravatar for Pierre Lindenbaum
2.1 years ago by
France/Nantes/Institut du Thorax - INSERM UMR1087
Pierre Lindenbaum129k wrote:
grep '#CHROM' -m1 my.vcf | cut -f 10- | tr "\t" "\n" | shuf | split -l 6 - animal
for F in animal*
do
     bcftools view --samples-file $F my.vcf > "split.${F}.vcf"  && rm "${F}"
done
ADD COMMENTlink written 2.1 years ago by Pierre Lindenbaum129k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 837 users visited in the last hour