Closed jgx65 closed 8 years ago
@EricArcher Not sure what you were trying to fix in genind2hierfstat
. You mentioned genotypes encoded as eg 1_11
. do you mean that _
is a separator for the two alleles? If you run the example above, you'll see that genind2hierfstat
new version does not give the expected result (i.e., same as head(dat1)
)
Hmmm... Sorry about that. The problem I was having was that I was getting a matrix of NAs for some datasets. I traced it to the following lines in the previous version of genind2hierfstat
:
x<-genind2df(dat,sep="",usepop=FALSE)
#to catch alleles encoded with letters, e.g. H3N2
if (length(grep("[A-Z]",alleles.name))==0) x<-as.matrix(data.frame(lapply(x,as.integer)))
genind2df
was regenerating a data.frame with my original allele names (which were like 1_11
). It didn't matter that they had a _
as a separator, it was that they did not have any letters, but they were not numeric, so the as.integer
conversion was converting everything to NA
.
I'm trying to duplicate my original error, and then if I can, will fix my fix to produce the correct output (I misunderstood the output format). Back soon...
I see. Basically, you'd like any character string to be a valid allele name, correct? I was trying to avoid using factor in the initial version because it could sometimes slow down things quite drastically. We could keep the classic integers, the nucleotides, and then something for anything else?
I should've known that you'd already gone the factor route and hadn't chosen it for the sake of efficiency. I like your suggestion. I'll start with the previous version of the code again and add that in.
Reverts jgx65/hierfstat#13 The modified function does not work: