Mercurial > repos > vmarcon > pcafactominer
annotate pcaFactoMineR_functions.R @ 0:7acfb3bdad66 draft default tip
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
author | vmarcon |
---|---|
date | Thu, 18 Jan 2018 07:57:36 -0500 |
parents | |
children |
rev | line source |
---|---|
0
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
1 #################### fonctions utilisées ##################################################### |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
2 |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
3 standardisation <- function(rawX,centrage=TRUE,scaling=c("none","uv","pareto")) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
4 { |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
5 # rawX : matrice nxp contenant les données brutes |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
6 # Forme à confirmer avec SLA colonne 1 = identifiant,colonne 2 = facteur biologique??? |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
7 # Si oui "supprimer" ces 2 colonnes pour n'avoir que variables quantitatives |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
8 # centrage = parametre booleen (TRUE/FALSE),par défaut = TRUE,indiquant si centrage donnees à faire |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
9 # scaling = nom de la methode de standardisation à appliquer aux donnees |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
10 # none = aucune standardisation |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
11 # uv = division par ecart type |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
12 # pareto = division par racine carree ecart type |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
13 # scaledX : matrice nxp contenant les variables quantitatives standardisees (centrage +/- scaling) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
14 scaledX <- prep(rawX,center=centrage,scale=scaling) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
15 return(scaledX) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
16 } |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
17 |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
18 ############################################################################################### |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
19 plot_ebouli <- function(res.PCA,mt,cexc) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
20 { |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
21 # res.PCA résultat de l'ACP est renvoyé par la fonction PCA (factoMineR) de type list contient |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
22 # l'ensemble des résultats dont les valeurs propres et % variance assicées à chaque cp |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
23 # La fonction plot les valeurs propres et les % de variance |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
24 # expliquée par chaque composante et la variance cumulée |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
25 |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
26 eig <- res.PCA$eig |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
27 barplot(eig[[1]]) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
28 #abline(h=1) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
29 title(main=mt,sub="Eigen values") |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
30 barplot(eig[[2]],ylim=c(0,100)) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
31 points(eig[[3]],type="b") |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
32 title(main=mt,sub="Variance explained",cex=cexc) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
33 |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
34 } |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
35 |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
36 ############################################################################################### |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
37 plot.contrib <- function(res.PCA,mt,cexc) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
38 { |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
39 # Fonction de plot des contributions sur les n composantes |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
40 # principales choisies par l'utilisateur (lastpc) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
41 # En entrée,la fonction prend le résultats de l'ACP FactoMineR de type list |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
42 |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
43 lastpc <- dim(res.PCA$var$contrib)[2] |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
44 ## plot contributions |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
45 contrib <- res.PCA$var$contrib |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
46 for (c in 1:lastpc) { |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
47 barplot(quantile(contrib[,c],probs=seq(0,1,0.025))) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
48 title(main=mt,sub=paste("Quantile plot Contrib PC",c,sep=""),cex=cexc) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
49 barplot(contrib[order(contrib[,c]),1]) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
50 title(main=mt,sub=paste("Contributions PC",c,sep=""),cex=cexc) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
51 } |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
52 } |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
53 |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
54 ############################################################################################### |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
55 pca.var <- function(res.PCA,contribmin=c(0,0),mt,cexc,linev=3,plotax=c(1,2)) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
56 { |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
57 # Loading plot avec eventuellement selection des variables par leurs contributions |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
58 # En entrée,la fonction prend le résultats de l'ACP FactoMineR de type list |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
59 # On passe en arguments : les contributions pour les 2 axes définis par l'utilisateur, |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
60 # le titre du graphique,la taille des caractères (cex), |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
61 # ??? est-ce que la fonction doit plotter toutes les composantes ??? |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
62 |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
63 ### sélection des variables sur leur contribution. |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
64 # les valeurs des contributions par défaut (0,0) permettent d'afficher |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
65 # toutes les variables. |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
66 selvar=c(which(res.PCA$var$contrib[,plotax[1]]>contribmin[1]), |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
67 which(res.PCA$var$contrib[,plotax[2]]>contribmin[2])) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
68 selvar <- selvar[!duplicated(selvar)] |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
69 fres.PCA <- res.PCA |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
70 fres.PCA$var$coord <- res.PCA$var$coord[selvar,] |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
71 fres.PCA$var$cor <- res.PCA$var$cor[selvar,] |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
72 fres.PCA$var$cos2 <- res.PCA$var$cos2[selvar,] |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
73 fres.PCA$var$contrib <- res.PCA$var$contrib[selvar,] |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
74 |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
75 #### Plot du cercle des corrélations |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
76 plot.PCA(fres.PCA,choix="var",cex=cexc,axes=plotax,title=NULL, habillage=1) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
77 title(main = mt,line = linev,cex=cexc) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
78 } |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
79 |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
80 ############################################################################################### |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
81 pca.indiv <- function(res.PCA,hb,facteur=NULL,contribmin=c(0,0),mt,cexc,linev=3,plotax=c(1,2)) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
82 { |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
83 # Espace des individus |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
84 # En entrée,la fonction prend le résultats de l'ACP FactoMineR de type list |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
85 # On passe en arguments : les contributions pour les 2 axes définis par l'utilisateur, |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
86 # le titre du graphique,la taille des caractères (cex), |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
87 # ??? est-ce que la fonction doit plotter toutes les composantes ??? |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
88 selvar=c(which(res.PCA$var$contrib[,plotax[1]]>contribmin[1]), |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
89 which(res.PCA$var$contrib[,plotax[2]]>contribmin[2])) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
90 |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
91 fres.PCA <- res.PCA |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
92 fres.PCA$var$coord <- res.PCA$var$coord[selvar,] |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
93 fres.PCA$var$cor <- res.PCA$var$cor[selvar,] |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
94 fres.PCA$var$cos2 <- res.PCA$var$cos2[selvar,] |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
95 fres.PCA$var$contrib <- res.PCA$var$contrib[selvar,] |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
96 |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
97 #### Plot l'espace des individus |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
98 if (hb ==1 ) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
99 { |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
100 aa <- cbind.data.frame(facteur,res.PCA$ind$coord) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
101 bb <- coord.ellipse(aa,bary=TRUE,level.conf=0.99) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
102 |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
103 colVal = rainbow(length(unique(facteur))) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
104 plot.PCA(fres.PCA,choix="ind",habillage=1,cex=cexc,axes=plotax,title=NULL,invisible="quali") |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
105 title(main = mt,line = linev,cex=cexc) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
106 |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
107 plot.PCA(fres.PCA,choix="ind",habillage=1,label="none",cex=cexc,axes=plotax,title=NULL,ellipse=bb) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
108 title(main = mt,line = linev,cex=cexc) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
109 } |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
110 else |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
111 { |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
112 plot.PCA(fres.PCA,choix="ind",cex=cexc,axes=plotax,title=NULL) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
113 title(main = mt,line = linev,cex=cexc) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
114 } |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
115 } |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
116 |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
117 ############################################################################################### |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
118 ## MODIFICATIONS 15062017 |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
119 ## Suppression standardisation car fonction externe |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
120 ## Concatenation samplemetadata et datamatrix avec merge si pas meme ordre de tri |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
121 ## HYPOTHESES : 1) datamatrix : nxp et 2) colonne 1 = identifiants individus |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
122 ############################################################################################### |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
123 |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
124 pca.main <- function(ids,bioFact,ncp,hb=0,minContribution=c(0,0),mainTitle=NULL,textSize=0.5,linev=3, |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
125 principalPlane=c(1,2),eigenplot=0,contribplot=0,scoreplot=0,loadingplot=0,nomGraphe, |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
126 variable_in_line=0,log_file) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
127 { |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
128 |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
129 res<-NULL |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
130 |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
131 ## Variable in line or column? |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
132 if (variable_in_line==1){ |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
133 column_use="individual" |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
134 line_use="variable" |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
135 } else { |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
136 line_use="individual" |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
137 column_use="variable" |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
138 } |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
139 |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
140 |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
141 ## Fonction d'écriture du fichier de log |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
142 |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
143 log_error=function(message="") { |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
144 cat("<HTML><HEAD><TITLE>PCA FactoMineR report</TITLE></HEAD><BODY>\n",file=log_file,append=F,sep="") |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
145 cat("⚠ An error occurred while trying to read your table.\n<BR>",file=log_file,append=T,sep="") |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
146 cat("Please check that:\n<BR>",file=log_file,append=T,sep="") |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
147 cat("<UL>\n",file=log_file,append=T,sep="") |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
148 cat(" <LI> the table you want to process contains the same number of columns for each line</LI>\n",file=log_file,append=T,sep="") |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
149 cat(" <LI> the first line of your table is a header line (specifying the name of each ",column_use,")</LI>\n",file=log_file,append=T,sep="") |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
150 cat(" <LI> the first column of your table specifies the name of each ",line_use,"</LI>\n",file=log_file,append=T,sep="") |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
151 cat(" <LI> both individual and variable names should be unique</LI>\n",file=log_file,append=T,sep="") |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
152 cat(" <LI> each value is separated from the other by a <B>TAB</B> character</LI>\n",file=log_file,append=T,sep="") |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
153 cat(" <LI> except for first line and first column, table should contain a numeric value</LI>\n",file=log_file,append=T,sep="") |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
154 cat(" <LI> this value may contain character '.' as decimal separator </LI>\n",file=log_file,append=T,sep="") |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
155 cat("</UL>\n",file=log_file,append=T,sep="") |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
156 cat("-------<BR>\nError messages recieved :<BR><FONT color=red>\n",conditionMessage(message),"</FONT>\n",file=log_file,append=T,sep="") |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
157 cat("</BODY></HTML>\n",file=log_file,append=T,sep="") |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
158 q(save="no",status=1) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
159 } |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
160 |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
161 # Sortie graphique |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
162 if (eigenplot==1 || contribplot==1 || scoreplot==1 || loadingplot==1) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
163 pdf(nomGraphe,onefile=TRUE) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
164 |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
165 # Verify data |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
166 verif_data=function(){ |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
167 if (length(dim(ids)) != 2 | ncol(ids) < 2 | nrow(ids) < 2) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
168 log_error(simpleCondition("The table on which you want to do PCA must be a data table with at least 2 rows and 2 columns.")) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
169 |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
170 tab=as.matrix(data) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
171 cell.with.na=c() |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
172 colstart=2-variable_in_line # |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
173 for (i in colstart:ncol(tab)) { |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
174 na.v1=is.na(tab[,i]) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
175 na.v2=is.na(as.numeric(tab[,i])) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
176 if (sum(na.v1)!=sum(na.v2)) { |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
177 sel=which(na.v1!=na.v2) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
178 sel=sel[1] |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
179 value=tab[sel,i] |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
180 log_error(simpleCondition( |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
181 paste("Column '",colnames(tab)[i],"' of your table contains non numeric values. Please check its content (on line #",sel," : value='",value,"'). Maybe you will need to specify that variable are in column.",sep="") |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
182 )) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
183 } |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
184 if (length(cell.with.na)==0 & sum(na.v1)!=0) { |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
185 cell.with.na=c(i,which(na.v1)[1]) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
186 } |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
187 } |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
188 } |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
189 |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
190 |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
191 ## Disposition matrice de donnees |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
192 ## Transposition si variables en ligne |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
193 Tids <- ids |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
194 if (variable_in_line == 1) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
195 { |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
196 Tids <- Tids[,-1] |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
197 Tids <- t(Tids) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
198 Tids <- data.frame(rownames(Tids), Tids) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
199 colnames(Tids)[1] <- "Sample" |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
200 } |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
201 rownames(Tids) <- as.character(Tids[,1]) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
202 |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
203 |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
204 ## suivant la presence variable qualitative (hb=1),l'appel a la fonction PCA est modifié |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
205 if (hb==1) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
206 { |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
207 ## Concatenation |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
208 data <- merge(bioFact,Tids,by.x=1,by.y=1) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
209 rownames(data) <- as.character(data[,1]) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
210 ## Suppression identifiants individus |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
211 data <- data[,-1] |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
212 data[,1] <- as.factor(data[,1]) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
213 facteur <- as.factor(bioFact[,-1]) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
214 verif_data() |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
215 |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
216 ## Analyse |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
217 res <- PCA(data,scale.unit=FALSE,ncp,graph=F,quali.sup=1) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
218 } |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
219 else |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
220 { |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
221 ## Suppression identifiants individus |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
222 data <- Tids[,-1] |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
223 verif_data() |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
224 |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
225 ## Analyse |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
226 res <- PCA(data,scale.unit=FALSE,ncp,graph=F) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
227 } |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
228 |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
229 if (eigenplot==1) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
230 { |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
231 par(mfrow=c(1,2)) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
232 plot_ebouli(res,mt=mainTitle,cexc=textSize) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
233 } |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
234 |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
235 if (contribplot==1) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
236 { |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
237 par(mfrow=c(1,2)) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
238 plot.contrib(res,mt=mainTitle,cexc=textSize) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
239 } |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
240 |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
241 if (scoreplot==1) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
242 { |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
243 if (hb==0) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
244 { |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
245 par(mfrow=c(1,1)) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
246 pca.indiv(res,hb=0,contribmin=minContribution,mt=mainTitle,cexc=textSize,plotax=principalPlane) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
247 } |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
248 if (hb==1) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
249 { |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
250 par(mfrow=c(1,1)) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
251 pca.indiv(res,hb=1,facteur=facteur,contribmin=minContribution,mt=mainTitle,cexc=textSize,plotax=principalPlane) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
252 } |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
253 } |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
254 if (loadingplot==1) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
255 { |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
256 par(mfrow=c(1,1)) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
257 pca.var(res,contribmin=minContribution,mt=mainTitle,cexc=textSize,plotax=principalPlane) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
258 } |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
259 |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
260 if (eigenplot==1 || contribplot==1 || scoreplot==1 || loadingplot==1) |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
261 dev.off() |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
262 |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
263 |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
264 if (!is.null(res)){ |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
265 cat("<HTML><HEAD><TITLE>PCA FactoMineR report</TITLE></HEAD><BODY>\n",file=log_file,append=F,sep="") |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
266 cat("✓ Your process is successfull !<BR>",file=log_file,append=T,sep="") |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
267 cat("</BODY></HTML>\n",file=log_file,append=T,sep="") |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
268 |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
269 |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
270 |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
271 } |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
272 } |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
273 |
7acfb3bdad66
planemo upload commit a2411926bebc2ca3bb31215899a9f18a67e59556
vmarcon
parents:
diff
changeset
|
274 ############################################################################################### |