[adegenet-forum] data input from dataframe

Jombart, Thibaut t.jombart at imperial.ac.uk
Fri Nov 28 14:39:58 CET 2014


Hi,
from ?df2genind:
" The function ‘df2genind’ converts a data.frame (or a matrix) into
     a genind object. The data.frame must meet the following
     requirements:
     - genotypes are in row (one row per genotype)
     - markers are in columns
     - each element is a string of characters coding alleles
"

Which 'scot' does not fulfil, as it contains no-marker data.
You probably want to use something like:
df2genind(scot[, -(1:2)], ...)

Cheers
Thibaut

________________________________
From: adegenet-forum-bounces at lists.r-forge.r-project.org [adegenet-forum-bounces at lists.r-forge.r-project.org] on behalf of Mark Coulson [coulsonmw at gmail.com]
Sent: 28 November 2014 13:22
To: adegenet-forum at lists.r-forge.r-project.org
Subject: [adegenet-forum] data input from dataframe

Ok, so I got rid of my 'River' column so it is now Col 1 is a population label name and col 2 is an individual identifier. the remaining columns are the genotype data now reading 4 digits (i.e. 0206, 1220, etc.).

scot <- read.table("Scotland_adegenet_no_river_names.txt", header=TRUE, sep="\t", quote="\"", colClasses="character", stringsAsFactors=FALSE)

executing the conversion via

df2genind(scot, sep="", ind.names=scot$Individual, pop=scot$Population, missing="0", ploidy=2, type="codom", ncode=4)

I still get the following error

Error in as.matrix(as.data.frame(strsplit(X, sep))) :
  error in evaluating the argument 'x' in selecting a method for function 'as.matrix': Error in data.frame(c("A", "n", "n", "A", "e"), c("A", "n", "n", "A",  :
  arguments imply differing number of rows: 5, 10, 8, 7, 9, 12, 11, 16, 17, 14, 13, 15, 18, 25, 27, 23, 21, 26, 20, 19, 22, 24, 6, 4, 1


While I can get the genepop file accepted, being able to take a dataframe as indicated would be much easier for what I am hoping to do and the size of the datasets etc.

Cheers,
Mark
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/adegenet-forum/attachments/20141128/7b7211ef/attachment.html>


More information about the adegenet-forum mailing list