1 #Author: Pierre Ratinaud
2 #Copyright (c) 20010-2013 Pierre Ratinaud
6 #fichier genere par IRaMuTeq
7 source('%s', encoding = 'utf8')
19 do.select.chi.classe <- %s
38 xlab <- paste('facteur ', x, ' -')
39 ylab <- paste('facteur ', y, ' -')
40 if (!typegraph == 0) {zlab <- paste('facteur ', z, ' -')}
41 xlab <- paste(xlab,round(afc_table$facteur[x,2],2),sep = ' ')
42 xlab <- paste(xlab,' %%',sep = '')
43 ylab <- paste(ylab,round(afc_table$facteur[y,2],2),sep = ' ')
44 ylab <- paste(ylab,' %%',sep = '')
45 if (!typegraph == 0) {
46 zlab <- paste(zlab,round(afc_table$facteur[z,2],2),sep = ' ')
47 zlab <- paste(zlab,' %%',sep = '')
51 if ( what == 0 ) table.in <- afc$colcoord
52 if ( what == 1 ) table.in <- afc$colcrl
53 rownames(table.in) <- afc$colnames
56 table.in<-table.in[,c(x,y)]
58 table.in<-table.in[,c(x,y,z)]
59 rx <- range(table.in[,1], na.rm = TRUE)
60 ry <- range(table.in[,2], na.rm = TRUE)
61 rz <- range(table.in[,3], na.rm = TRUE)
65 cex.par <- rep(taillecar/10, nrow(table.in))
67 if ( what == 0 ) table.in <- afc$rowcoord
68 if ( what == 1 ) table.in <- afc$rowcrl
69 rownames(table.in) <- afc$rownames
70 tablechi <- chistabletot
73 table.in<-table.in[,c(x,y)]
75 table.in<-table.in[,c(x,y,z)]
76 rx <- range(table.in[,1], na.rm = TRUE)
77 ry <- range(table.in[,2], na.rm = TRUE)
78 rz <- range(table.in[,3], na.rm = TRUE)
80 if (exists('afctable')) {
81 eff <- rowSums(afctable)
86 if (!is.null(debsup)) {
88 table.in <- table.in[1:(debsup-1),]
89 tablechi <- tablechi[1:(debsup-1),]
90 cex.par <- eff[1:(debsup-1)]
93 table.in <- table.in[debsup:(debet-1),]
94 tablechi <- tablechi[debsup:(debet-1),]
95 cex.par <- eff[debsup:(debet-1)]
99 table.in <- table.in[debet:nrow(table.in),]
100 tablechi <- tablechi[debet:nrow(tablechi),]
101 cex.par <- eff[debet:fin]
105 if (is.null(debsup)) {
107 if (!is.null(debet)) {
108 table.in <- table.in[1:(debet-1),]
109 tablechi <- tablechi[1:(debet-1),]
110 cex.par <- eff[1:(debet-1)]
115 fin <- nrow(table.in)
116 table.in <- table.in[debet:nrow(table.in),]
117 tablechi <- tablechi[debet:nrow(tablechi),]
118 cex.par <- eff[debet:fin]
123 if (select.nb > nrow(table.in)) select.nb <- nrow(table.in)
124 row.keep <- select_point_nb(tablechi, select.nb)
125 table.in <- table.in[row.keep,]
126 tablechi <- tablechi[row.keep,]
127 } else if (do.select.chi) {
128 if (select.chi > max(tablechi)) select.chi <- max(tablechi)
129 row.keep <- select_point_chi(tablechi, select.chi)
130 table.in <- table.in[row.keep,]
131 tablechi <- tablechi[row.keep,]
132 } else if (do.select.chi.classe) {
133 row.keep <- select.chi.classe(tablechi, ptbycluster, active=FALSE)
134 table.in <- table.in[row.keep,]
135 tablechi <- tablechi[row.keep,]
137 row.keep <- 1:nrow(table.in)
139 classes <- apply(tablechi, 1, which.max)
140 maxchi <- apply(tablechi, 1, max)
141 infp <- which(is.infinite(maxchi) & maxchi > 0)
144 if (!length(infp) == length(maxchi)) {
145 valmax <- max(maxchi, na.rm = TRUE)
149 maxchi[infp] <- valmax + 2
152 #row.keep <- append(row.keep, rn.keep)
153 #row.keep <- unique(row.keep)
154 cex.par <- cex.par[row.keep]
155 cex.par <- norm.vec(cex.par, txt.min/10, txt.max/10)
158 cex.par <- norm.vec(cex.par, tchi.min/10, tchi.max/10)
160 cex.par <- rep(taillecar/10, nrow(table.in))
164 if (is.null(xminmax)) {
165 xminmax <- c(min(table.in[,1], na.rm = TRUE) + ((max(cex.par)/10) * min(table.in[,1], na.rm = TRUE)), max(table.in[,1], na.rm = TRUE) + ((max(cex.par)/10) * max(table.in[,1], na.rm = TRUE)))
167 if (is.null(yminmax)) {
168 yminmax <- c(min(table.in[,2], na.rm = TRUE) + ((max(cex.par)/10) * min(table.in[,2], na.rm = TRUE)), max(table.in[,2], na.rm = TRUE) + ((max(cex.par)/10) * max(table.in[,2], na.rm = TRUE)))
171 if (typegraph == 0 || typegraph == 2) {
173 open_file_graph(fileout, width = width, height = height, svg = do.svg)
174 parcex <- taillecar/10
177 table.in <- table.in[order(cex.par, decreasing = TRUE),]
178 classes <- classes[order(cex.par, decreasing = TRUE)]
179 cex.par <- cex.par[order(cex.par, decreasing = TRUE)]
180 table.out <- stopoverlap(table.in, cex.par=cex.par, xlim = xminmax, ylim = yminmax)
181 table.in <- table.out$toplot
182 notplot <- table.out$notplot
183 if (! is.null(notplot)) {
184 write.csv2(notplot, file = paste(fileout,'_notplotted.csv', sep=''))
186 classes <- classes[table.in[,4]]
187 cex.par <- cex.par[table.in[,4]]
189 if (typegraph == 0) {
190 make_afc_graph(table.in, classes, clnb, xlab, ylab, cex.txt = cex.par, xminmax = xminmax, yminmax = yminmax)
194 nodes.attr <- make.afc.attributes(rownames(table.in), afc_table, afctable, clnb)
196 tokeep <- rownames(chistabletot) %%in%% rownames(table.in)
197 chis <- chistabletot[tokeep,]
198 chis<-chis[rownames(table.in),]
199 nodes.attr$chiclasse <- chis
203 afctogexf(fileout, table.in, classes, clnb, cex.par, nodes.attr = nodes.attr)
208 rn <- vire.nonascii(rownames(table.in))
210 colors = rain[classes]
211 #rn <- rownames(table.in)
214 text3d(table.in[,1], table.in[,2], table.in[,3], rn, col = colors , cex = cex.par)
215 rgl.bg(col = c('white', "#99bb99"), front = "lines", box=FALSE, sphere = TRUE)
216 par3d('userMatrix' = matrix(c(1,0,0,0, 0,1,0,0,0,0,1,0,0,0,0,1), ncol=4, nrow = 4))
218 #par3d(windowRect = c(100,100,600,600))
219 rgl.lines(c(rx), c(0, 0), c(0, 0), col = "#000000")
220 rgl.lines(c(0,0),c(ry),c(0,0),col = "#000000")
221 rgl.lines(c(0,0),c(0,0),c(rz),col = "#000000")
222 text3d(rx[2]+1,0,0, xlab)
223 text3d(0,ry[2]+1,0, ylab)
224 text3d(0,0,rz[2]+1, zlab)
227 maxchi <- norm.vec(maxchi, tchi.min/100, tchi.max/100)
228 } else if (!is.null(cex.par)) {
229 maxchi <- norm.vec(cex.par, txt.min/100, txt.max/100)
236 text3d(rx[2],(ry[2]+(0.2*i)),0,paste('classe',i),col=rain[i])
239 # rgl.spheres(table.in, col = colors, radius = maxchi, alpha = alpha)
244 ReturnVal <- tkmessageBox(title="RGL 3 D",message="Cliquez pour commencer le film",icon="info",type="ok")
246 movie3d(spin3d(axis=c(0,1,0),rpm=6), movie = 'film', frames = "tmpfilm", duration=10, clean=TRUE, top = TRUE, dir = dirout)
247 ReturnVal <- tkmessageBox(title="RGL 3 D",message="Fini !",icon="info",type="ok")
250 if (typegraph == 1) {
252 ReturnVal <- tkmessageBox(title="RGL 3 D",message="Cliquez pour fermer",icon="info",type="ok")
254 writeWebGL(dir = fileout, width = width, height= height)