DownSample a VCF. Will keep ānā random variants in a vcf.
Usage: downsamplevcf [options] Files
Options:
-h, --help
print help and exit
--helpFormat
What kind of help. One of [usage,markdown,xml].
-o, --output
Output file. Optional . Default: stdout
--version
print version and exit
-N
random seed. -1==use current time
Default: -1
-n
output size. keep 'n' random variants in the input vcf
Default: 10
${PATH}
. Setting JAVA_HOME is not enough : (e.g: https://github.com/lindenb/jvarkit/issues/23 )$ git clone "https://github.com/lindenb/jvarkit.git"
$ cd jvarkit
$ ./gradlew downsamplevcf
The java jar file will be installed in the dist
directory.
20131210
The project is licensed under the MIT license.
Should you cite downsamplevcf ? https://github.com/mr-c/shouldacite/blob/master/should-I-cite-this-software.md
The current reference is:
http://dx.doi.org/10.6084/m9.figshare.1425030
Lindenbaum, Pierre (2015): JVarkit: java-based utilities for Bioinformatics. figshare. http://dx.doi.org/10.6084/m9.figshare.1425030
bcftools view --header-only input.vcf > subsample.vcf
bcftools view --no-header input.vcf | awk '{printf("%f\t%s\n",rand(),$0);}' | sort -t $'\t' -k1,1g | cut -f2- | head -n 1000 >> subsample.vcf
$ curl -skL "ftp://ftp-trace.ncbi.nih.gov/1000genomes/ftp/release/20130502/ALL.wgs.phase3_shapeit2_mvncall_integrated_v5a.20130502.sites.vcf.gz" |\
gunzip -c |\
java -jar dist/downsamplevcf.jar -n 100 > output.vcf