snp_writeBed | R Documentation |
Function to write bed/bim/fam files from a bigSNP.
This will use the slot code
rounded to write 0s, 1s, 2s or NAs.
snp_writeBed(x, bedfile, ind.row = rows_along(G), ind.col = cols_along(G))
x |
A bigSNP. |
bedfile |
Path to file with extension ".bed" to create. |
ind.row |
An optional vector of the row indices (individuals) that
are used. If not specified, all rows are used. |
ind.col |
An optional vector of the column indices (SNPs) that are used.
If not specified, all columns are used. |
The input bedfile
path.
N <- 17
M <- 911
fake <- snp_fake(N, M)
G <- fake$genotypes
G[] <- sample(as.raw(0:3), size = length(G), replace = TRUE)
# Write the object as a bed/bim/fam object
tmp <- tempfile(fileext = ".bed")
bed <- snp_writeBed(fake, tmp)
# Read this new file for the first time
rds <- snp_readBed(bed, backingfile = tempfile())
# Attach object in R session
fake2 <- snp_attach(rds)
# Same content
all.equal(fake$genotypes[], fake2$genotypes[])
all.equal(fake$fam, fake2$fam)
all.equal(fake$map, fake2$map)
# Two different backingfiles
fake$genotypes$backingfile
fake2$genotypes$backingfile
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.