This is a package to write snpStats objects to disk in formats suitable for reading by snphap, phase, mach, IMPUTE, beagle, and (almost) anything else that expects a rectangular format.
We will load a small dataset included in the snpStats package
library(snpStatsWriter) data(testdata,package="snpStats") A.small <- Autosomes[1:6,1:10] nsnps <- ncol(A.small)
and write it to disk in lots of formats.
f <- tempfile() write.snphap(A.small, file=f) head(read.table(f,sep="\t")) unlink(f)
pf <- tempfile() ## pedigree file mf <- tempfile() ## marker file write.mach(A.small, a1=rep("1",nsnps), a2=rep("2",nsnps), pedfile=pf, mfile=mf) head(read.table(mf)) head(read.table(pf)) unlink(pf) unlink(mf)
pf <- tempfile() write.impute(A.small, a1=rep("1",nsnps), a2=rep("2",nsnps), bp=1:nsnps, fileroot=pf) unlink(paste0(pf,".gen")) unlink(paste0(pf,".sample"))
gf <- tempfile() ## genotype file mf <- tempfile() ## marker file write.beagle(A.small, a1=rep("1",nsnps), a2=rep("2",nsnps), bp=1:nsnps, gfile=gf, mfile=mf) head(read.table(gf,header=TRUE)) head(read.table(mf)) unlink(gf) unlink(mf)
NB phase input is a little different to most other formats!
f <- tempfile() write.phase(A.small, file=f) head(scan(f,what="")) unlink(f)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.