Converts the genotype matrix (geno slot) of a SNPDataLong object to a data.frame, with optional centering and scaling per SNP (column).
genoToDF(object, center = FALSE, scale = FALSE)A data.frame with individuals as rows and SNPs as columns (numeric 0/1/2, or centered/scaled values).
# \donttest{
set.seed(1)
raw_mat <- matrix(as.raw(sample(1:3, 100, TRUE)), nrow = 10, ncol = 10)
rownames(raw_mat) <- paste0("S", 1:10)
colnames(raw_mat) <- paste0("SNP", 1:10)
geno <- methods::new("SnpMatrix", raw_mat)
obj <- methods::new("SNPDataLong",
geno = geno,
map = data.frame(Name = colnames(geno),
Chromosome = 1,
Position = 1:10),
path = tempfile(),
xref_path = "chip1")
df <- genoToDF(obj, center = TRUE, scale = TRUE)
#> No monomorphic SNPs detected. Skipping subset.
#> Applying centering and/or scaling to SNP columns...
#> Genotype data converted to data.frame with dimensions: 10 x 10
head(df[, 1:5])
#> SNP1 SNP2 SNP3 SNP4 SNP5
#> S1 -1.256289 1.5212777 2.1213203 -0.1355262 0.000000
#> S2 1.027872 -1.0141851 -0.7071068 -1.4907880 -1.224745
#> S3 -1.256289 -1.0141851 -0.7071068 1.2197357 1.224745
#> S4 -0.114208 -1.0141851 -0.7071068 -1.4907880 0.000000
#> S5 -1.256289 0.2535463 -0.7071068 1.2197357 -1.224745
#> S6 1.027872 0.2535463 0.7071068 -0.1355262 -1.224745
# }