-class PrepSimi :
- def _init_(self, parent, parametres, indices_simi) :
- self.parametres = parametres
- self.dial = PrefSimi(parent, -1, self.parametres, indices_simi)
- self.dial.CenterOnParent()
- self.val = self.dial.ShowModal()
- if self.val == wx.ID_OK :
- self.make_param()
-
- def make_param(self) :
- self.select = self.dial.check_colch.GetValue()
- param = {'coeff' : self.dial.choice1.GetSelection(),
- 'layout' : self.dial.choice2.GetSelection(),
- 'type' : self.dial.choice3.GetSelection(),
- 'arbremax' : self.dial.check1.GetValue(),
- 'coeff_tv' : self.dial.check_s_size.GetValue(),
- 'coeff_tv_nb' : self.dial.spin_tv.GetValue(),
- 'tvprop' : self.dial.check2.GetValue(),
- 'tvmin' : self.dial.spin_tvmin.GetValue(),
- 'tvmax' : self.dial.spin_tvmax.GetValue(),
- 'coeff_te' : self.dial.check3.GetValue(),
- 'coeff_temin' : self.dial.spin_temin.GetValue(),
- 'coeff_temax' : self.dial.spin_temax.GetValue(),
- 'label_e' : self.dial.check_elab.GetValue(),
- 'label_v' : self.dial.check_vlab.GetValue(),
- 'vcex' : self.dial.check_vcex.GetValue(),
- 'vcexmin' : self.dial.spin_vcexmin.GetValue(),
- 'vcexmax' : self.dial.spin_vcexmax.GetValue(),
- 'cex' : self.dial.spin_cex.GetValue(),
- 'seuil_ok' : self.dial.check_seuil.GetValue(),
- 'seuil' : self.dial.spin_seuil.GetValue(),
- 'cols' : self.dial.cols.GetColour(),
- 'cola' : self.dial.cola.GetColour(),
- 'width' : self.dial.spin_width.GetValue(),
- 'height' : self.dial.spin_height.GetValue(),
- 'first' : False,
- 'keep_coord' : keep_coord,
- 'alpha' : self.dial.slider_sphere.GetValue(),
- 'film' : self.dial.film.GetValue()
- }
- if 'cexfromchi' in self.parametres :
- param['cexfromchi'] = self.dial.checkit.GetValue()
- if 'sfromchi' in self.parametres :
- param['sfromchi'] = self.dial.checki.GetValue()
- if 'vlabcolor' in self.parametres :
- param['vlabcolor'] = self.parametres['vlabcolor']
- if 'check_bystar' in dir(self.dial) :
- param['bystar'] = self.dial.check_bystar.GetValue()
- param['stars'] = self.parametres['stars']
- self.parametres.update(param)
-
-class PrintSimiScript(PrintRScript) :
- def make_script(self) :
- self.load(['igraph', 'proxy', 'Matrix'])
- self.source([self.analyse.parent.RscriptsPath['simi'], self.analyse.parent.RscriptsPath['Rgraph']])
- txt = """
- dm.path <- "%s"
- cn.path <- "%s"
- selected.col <- "%s"
- """ % (self.pathout['mat01.csv'], self.pathout['actives.csv'], self.pathout['selected.csv'])
-
- txt += """
- dm <- dm[, selected.col+1]
- """
- if self.parametres['coeff'] == 0 :
- method = 'cooc'
- txt += """
- method <- 'cooc'
- mat <- make.a(dm)
- """
- else :
- txt += """
- dm <- as.matrix(dm)
- """
- if self.parametres['coeff'] == 1 :
- method = 'prcooc'
- txt += """
- method <- 'Russel'
- mat <- simil(dm, method = 'Russel', diag = TRUE, upper = TRUE, by_rows = FALSE)
- """
- elif self.analyses.indices[self.parametres['coeff']] == 'binomial' :
- method = 'binomial'
- txt += """
- method <- 'binomial'
- mat <- binom.sim(dm)
- """
- else :
- method = self.types[self.paramsimi['coeff']]
- txt += """
- method <-"%s"
- mat <- simil(dm, method = method, diag = TRUE, upper = TRUE, by_rows = FALSE)
- """ % self.analyse.indices[self.parametres['coeff']]
- txt += """
- mat <- as.matrix(stats::as.dist(mat,diag=TRUE,upper=TRUE))
- mat[is.na(mat)] <- 0
- mat[is.infinite(mat)] <- 0
- """
- if self.parametres['layout'] == 0 : layout = 'random'
- if self.parametres['layout'] == 1 : layout = 'circle'
- if self.parametres['layout'] == 2 : layout = 'frutch'
- if self.parametres['layout'] == 3 : layout = 'kawa'
- if self.parametres['layout'] == 4 : layout = 'graphopt'
-
- txt += """
- eff <- colSums(dm)
- g.ori <- graph.adjacency(mat, mode='lower', weighted = TRUE)
- w.ori <- E(g.ori)$weight
- if (max.tree) {
- if (method == 'cooc') {
- E(g.ori)$weight <- 1 / w.ori
- } else {
- E(g.ori)$weigth <- 1 - w.ori
- }
- g.max <- minimum.spanning.tree(g.ori)
- if (method == 'cooc') {
- E(g.max)$weight <- 1 / E(g.max)$weight
- } else {
- E(g.max)$weight <- 1 - E(g.max)$weight
- }
- g.toplot <- g.max
- } else {
- g.toplot <- g.ori
- }
- """
-