View source: R/population_stats.R
freq.to.genpop | R Documentation |
Given a data frame of allele frequencies such as that produced by
simpleFreq
or deSilvaFreq
, freq.to.genpop
creates a
data frame of allele counts that can be read by the as.genpop
function in the package adegenet.
freq.to.genpop(freqs, pops = row.names(freqs), loci = unique(as.matrix(as.data.frame(strsplit(names(freqs), split = ".", fixed = TRUE), stringsAsFactors = FALSE))[1, ]))
freqs |
A data frame of allele frequencies. Row names are population names.
The first column is called |
pops |
An optional character vector indicating the names of populations to use. |
loci |
An optional character vector indicating the names of loci to use. |
adegenet expects one ploidy for the entire dataset. Therefore, data
frames of allele frequencies with multiple “Genomes” columns,
such as those produced when ploidy varies by locus, are not allowed as
the freqs
argument.
A data frame with row and column names identical to those in
freqs
, minus the "Genomes"
column and any columns for loci
not included in loci
. Allele frequencies are converted to counts
by multiplying by the values in the "Genomes"
column and rounding
to the nearest integer.
Lindsay V. Clark
Jombart, T. (2008) adegenet: a R package for the multivariate analysis of genetic markers. Bioinformatics 24, 1403-1405.
simpleFreq
, deSilvaFreq
,
write.freq.SPAGeDi
, gendata.to.genind
# create a simple allele frequency table # (usually done with simpleFreq or deSilvaFreq) myfreq <- data.frame(row.names=c("popA","popB"), Genomes=c(120,100), locG.152=c(0.1,0.4), locG.156=c(0.5, 0.3), locG.160=c(0.4, 0.3), locK.179=c(0.15, 0.25), locK.181=c(0.35, 0.6), locK.183=c(0.5, 0.15)) myfreq # convert to adegenet format gpfreq <- freq.to.genpop(myfreq) gpfreq ## Not run: # If you have adegenet installed, you can now make this into a # genpop object. require(adegenet) mygenpop <- genpop(gpfreq, ploidy=as.integer(4), type="codom") # examine the object that has been created mygenpop popNames(mygenpop) mygenpop@tab mygenpop@all.names # Perform a distance calculation with the object dist.genpop(mygenpop) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.