Skip to contents

Read genotype data (VCF, plink1, plink2 or GDS) as a RangedSummarizedExperiment: variants in rowRanges, samples in colData, and dosages in a DelayedArray assay that reads from the file only when something touches it. Nothing is read here beyond the variant and sample metadata.

The panel is the same shape a QtlDataset uses for its genotypes and the same shape a collection carries as its ldSketch, so the Bioconductor and tidy surfaces apply throughout: subset it with panel[i, j], ask rowRanges() for the variants, colnames() for the samples, and hand it to computeLd.

A panel that is not one self-describing file is named by keyword instead of by path: pass plink1Prefix or plink2Prefix for a triplet stem, bed/bim/fam or pgen/pvar/psam for explicit triplet paths, genoMeta for a one-file-per-chromosome panel (optionally narrowed with chroms), or ldMeta plus region to resolve a block out of an LD-meta table. Exactly one source may be given.

Usage

readGenotypes(path, format = NULL, ...)

# S4 method for class 'character'
readGenotypes(path, format = NULL, ...)

# S4 method for class 'missing'
readGenotypes(path, format = NULL, ...)

Arguments

path

Character, path to a single self-describing genotype file (.vcf, .vcf.gz, .vcf.bgz, .bcf or .gds). Omit it when naming the panel by one of the keyword sources described above.

format

Character, one of "vcf", "plink1", "plink2", "gds". If NULL, inferred from file extension.

...

The keyword source arguments described above, plus any further arguments forwarded to the format-specific reader.

Value

A RangedSummarizedExperiment of variants x samples.

See also

Examples

panel <- readGenotypes(
  system.file("extdata", "toy_ref.bed", package = "pecotmr")
)
dim(panel)
#> [1] 17421   165
head(rownames(panel))
#> [1] "rs11089128" "rs7288972"  "rs11167319" "rs8138488"  "rs2186521" 
#> [6] "rs2027649" 

# The same panel named by its PLINK1 stem rather than by a file.
stem <- sub("\\.bed$", "", system.file(
  "extdata", "toy_ref.bed",
  package = "pecotmr"
))
dim(readGenotypes(plink1Prefix = stem))
#> [1] 17421   165