[adegenet-commits] r1050 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Nov 13 11:18:02 CET 2012


Author: jombart
Date: 2012-11-13 11:18:01 +0100 (Tue, 13 Nov 2012)
New Revision: 1050

Modified:
   pkg/R/gengraph.R
Log:
now gengraph annotates edges using nb of mutations

Modified: pkg/R/gengraph.R
===================================================================
--- pkg/R/gengraph.R	2012-11-08 16:44:10 UTC (rev 1049)
+++ pkg/R/gengraph.R	2012-11-13 10:18:01 UTC (rev 1050)
@@ -22,6 +22,9 @@
 ############
 ## MATRIX ##
 ############
+##
+## this is the basic method
+##
 gengraph.matrix <- function(x, cutoff=NULL, ngrp=NULL, computeAll=FALSE, plot=TRUE, show.graph=TRUE, col.pal=funky,
                             truenames=TRUE, ...){
     ## CHECKS ##
@@ -79,15 +82,25 @@
         V(g)$color <- col.pal(clust$no)[clust$membership]
         col <- col.pal(clust$no)[1:clust$no]
         names(col) <- 1:clust$no
-        res <- list(graph=g, clust=clusters(g), cutoff=cutoff, col=col)
+
+        ## assign labels to vertices
         if(truenames){
-            V(res$graph)$label <- rownames(x)
+            V(g)$label <- rownames(x)
+        } else {
+            V(g)$label <- 1:nrow(x)
         }
 
+        ## assign labels to edges
+        if(length(E(g))>0) {
+            E(g)$label <- E(g)$weight
+        }
+
+        ## make result
+        res <- list(graph=g, clust=clusters(g), cutoff=cutoff, col=col)
+
     } else { ## IF CUT-OFF POINT NEEDS TO BE FOUND ##
         if(ngrp>=nrow(x)) stop("ngrp is greater than or equal to the number of individuals")
 
-
         ## FIRST HAVE A LOOK AT A RANGE OF VALUES ##
         cutToTry <- pretty(x,10)
         cutToTry <- cutToTry[cutToTry>1 & cutToTry<nrow(x)]
@@ -112,11 +125,11 @@
 
 
     ## RETURN ##
-    if(truenames){
-        V(res$graph)$label <- rownames(x)
-    } else {
-        V(res$graph)$label <- 1:nrow(x)
-    }
+    ## if(truenames){
+    ##     V(res$graph)$label <- rownames(x)
+    ## } else {
+    ##     V(res$graph)$label <- 1:nrow(x)
+    ## }
 
     return(res)
 



More information about the adegenet-commits mailing list