Randomly subsets SNVs from a VCFArrow object
Details
This function subsets a VCFArrow object to specific number of SNVs, returning new VCFArrow object. The subsampling is stratified, i.e. the same proportion of SNVs per CHROM. The seed for random number generator is automatically generated unless specified.
Examples
f <- system.file("extdata", "vaillantii_discosnp_sub.vcf.gz",
package = "VCFArrow")
vcf <- read_vcf(f) |> set_vcf_groups(dirname(f))
#> ℹ VCF is being read in chunks of 50000 variants
#> ✔ VCF successfully read into a VCFArrow object
vcf_sub_SNVs_stratified(vcf, n_SNVs = 1000, seed = 42)
#>
#> An object of class "VCFArrow"
#>
#> Dimensions:
#> Variants: 0
#> Samples: 18
#>
#> Quick stats:
#> Non-missing variants: 0
#>
#> Phased genotypes: FALSE
#>
#> Storage:
#> Path: /tmp/RtmpSpcr9J/arrow_vcf_1ff818ce31df
#>
#> Genotype storage (Arrow):
#> FileSystemDataset with 1 Feather file
#> 9 columns
#> .row_id: int32
#> sample: string
#> a1: int32
#> a2: int32
#> phased: bool
#> fmt: string
#> DP: double
#> GQ: double
#> ADR: double
#>
#> See $metadata for additional Schema metadata
#>
#> Variants: <empty>
#>
#> Samples (first 5):
#> [1] "Pv120" "Pv126" "Pv13" "Pv14" "Pv27"
#> ... 13 more