Reads sample annotation fields from a GDS file and prepares them for null model fitting. Handles PLINK phenotype encoding and covariate conversions.
extract_pheno_covar_gds(
gds_file,
pheno_name = "phenotype",
covar_names = NULL,
pheno_coding = "plink",
verbose = 1
)Character path to GDS file.
Character name of the sample.annotation field containing the phenotype. Default: "phenotype".
Character vector of sample.annotation field names to use as covariates. Default: NULL (no covariates beyond intercept).
Character encoding scheme for phenotype values. "plink" (1=control, 2=case, -9=missing) or "01" (already 0/1). Default: "plink".
Integer verbosity level (0=silent, 1=progress, 2=detailed).
A list with components:
Character vector of sample IDs (missing-phenotype samples excluded)
Numeric response vector (0/1 for binary)
Numeric covariate matrix (columns named by covar_names), or NULL if no covariates
Character: "binary" or "continuous" (auto-detected)
Integer: total samples in GDS
Integer: samples excluded due to missing phenotype
Opens the GDS file read-only using SeqArray and reads sample annotation nodes. Phenotype encoding is applied before missing-value filtering, so PLINK sentinel values (-9) are converted to NA and those samples are excluded. Character covariates are converted: sex (M/F) becomes 1/0; other character covariates become integer factor codes minus 1.
Trait type is auto-detected after encoding: if all non-missing values are in {0, 1} the trait is "binary", otherwise "continuous".
Complexity: O(n) in sample count. The GDS file is opened and closed within this call.