# NOT RUN {
# set up a genambig object to use in this example
mygen <- new("genambig", samples=c(paste("G", 1:30, sep=""),
paste("R", 1:50, sep="")),
loci=c("afrY", "ggP"))
PopNames(mygen) <- c("G", "R")
PopInfo(mygen) <- c(rep(1, 30), rep(2, 50))
mygen <- reformatPloidies(mygen, output="one")
Ploidies(mygen) <- 4
Usatnts(mygen) <- c(2, 2)
# randomly create genotypes according to pre-set allele frequencies
for(s in Samples(mygen, populations=1)){
Genotype(mygen, s, "afrY") <-
unique(sample(c(140, 142, 146, 150, 152), 4, TRUE,
c(.30, .12, .26, .08, .24)))
Genotype(mygen, s, "ggP") <-
unique(sample(c(210, 214, 218, 220, 222), 4, TRUE,
c(.21, .13, .27, .07, .32)))
}
for(s in Samples(mygen, populations=2)){
Genotype(mygen, s, "afrY") <-
unique(sample(c(140, 142, 144, 150, 152), 4, TRUE,
c(.05, .26, .17, .33, .19)))
Genotype(mygen, s, "ggP") <-
unique(sample(c(212, 214, 220, 222, 224), 4, TRUE,
c(.14, .04, .36, .20, .26)))
}
# write a SPAGeDi file
write.SPAGeDi(mygen, file="SPAGdataFreqExample.txt")
# calculate allele frequenies
myfreq <- deSilvaFreq(mygen, self = 0.05)
# write allele frequencies file
write.freq.SPAGeDi(myfreq, usatnts=Usatnts(mygen),
file="SPAGfreqExample.txt")
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab