[adegenet-forum] PCA with mitochondrial data - error in file

Jombart, Thibaut t.jombart at imperial.ac.uk
Tue Apr 24 11:01:50 CEST 2012


Hello Nicolas, 

there's a bunch of missing lines between 'kea' and the creation of 'obj'. If there's nothing in obj$pop, then that's the reason of the error. Pretty easy to check using:
##
pop(obj)
##

or just printing the object:
##
obj
##

Unless the grouping factor can be easily deduced from the current individual labels (e.g. labels are pop1-ind1), you should read it in R separately, making sure the ordering is consistent. You'd use something along the lines of:
##
popFac <- read.csv("oneColumnFileWithMyGroupsInIt.csv")
popFac <- factor(unlist(popFac))
pop(obj) <- popFac
##

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 nicolas dussex [nicolas.dussex at gmail.com]
Sent: 24 April 2012 04:27
To: adegenet-forum at lists.r-forge.r-project.org
Subject: [adegenet-forum] PCA with mitochondrial data - error in file

Hi there,

I've been trying to perfomr a PCA on mitochondrial data but there's been a problem that I haven't been able to solve.

I've been able to open my phylip file :

> kea<-read.dna("kea.phy")
  > kea
> pca1 <- dudi.pca(obj$tab, cent = TRUE, scale = FALSE, scannf = FALSE, nf = 3)
> pca1
Duality diagramm
class: pca dudi
$call: dudi.pca(df = obj$tab, center = TRUE, scale = FALSE, scannf = FALSE,
    nf = 3)
$nf: 3 axis-components saved
$rank: 5
eigen values: 1.296 0.3866 0.2515 0.05097 0.03569
  vector length mode    content
1 $cw    14     numeric column weights
2 $lw    53     numeric row weights
3 $eig   5      numeric eigen values

 data.frame nrow ncol content
1 $tab       53   14   modified array
2 $li        53   3    row coordinates
3 $l1        53   3    row normed scores
4 $co        14   3    column coordinates
5 $c1        14   3    column normed scores
other elements: cent norm

but then, when I try to crate a scatter plot:

>s.class(pca1$li, obj$pop, lab = obj$pop.names, sub = "PCA 1-2", csub = 2)

I get the following error message:

Erreur dans s.class(pca1$li, obj$pop, lab = obj$pop.names, sub = "PCA 1-2",  :
  factor expected for fac

Is it because my object lacks population information (groupings)? If so, how can I eiterh modify my .phy file or add the population information in R.

Many Thanks!


Nic
--
Nicolas Dussex
PhD Candidate
Department of Zoology
University of Otago
340 Great King Street
P.O.Box 56
Dunedin 9054
New Zealand

Mobile: 021 02790938


More information about the adegenet-forum mailing list