# Get the path to the example .bed file
path <- system.file("extdata", "example.bed",
package = "BEDMatrix")
# Create a BEDMatrix object the example .bed file
m <- BEDMatrix(path)
# Get the dimensions of the BEDMatrix object
dim(m)
# Get the row names of the BEDMatrix object
rownames(m)
# Get the column names of the BEDMatrix object
colnames(m)
# Extract genotypes for the specified sample(s)
m[1, ]
m[1:3, ]
m["per0_per0", ]
m[c("per0_per0", "per1_per1", "per2_per2"), ]
# Extract genotypes for a particular variant
m[, 1]
m[, c("snp0_A", "snp1_C", "snp2_G")]
# Extract genotypes for the specified samples and variants
m[
c("per0_per0", "per1_per1", "per2_per2"),
c("snp0_A", "snp1_C", "snp2_G")
]
Run the code above in your browser using DataLab