Learn R Programming

hirisplexr (version 0.1.0)

write_hirisplex_csv: Write HIrisPlex / HIrisPlex-S CSV from a PLINK BED/BIM/FAM prefix

Description

Given a PLINK 1.9 binary dataset (prefix.bed/.bim/.fam), this function produces a CSV ready to upload to the HIrisPlex(-S) webtool.

Usage

write_hirisplex_csv(
  prefix,
  out,
  panel = c("hirisplexs", "hirisplex", "irisplex"),
  sample_id = c("IID", "FID_IID"),
  allow_strand_flip = TRUE
)

Value

(Invisibly) the output file path.

Arguments

prefix

Character. Path prefix to PLINK files, without extension.

out

Character. Output CSV path.

panel

Character. One of "hirisplexs" (default), "hirisplex", "irisplex".#'

sample_id

Character. How to form 'SampleID': "IID" or "FID_IID". Default is "IID".

allow_strand_flip

Logical. If TRUE, attempt to match the required allele by allowing strand complements.

Details

Columns are 'SampleID' followed by one column per required SNP in the form rsID_Allele (e.g., rs12203592_T). Each cell contains 0/1/2 (count of the input allele) or NA when the SNP is missing. The column set and order are defined by the selected panel (IrisPlex, HIrisPlex, HIrisPlex-S).

Allele counting is based on the PLINK .bim alleles. Genotype dosage is read on demand from the .bed using BEDMatrix::BEDMatrix(), which encodes the dosage of the first allele in the .bim file (A1). If the webtool's required input allele equals A1, we use the dosage directly; if it equals A2, we use (2 - dosage). If allow_strand_flip = TRUE, we also reconcile complements (A<->T, C<->G) to account for strand orientation differences.

Examples

Run this code
if (FALSE) {
write_hirisplex_csv("/path/to/prefix", tempfile(fileext = ".csv"), panel = "hirisplexs")
}

Run the code above in your browser using DataLab