snpStatsWriter

Chris Wallace // web // email

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.

snphap

f <- tempfile()
write.snphap(A.small, file=f)
head(read.table(f,sep="\t"))
unlink(f)

mach

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)

impute

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"))

beagle

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)

phase/fastPhase

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)


chr1swallace/snpStatsWriter documentation built on May 13, 2019, 6:20 p.m.