X-Git-Url: http://iramuteq.org/git?a=blobdiff_plain;f=Rscripts%2FRgraph.R;h=e758cfb2fedc4132b2c665f12139075eecbef52a;hb=c038ef7892cf106654fcd0d35389584513b2ec1d;hp=dacd7a81d98d2afc18b869bb2fd9cdb78194c1fd;hpb=dbd43dfa2a70c764332cf4694e22f29ca14b3539;p=iramuteq diff --git a/Rscripts/Rgraph.R b/Rscripts/Rgraph.R index dacd7a8..e758cfb 100644 --- a/Rscripts/Rgraph.R +++ b/Rscripts/Rgraph.R @@ -680,12 +680,12 @@ plot.dendro.prof <- function(tree, classes, chisqtable, nbbycl = 60, type.dendro colcloud <- rainbow(length(sum.cl)) colcloud <- del.yellow(colcloud) } - label.ori<-tree[[2]] + label.ori<-tree$tip.label if (!is.null(lab)) { tree$tip.label <- lab } else { - tree[[2]]<-paste('classe ',tree[[2]]) - } + tree$tip.label<-paste('classe ',tree$tip.label) + } par(mar=c(2,1,0,1)) plot.phylo(tree,label.offset=0, tip.col=col, type=type.dendro, direction = 'downwards', srt=90, adj = 0.5, cex = 1.5, y.lim=c(-0.3,tree$Nnode)) par(mar=c(0,0,0,0)) @@ -748,12 +748,12 @@ plot.dendro.cloud <- function(tree, classes, chisqtable, nbbycl = 60, type.dendr colcloud <- rainbow(length(sum.cl)) } par(mar=c(0,0,0,0)) - label.ori<-tree[[2]] + label.ori<-tree$tip.label if (!is.null(lab)) { tree$tip.label <- lab } else { - tree[[2]]<-paste('classe ',tree[[2]]) - } + tree$tip.label<-paste('classe ',tree$tip.label) + } plot.phylo(tree,label.offset=0.1,tip.col=col, type=type.dendro) for (i in rev(tree.order)) { par(mar=c(0,0,1,0),cex=0.9) @@ -799,11 +799,11 @@ plot.dendropr <- function(tree, classes, type.dendro="phylogram", histo=FALSE, f } } par(mar=c(0,0,0,0),cex=1) - label.ori<-tree[[2]] + label.ori<-tree$tip.label if (!is.null(lab)) { tree$tip.label <- lab } else { - tree[[2]]<-paste('classe ',tree[[2]]) + tree$tip.label<-paste('classe ',tree$tip.label) } plot.phylo(tree,label.offset=0.1,tip.col=col, type=type.dendro) #cl.order <- as.numeric(label.ori) @@ -862,11 +862,11 @@ plot.dendro.lex <- function(tree, to.plot, bw=FALSE, lab=NULL, lay.width=c(3,3,2 } layout(matlay, widths=lay.width,TRUE) par(mar=c(3,0,2,4),cex=1) - label.ori<-tree[[2]] + label.ori<-tree$tip.label if (!is.null(lab)) { - tree$tip.label <- lab[tree.order] + tree$tip.label <- lab } else { - tree[[2]]<-paste('classe ',tree[[2]]) + tree$tip.label<-paste('classe ',tree$tip.label) } to.plot <- matrix(to.plot[,tree.order], nrow=nrow(to.plot), dimnames=list(rownames(to.plot), colnames(to.plot))) if (!bw) { @@ -1164,10 +1164,12 @@ graph.to.file <- function(graph.simi, nodesfile = NULL, edgesfile = NULL, commun } else { V(g)$weight <- graph.simi$label.cex } - V(g)$x <- graph.simi$layout[,1] - V(g)$y <- graph.simi$layout[,2] - if (ncol(graph.simi$layout) == 3) { - V(g)$z <- graph.simi$layout[,3] + layout <- layout.norm(graph.simi$layout,-5,5,-5,5,-5,5) + print(layout) + V(g)$x <- layout[,1] + V(g)$y <- layout[,2] + if (ncol(layout) == 3) { + V(g)$z <- layout[,3] } if (community) { member <- graph.simi$communities$membership @@ -1215,6 +1217,13 @@ graph.to.file2 <- function(graph, layout, nodesfile = NULL, edgesfile = NULL, co if (!is.null(sweight)) { V(g)$sweight <- sweight } + if (is.null(V(g)$weight)) { + if (!is.null(sweight)) { + V(g)$weight <- sweight + } else { + V(g)$weight <- 1 + } + } df <- get.data.frame(g, what='both') if (!is.null(nodesfile)) { write.table(df$vertices, nodesfile, sep='\t', row.names=FALSE)