Subsetting VCF file by "First n SNPs"
Hi all,
I was wondering if there's an easy way to subset or extract the first n SNPs from a vcf file (by position). I know that plink has --from and --to flags but these require you to specifically input the variant ids, while the --from-bp, --to-bp and --window flags allow you to specify positions but I was hoping to create a new vcf using only the first say 25 SNPs from a certain position. Is there an easy way of doing this? If not what would be the best method of doing this?
Thanks in advance!
• 1,114 views
•
link
1 answer
bcftools view indexed.vcf.gz "chr1:234-467" | awk '/^#/ {print;next;} {N++;if(N>=3) exit(0);print;}'
• 0 views
•
link
Log in to answer this question.