<div dir="ltr">FYI - this is fixed in the tab function itself, but seems not to update the rest of the genind object when applied to genind@tab. So for example, if you import to genind, use tab(x, NA.method="mean") on the x@tab, then export using genind2df, it will fail. Also, did the old NA.method="mean" replace missing values with median alleles? This v gives a mean, which is not ideal if other programs are expecting integers.<div><br></div><div>I'm still using my above code as a workaround.</div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature"><div dir="ltr"><div><br></div><div>----------------------------------------------</div><div>Paul Maier</div><div><br></div><div>San Diego State, PhD Student</div><div>US Geological Survey, Biologist</div><div>The Biodiversity Group, Science Advisor</div><div><br></div></div></div></div>
<br><div class="gmail_quote">On Thu, Jul 16, 2015 at 4:25 AM, Jombart, Thibaut <span dir="ltr"><<a href="mailto:t.jombart@imperial.ac.uk" target="_blank">t.jombart@imperial.ac.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Fixed now:<br>
<a href="https://github.com/thibautjombart/adegenet/issues/71#issuecomment-121790358" rel="noreferrer" target="_blank">https://github.com/thibautjombart/adegenet/issues/71#issuecomment-121790358</a><br>
<br>
And readily available in the devel version:<br>
<br>
install.packages("devtools")<br>
library(devtools)<br>
install_github("thibautjombart/adegenet")<br>
library("adegenet")<br>
<br>
Cheers<br>
Thibaut<br>
<br>
<br>
<br>
<br>
________________________________________<br>
From: <a href="mailto:adegenet-forum-bounces@lists.r-forge.r-project.org">adegenet-forum-bounces@lists.r-forge.r-project.org</a> [<a href="mailto:adegenet-forum-bounces@lists.r-forge.r-project.org">adegenet-forum-bounces@lists.r-forge.r-project.org</a>] on behalf of Jombart, Thibaut [<a href="mailto:t.jombart@imperial.ac.uk">t.jombart@imperial.ac.uk</a>]<br>
Sent: 16 July 2015 11:50<br>
To: Zhian Kamvar; <a href="mailto:adegenet-forum@lists.r-forge.r-project.org">adegenet-forum@lists.r-forge.r-project.org</a><br>
<div class="HOEnZb"><div class="h5">Subject: Re: [adegenet-forum] read.genepop (adegenet 2.0.0 with R v. 3.2.1)<br>
<br>
Looks like a bug indeed. Thanks for spotting it. Will fix today.<br>
<br>
Cheers<br>
Thibaut<br>
<br>
<br>
________________________________________<br>
From: <a href="mailto:adegenet-forum-bounces@lists.r-forge.r-project.org">adegenet-forum-bounces@lists.r-forge.r-project.org</a> [<a href="mailto:adegenet-forum-bounces@lists.r-forge.r-project.org">adegenet-forum-bounces@lists.r-forge.r-project.org</a>] on behalf of Zhian Kamvar [<a href="mailto:zkamvar@gmail.com">zkamvar@gmail.com</a>]<br>
Sent: 16 July 2015 01:35<br>
To: <a href="mailto:adegenet-forum@lists.r-forge.r-project.org">adegenet-forum@lists.r-forge.r-project.org</a><br>
Subject: Re: [adegenet-forum] read.genepop (adegenet 2.0.0 with R v. 3.2.1)<br>
<br>
This smells like a bug. After poking around some, it is indeed one in read.fstat and read.genepop. (Both read.genetix and read.structure still work):<br>
<br>
> obj <- read.genepop(system.file("files/nancycats.gen",package="adegenet"))<br>
<br>
Converting data from a Genepop .gen file to a genind object...<br>
<br>
<br>
File description: Genotypes of cats from 17 colonies of Nancy (France)<br>
<br>
...done.<br>
<br>
> obj<br>
/// GENIND OBJECT /////////<br>
<br>
// 237 individuals; 9 loci; 111 alleles; size: 138.5 Kb<br>
<br>
// Basic content<br>
@tab: 237 x 111 matrix of allele counts<br>
@loc.n.all: number of alleles per locus (range: 8-18)<br>
@loc.fac: locus factor for the 111 columns of @tab<br>
@all.names: list of allele names for each locus<br>
@ploidy: ploidy of each individual (range: 2-2)<br>
@type: codom<br>
@call: read.genepop(file = system.file("files/nancycats.gen", package = "adegenet"))<br>
<br>
// Optional content<br>
@pop: population of each individual (group size range: 9-23)<br>
> summary(obj)<br>
<br>
# Total number of genotypes: 237<br>
<br>
# Population sample sizes:<br>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17<br>
10 22 12 23 15 11 14 10 9 11 20 14 13 17 11 12 13<br>
<br>
# Number of alleles per locus:<br>
fca8 fca23 fca43 fca45 fca77 fca78 fca90 fca96 fca37<br>
17 11 10 10 12 8 12 13 18<br>
<br>
# Number of alleles per population:<br>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17<br>
37 53 50 67 48 56 43 54 43 46 73 53 44 62 42 40 37<br>
<br>
# Percentage of missing data:<br>
[1] 0<br>
<br>
# Observed heterozygosity:<br>
fca8 fca23 fca43 fca45 fca77 fca78 fca90 fca96 fca37<br>
0.6118143 0.6666667 0.6793249 0.6455696 0.6329114 0.5654008 0.6497890 0.5949367 0.4514768<br>
<br>
# Expected heterozygosity:<br>
fca8 fca23 fca43 fca45 fca77 fca78 fca90 fca96 fca37<br>
0.8803076 0.7928751 0.7953319 0.7930531 0.8702576 0.6884669 0.8157881 0.7767630 0.6062686<br>
<br>
This will be reported and fixed.<br>
<br>
Cheers,<br>
Zhian<br>
<br>
> On Jul 15, 2015, at 11:16 , <a href="mailto:adegenet-forum-request@lists.r-forge.r-project.org">adegenet-forum-request@lists.r-forge.r-project.org</a> wrote:<br>
><br>
> On closer inspection, it appears the new version stores missing data as<br>
> alleles (i.e. *.00 in @tab). So using tab to replace the allele counts<br>
> doesn't work. For example, x@tab <- tab(x, NA.method="mean") does nothing<br>
> because missing data is stored as normal data. Here's a workaround I<br>
> created, although probably not the most clever method, it fixed my problem.<br>
> Hopefully this helps someone!<br>
> Paul<br>
><br>
> # Fix missing values to reflect depracated option, missing = "mean"<br>
> x@tab <- x@tab[,-grep("\\.00",colnames(x@tab))] #remove "00" alleles<br>
> rep <- gsub("([^\\.]+)\\.\\d+","\\1",colnames(x@tab)) #locus names<br>
> loci <- unique(x@loc.fac) #unique locus names<br>
> x@loc.fac <- as.factor(rep)<br>
> for (i in 1:length(x@all.names))<br>
> if ("00" %in% x@all.names[[i]]) #remove "00" from allele names<br>
> x@all.names[[i]] <- x@all.names[[i]][-which(x@all.names[[i]]=="00")]<br>
> for (i in 1:length(x@loc.n.all)) #remove "00" from allele counts<br>
> x@loc.n.all[[i]] <- length(x@all.names[[i]])<br>
> for (i in 1:length(loci)) { #replace missing data with mean allele counts<br>
> df <- data.frame(x@tab[,which(loci[i] == rep)]) #df, alleles for one locus<br>
> for (j in 1:nrow(df)) {<br>
> if (sum(df[j,]) == 0) {<br>
> for (k in 1:length(df[j,])) { #mean allele counts from rows with data<br>
> df[j,k] <- round(mean( df[which(apply(df,1,sum) != 0),k] ))<br>
> }<br>
> x@tab[j,which(loci[i] == rep)] <- as.numeric(df[j,])<br>
> }<br>
> }<br>
> }<br>
<br>
_______________________________________________<br>
adegenet-forum mailing list<br>
<a href="mailto:adegenet-forum@lists.r-forge.r-project.org">adegenet-forum@lists.r-forge.r-project.org</a><br>
<a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/adegenet-forum" rel="noreferrer" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/adegenet-forum</a><br>
_______________________________________________<br>
adegenet-forum mailing list<br>
<a href="mailto:adegenet-forum@lists.r-forge.r-project.org">adegenet-forum@lists.r-forge.r-project.org</a><br>
<a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/adegenet-forum" rel="noreferrer" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/adegenet-forum</a><br>
_______________________________________________<br>
adegenet-forum mailing list<br>
<a href="mailto:adegenet-forum@lists.r-forge.r-project.org">adegenet-forum@lists.r-forge.r-project.org</a><br>
<a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/adegenet-forum" rel="noreferrer" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/adegenet-forum</a><br>
</div></div></blockquote></div><br></div>