[adegenet-forum] importing data frame as a genind object
Mark Coulson
coulsonmw at gmail.com
Mon Dec 1 14:01:54 CET 2014
My data are structured as follows
C1 C2 C3 C4
etc.
Population Individual Locus1 Locus2 etc.
PopA C0001 0205 1326 etc.
PopA C0002
etc
etc
etc
PopB X0001
PopB X0002
etc.
.
.
.
Missing data coded as NA
Issued the following commands
scotdata <- read.table("Scotland_adegenet_no_river_names.txt", header=TRUE,
sep="\t", quote="\"", colClasses="character", stringsAsFactors=FALSE)
scotind <- df2genind(scotdata[,-(1:2)], sep="",
ind.names=scotdata$Individual, pop=scotdata$Population, missing="NA",
ploidy=2, type="codom", ncode=4)
This converted it to a genind format and issuing 'scotind' gave the correct
number of loci, individuals, etc.
However, x <- summary(scotind) gave exactly 10 alleles per locus and
massive differences between Hexp and Hobs. I have since made a modified
genepop file which reads in correctly and gives the correct number of
alleles, Hexp, Hobs, etc. (however see my other post for DAPC issues!). So
I can go with this for now, but routinely would find the dataframe format
above easier to work with given large datasets.
Cheers,
Mark
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/adegenet-forum/attachments/20141201/70eb9c9e/attachment.html>
More information about the adegenet-forum
mailing list