adeverse / ade4

Analysis of Ecological Data : Exploratory and Euclidean Methods in Environmental Sciences
http://adeverse.github.io/ade4/
38 stars 10 forks source link

Error in if (n0 == 6) return(cha) : missing value where TRUE/FALSE needed #6

Closed mmaalvarez closed 7 years ago

mmaalvarez commented 7 years ago

Hi, I am having a problem when trying to convert genotype data into a genet object in order to then compute the genetic distances. Namely, I am running:

library("ade4")
library("readr")

file = read_delim("file.txt", " ", escape_double = FALSE, col_names = FALSE, trim_ws = TRUE)
rownames(file) = file$X1
file$X1 = NULL
file = as.data.frame(file)

data.genet <- char2genet(file, as.factor(rep(c("Ady", "Alg", "Bas", "Bed", "CEU", "Dru", "Egy", "ESN", "FIN", "Fre", "GBR", "GWD", "IBS", "Ita", "Lib", "LWK", "MoN", "MoS", "Moz", "MSL", "Orc", "Pal", "Rus", "Sah", "Sar", "Spa", "TSI", "TUN", "Tus", "YRI"), c(7,9,16,26,49,12,19,53,38,12,46,55,54,7,16,44,18,8,19,42,7,16,16,18,16,20,53,18,5,52))))

ldist <- dist.genet(data.genet, 3))

But in the char2genet part, it prints:

Error in if (n0 == 6) return(cha) : missing value where TRUE/FALSE needed

I do not know which is the problem, the format of 'file.txt' is apparently the same as 'casitas': file.txt

sdray commented 7 years ago

Hi,

please use functions of the adegenet package to analyze you genetic data (functions in ade4 are less efficient and would be deprecated soon).