I was converting a genind to a gtype and got this error:
Error: no ids in 'schemes' are in 'gen.data' or 'ind.names'
Traceback:
1. genind2gtypes(cp)
2. df2gtypes(x = gen.mat, ploidy = x@ploidy[1], id.col = NULL, strata.col = if (has.pop) 1 else NULL,
. loc.col = if (has.pop) 2 else 1, schemes = x@strata, other = list(genind = adegenet::other(x)))
3. methods::new("gtypes", gen.data = gen.data, ploidy = ploidy,
. ind.names = ind.names, strata = strata, schemes = schemes,
. sequences = sequences, description = description, other = if (is.null(other)) list() else other)
4. initialize(value, ...)
5. initialize(value, ...)
6. .local(.Object, ...)
7. stop("no ids in 'schemes' are in 'gen.data' or 'ind.names'",
. call. = FALSE)
These are the parameters of my genind object:
/// GENIND OBJECT /////////
// 605 individuals; 2,809 loci; 5,618 alleles; size: 14.6 Mb
// Basic content
@tab: 605 x 5618 matrix of allele counts
@loc.n.all: number of alleles per locus (range: 2-2)
@loc.fac: locus factor for the 5618 columns of @tab
@all.names: list of allele names for each locus
@ploidy: ploidy of each individual (range: 2-2)
@type: codom
@call: repool(c(D, N, F, DFf1, DFf2, DFf1xD, DFf1xF, DFf1DxD, DFf1FxF,
DFf1xN, DNf1, DNf2, DNf1xD, DNf1DxD, DNf1xN, DNf1NxN, DNf1xF,
DNf1FxF, FNf1, FNf2, FNf1xF, FNf1FxF, FNf1xN, FNf1NxN, FNf1NNxN,
FNf1xD, FNf1DxD))
// Optional content
@pop: population of each individual (group size range: 20-40)
@strata: a data frame with 2 columns ( INDIVIDUALS, POP_ID )
It seems like genind2gtype is setting the schemes parameter as as strata(genind), so it is getting an error because my strata(genind) columns have a different name than 'id' as required by schemes. I was able to avoid the error by changing the column name: colnames(strata(sim.gind)) <- c("id","POP_ID")
Thanks for the heads up on this. I am wrapping up some bug fixes and major updates to strataG this month and will make sure this issue is addressed in that.
I was converting a genind to a gtype and got this error:
These are the parameters of my genind object:
It seems like genind2gtype is setting the schemes parameter as as strata(genind), so it is getting an error because my strata(genind) columns have a different name than 'id' as required by schemes. I was able to avoid the error by changing the column name:
colnames(strata(sim.gind)) <- c("id","POP_ID")