Convert a bed to a matrix
bed2matrix(bedfile, n = NULL, p = NULL)Path to a bed file.
Number of samples. Default reads it from corresponding fam file.
Number of SNPs. Default reads it from corresponding bim file.
An integer matrix.
bedfile <- system.file("extdata", "geno3pops.bed", package = "pcadapt")
mat <- bed2matrix(bedfile)
dim(mat)
#> [1]  150 1500
table(mat)
#> mat
#>      0      1      2 
#>  55488 106547  62965