#
-def RchdTxt(DicoPath, RscriptPath, mincl, classif_mode, nbt = 9, libsvdc = False, libsvdc_path = None, R_max_mem = False):
+def RchdTxt(DicoPath, RscriptPath, mincl, classif_mode, nbt = 9, svdmethod = 'svdR', libsvdc = False, libsvdc_path = None, R_max_mem = False, mode_patate = False):
txt = """
source("%s")
source("%s")
txt += """
nbt <- %i
""" % nbt
- if libsvdc :
+ if svdmethod == 'svdlibc' and libsvdc :
txt += """
- libsvdc <- TRUE
+ svd.method <- 'svdlibc'
libsvdc.path <- "%s"
""" % ffr(libsvdc_path)
+ elif svdmethod == 'irlba' :
+ txt += """
+ library(irlba)
+ svd.method <- 'irlba'
+ libsvdc.path <- NULL
+ """
else :
txt += """
- libsvdc <- FALSE
+ svd.method = 'svdR'
libsvdc.path <- NULL
"""
-
+ if mode_patate :
+ txt += """
+ mode.patate = TRUE
+ """
+ else :
+ txt += """
+ mode.patate = FALSE
+ """
txt +="""
library(Matrix)
data1 <- readMM("%s")
data2 <- as(data2, "dgCMatrix")
row.names(data2) <- 1:nrow(data2)
""" % DicoPath['TableUc2']
- #log.info('ATTENTION ############# MODEPATATE ####################')
txt += """
- chd1<-CHD(data1, x = nbt, mode.patate = FALSE, libsvdc = libsvdc, libsvdc.path = libsvdc.path)
+ chd1<-CHD(data1, x = nbt, mode.patate = mode.patate, svd.method = svd.method, libsvdc.path = libsvdc.path)
"""
if classif_mode == 0:
txt += """
- chd2<-CHD(data2, x = nbt, libsvdc = libsvdc, libsvdc.path = libsvdc.path)
+ chd2<-CHD(data2, x = nbt, mode.patate = mode.patate, svd.method = svd.method, libsvdc.path = libsvdc.path)
"""
else:
txt += """
rm(data2)
"""
txt += """
- chd.result <- Rchdtxt("%s",mincl=%i,classif_mode=%i, nbt = nbt)
+ classif_mode <- %i
+ mincl <- %i
+ uceout <- "%s"
+ if (classif_mode == 0) {
+ chd.result <- Rchdtxt(uceout, chd1, chd2 = chd2, mincl = mincl,classif_mode = classif_mode, nbt = nbt)
+ } else {
+ chd.result <- Rchdtxt(uceout, chd1, chd2 = chd1, mincl = mincl,classif_mode = classif_mode, nbt = nbt)
+ }
n1 <- chd.result$n1
classeuce1 <- chd.result$cuce1
classeuce2 <- chd.result$cuce2
- """ % (DicoPath['uce'], mincl, classif_mode)
+ """ % (classif_mode, mincl, DicoPath['uce'])
txt += """
tree.tot1 <- make_tree_tot(chd1)
cn.path <- "%s"
selected.col <- "%s"
""" % (self.pathout['mat01.csv'], self.pathout['actives.csv'], self.pathout['selected.csv'])
+ if 'word' in self.parametres :
+ txt += """
+ word <- TRUE
+ index <- %i + 1
+ """ % self.parametres['word']
+ else :
+ txt += """
+ word <- FALSE
+ """
txt += """
dm <-readMM(dm.path)
- cn <- read.table(cn.path, sep=';', quote='"')
+ cn <- read.table(cn.path, sep='\t', quote='"')
colnames(dm) <- cn[,1]
- sel.col <- read.csv2(selected.col)
- dm <- dm[, sel.col[,1] + 1]
+ sel.col <- read.csv2(selected.col, header = FALSE)
+ sel.col <- sel.col[,1] + 1
+ if (!word) {
+ dm <- dm[, sel.col]
+ } else {
+ forme <- colnames(dm)[index]
+ if (!index %in% sel.col) {
+ sel.col <- append(sel.col, index)
+ }
+ dm <- dm[, sel.col]
+ index <- which(colnames(dm) == forme)
+ }
"""
+
else :
txt += """
load("%s")
mat[is.na(mat)] <- 0
mat[is.infinite(mat)] <- 0
"""
+ if 'word' in self.parametres and not self.parametres['keep_coord'] :
+ txt += """
+ mat <- graph.word(mat, index)
+ cs <- colSums(mat)
+ if (length(cs)) mat <- mat[,-which(cs==0)]
+ rs <- rowSums(mat)
+ if (length(rs)) mat <- mat[-which(rs==0),]
+ if (length(cs)) dm <- dm[, -which(cs==0)]
+ """
+
if self.parametres['layout'] == 0 : layout = 'random'
if self.parametres['layout'] == 1 : layout = 'circle'
if self.parametres['layout'] == 2 : layout = 'frutch'
vertex.size <- NULL
"""
else :
- #FIXME
- tmpchi = False
- if tmpchi :
+ if self.parametres['type'] == 'clustersimitxt' :
txt += """
lchi <- read.table("%s")
lchi <- lchi[,1]
- """ % ffr(tmpchi)
- if 'selected_col' in dir(self.tableau) :
- txt += """
- lchi <- lchi[c%s+1]
- """ % datas
- if tmpchi and self.parametres.get('cexfromchi', False) :
+ """ % ffr(self.parametres['tmpchi'])
+ txt += """
+ lchi <- lchi[sel.col]
+ """
+ if self.parametres['type'] == 'clustersimitxt' and self.parametres.get('cexfromchi', False) :
txt += """
label.cex <- norm.vec(lchi, vcexminmax[1], vcexminmax[2])
"""
label.cex <- graph.simi$label.cex
}
"""
- if tmpchi and self.parametres.get('sfromchi', False) :
+ if self.parametres['type'] == 'clustersimitxt' and self.parametres.get('sfromchi', False) :
txt += """
vertex.size <- norm.vec(lchi, minmaxeff[1], minmaxeff[2])
"""