Learn R Programming

pgenlibr (version 0.7.0)

NewPgenWriter: Creates a new .pgen file for writing.

Description

Only the .pgen is written; you are responsible for writing the companion .pvar (or .bim) and .psam (or .fam) files yourself, with samples in the same order as in the vectors passed to the append functions, and variants in append order. After all variant_ct variants have been appended (with AppendBiallelic(), AppendAlleles(), or AppendDosages()), ClosePgenWriter() must be called to finalize the file.

Usage

NewPgenWriter(
  filename,
  sample_ct,
  variant_ct,
  nonref_flags = as.logical(c(TRUE)),
  allele_ct_limit = 2L,
  hardcall_phase_present = FALSE,
  dosage_present = FALSE
)

Value

A pgen_writer object.

Arguments

filename

.pgen file path.

sample_ct

Number of samples.

variant_ct

Number of variants that will be written.

nonref_flags

TRUE when the data is from an ordinary PLINK 1 .bed file (where the A2 allele is major rather than consistently reference), FALSE when the REF allele is consistently reference, or a logical vector of length variant_ct when this is mixed. NULL is also permitted (this delegates tracking of nonref information to the .pvar file), but it's discouraged since .pgen+.bim+.fam is a useful data representation with direct plink2 support. Defaults to TRUE, as in the Python PgenWriter.

allele_ct_limit

Maximum number of alleles (REF + ALTs) that any variant can have; defaults to 2. Values larger than 2 are only useful with AppendAlleles().

hardcall_phase_present

Whether phased hardcalls may be written (with AppendAlleles()). Defaults to FALSE.

dosage_present

Whether dosages may be written (with AppendDosages()). Defaults to FALSE.