EricArcher/strataG

error in SFS calculation

Farhad63 opened this issue · 1 comments

Hi I appreciate if you could help me
I get an error when I run this sfs on my SNP data which I I have converted to data-frame.
command: mysfs<- sfs(mydata, strata.col=2, locus.col = 3, sort.strata = FALSE, na.action ="filter")
Error: Error in FUN(X[[i]], ...) : 'x' must be numeric
my dataframe structure is like this below which is produced by conversion of gtypes to dataframe.
I imagine is my dataframe is it any specific function to convert genind, gl or gtype to data frame with 1, 0, 2 formats required for sfs analysis ?
id stratum SNP1 SNP2 SNP3 SNP4.......................... SNPn
ind1 1 01 02
ind1 1
ind2 .
ind2 .
. .
indn .

The SNP columns should be numerics (or integers). For the argument 'x', the help file says:

a data frame of SNP genotypes where the first two columns are id and strata designations and SNPs start on the third column. SNP genotypes are coded as integers where 0 and 2 are the major and minor homozygotes and 1 is the heterozygote.

From your output below, having values like 01 and 02 implies they are stored as characters or factors. Convert them, then try running it again.