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

nicolas dussex nicolas.dussex at gmail.com
Tue Apr 24 05:27:01 CEST 2012


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*

*53 DNA sequences in binary format stored in a matrix.*

* All sequences of same length: 1026 *

*Labels: Arth_Jo105 Arth_Jo98 Arth_V0610 Arth_V0391 Arth_V0753 Arth_V1280
...*

* Base composition:*

*    a     c     g     t*

*0.276 0.254 0.158 0.312*

 ..and then created a genind object

*> obj <- DNAbin2genind(kea, polyThres = 0.01)*

*> obj*

* *

*   #####################*

*   ### Genind object ### *

*   #####################*

*- genotypes of individuals - *

* *

*S4 class:  genind*

*@call: DNAbin2genind(x = kea, polyThres = 0.01)*

* *

*@tab:  53 x 14 matrix of genotypes*

* *

*@ind.names: vector of  53 individual names*

*@loc.names: vector of  7 locus names*

*@loc.nall: number of alleles per locus*

*@loc.fac: locus factor for the  14 columns of @tab*

*@all.names: list of  7 components yielding allele names for each locus*

*@ploidy:  1*

*@type:  codom*

* *

*Optionnal contents: *

*@pop:  - empty -*

*@pop.names:  - empty -*

* *

*@other: - empty -*
...then I performed a PCA:

*> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/adegenet-forum/attachments/20120424/c7a8f58d/attachment.html>


More information about the adegenet-forum mailing list