Require the complete set of 3 files in the binary PLINK format. It includes BED file, BIM file and BAM file. For more information about the binary PLINK format, please check in the manual of PLINK.

read.bed(bed, bim, fam, only.snp = FALSE)

Arguments

bed

A path of BED file

bim

A path of BIM file

fam

A path of FAM file

only.snp

If TRUE, the function to read only SNP matrix, otherwise all files are loaded. The default value is FALSE.

Value

The list containing the matrices of $snp, $snp.info, and $ind.info.

  • $snp is a SNP matrix from BED file.

  • $snp.info is a data.frame of SNP information from BIM file.

  • $ind.info is a data.frame of individual information from FAM file.

Details

For more details about the binary PLINK format, please check http://zzz.bwh.harvard.edu/plink/binary.shtml

See also

Examples


#Use the example files embedded in the package.
bed <- system.file("extdata", "example_SNP.bed", package="KRIS")
bim <- system.file("extdata", "example_SNP.bim", package="KRIS")
fam <- system.file("extdata", "example_SNP.fam", package="KRIS")
snp <- read.bed(bed, bim, fam )

#Check the objects inside 'snp'
ls(snp)
#> [1] "ind.info" "snp"      "snp.info"

#Preview $snp
print(snp$snp[1:10, 1:10])
#>       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
#>  [1,]    0    1    1    1    2    0    1    1    1     2
#>  [2,]    1    1    1    2    1    1    1    0    2     2
#>  [3,]    2    0    0    1    1    0    1    1    2     2
#>  [4,]    2    1    2    2    1    0    1    2    1     2
#>  [5,]    2    0    2    2    0    0    1    0    0     1
#>  [6,]    2    0    2    0    0    1    2    0    1     2
#>  [7,]    1    0    1    2    2    0    0    1    1     2
#>  [8,]    2    0    2    2    2    2    0    1    1     2
#>  [9,]    2    2    2    1    0    0    0    1    2     1
#> [10,]    2    0    2    1    1    2    1    1    2     2

#Preview $snp.info
head(snp$snp.info)
#>   chr      ID GD position allele1 allele2
#> 1   1 marker1  0    10000       A       T
#> 2   1 marker2  0    20000       A       T
#> 3   1 marker3  0    30000       A       T
#> 4   1 marker4  0    40000       A       T
#> 5   1 marker5  0    50000       A       T
#> 6   1 marker6  0    60000       A       T

#Preview $ind.info
head(snp$ind.info)
#>   FamID IndID PatID MatID sex phenotype
#> 1     1     1     0     0   1         1
#> 2     2     2     0     0   1         1
#> 3     3     3     0     0   1         1
#> 4     4     4     0     0   1         1
#> 5     5     5     0     0   1         1
#> 6     6     6     0     0   1         1