Convert a bed to a matrix

bed2matrix(bedfile, n = NULL, p = NULL)

Arguments

bedfile

Path to a bed file.

n

Number of samples. Default reads it from corresponding fam file.

p

Number of SNPs. Default reads it from corresponding bim file.

Value

An integer matrix.

Examples

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