X-Git-Url: http://iramuteq.org/git?p=iramuteq;a=blobdiff_plain;f=PrintRScript.py;h=e334a87660cc74ed61e6e8ed3abd6c3cbee34935;hp=dd053e34788a4bedc56090dccf2ccacbb09bb568;hb=0af826e66e86cc0a40361e00549fb64dbd2b92d0;hpb=45e272d7c7cb8fcfc079403631d8a4dcacc795ce diff --git a/PrintRScript.py b/PrintRScript.py old mode 100644 new mode 100755 index dd053e3..e334a87 --- a/PrintRScript.py +++ b/PrintRScript.py @@ -113,7 +113,7 @@ class Alceste2(PrintRScript) : # -def RchdTxt(DicoPath, RscriptPath, mincl, classif_mode, nbt = 9, svdmethod = 'svdR', libsvdc = False, libsvdc_path = None, R_max_mem = False, mode_patate = False): +def RchdTxt(DicoPath, RscriptPath, mincl, classif_mode, nbt = 9, svdmethod = 'svdR', libsvdc = False, libsvdc_path = None, R_max_mem = False, mode_patate = False, nbproc=1): txt = """ source("%s") source("%s") @@ -167,11 +167,12 @@ def RchdTxt(DicoPath, RscriptPath, mincl, classif_mode, nbt = 9, svdmethod = 'sv """ % ffr(DicoPath['TableUc2']) txt += """ log1 <- "%s" - print('FIXME : source newCHD') - source('/home/pierre/workspace/iramuteq/Rscripts/newCHD.R') - chd1<-CHD(data1, x = nbt, mode.patate = mode.patate, svd.method = svd.method, libsvdc.path = libsvdc.path, find='matrix', select.next='size', sample=20, amp=500) - #chd1<-CHD(data1, x = nbt, mode.patate = mode.patate, svd.method = svd.method, libsvdc.path = libsvdc.path)#, log.file = log1) - """ % ffr(DicoPath['log-chd1.txt']) + #print('FIXME : source newCHD') + #source('/home/pierre/workspace/iramuteq/Rscripts/newCHD.R') + #nbproc <- %s + #chd1<-CHD(data1, x = nbt, mode.patate = mode.patate, svd.method = svd.method, libsvdc.path = libsvdc.path, find='matrix', select.next='size', sample=20, amp=500, proc.nb=nbproc) + chd1<-CHD(data1, x = nbt, mode.patate = mode.patate, svd.method = svd.method, libsvdc.path = libsvdc.path)#, log.file = log1) + """ % (ffr(DicoPath['log-chd1.txt']), nbproc) if classif_mode == 0: txt += """ @@ -1186,6 +1187,12 @@ class PrintSimiScript(PrintRScript) : vertex.label.color <- colm[membership(com)] } } + if (!length(graph.simi$elim)==0) { + vertex.label.color <- vertex.label.color[-graph.simi$elim] + if (length(label.cex > 1)) { + label.cex <- label.cex[-graph.simi$elim] + } + } coords <- plot.simi(graph.simi, p.type='%s',filename="%s", vertex.label = label.v, edge.label = label.e, vertex.col = vertex.col, vertex.label.color = vertex.label.color, vertex.label.cex=label.cex, vertex.size = vertex.size, edge.col = cola, leg=leg, width = width, height = height, alpha = alpha, movie = film, edge.curved = edge.curved, svg = svg) save.image(file="%s") """ % (type, self.filename, ffr(self.pathout['RData'])) @@ -1560,6 +1567,58 @@ class ChronoPropScript(PrintRScript) : self.add(txt) self.write() +class ChronoggScript(PrintRScript) : + def make_script(self) : + self.sources([self.analyse.parent.RscriptsPath['Rgraph']]) + print self.parametres + txt = """ + library(ggplot2) + inRData <- "%s" + dendrof <- "%s" + load(inRData) + load(dendrof) + """ % (ffr(self.pathout['RData.RData']), ffr(self.pathout['dendrogramme.RData'])) + txt += """ + svg <- %s + """ % self.parametres['svg'] + txt += """ + tc <- which(grepl("%s",rownames(chistabletot))) + rn <- rownames(chistabletot)[tc] + tc <- tc[order(rn)] + dpt <- chistabletot[tc,] + tot <- afctable[tc,] + tcp <- rowSums(tot) + ptc <- tcp/sum(tcp) + dpt <- t(dpt) + dd <- dpt + """ % self.parametres['var'].replace(u'*', u"\\\\*") + txt += """ + classes <- n1[,ncol(n1)] + tcl <- table(classes) + if ('0' %in% names(tcl)) { + to.vire <- which(names(tcl) == '0') + tcl <- tcl[-to.vire] + } + tclp <- tcl/sum(tcl) + ptt <- prop.table(as.matrix(tot), 1) + ptt <- ptt[,as.numeric(tree.cut1$tree.cl$tip.label)] + rownames(ptt) <- cumsum(ptc) + nptt<-as.data.frame(as.table(ptt)) + nptt[,1]<-as.numeric(as.character(nptt[,1])) + col <- rainbow(ncol(ptt))[as.numeric(tree.cut1$tree.cl$tip.label)] + """ + txt += """ + open_file_graph("%s", w=%i, h=%i, svg=svg) + """ % (ffr(self.parametres['tmpgraph']), self.parametres['width'], self.parametres['height']) + txt+= """ + par(mar=c(10,2,2,2)) + gg <- ggplot(data=nptt, aes(x=Var1,y=Freq,fill=Var2)) + geom_area(alpha=1 , size=0.5, colour="black") + gg + scale_fill_manual(values=col) + dev.off() + """ + self.add(txt) + self.write() + class DendroScript(PrintRScript) : def make_script(self) : if self.parametres['svg'] :