gcModify {gcExplorer} | R Documentation |
gcModify
is a function to modify and plot an object
of class "graphdata"
:
- remove edges/nodes
- zoom
- draw custom node plots
## S4 method for signature 'graphdata': gcModify(graphdata, clsim = NULL, rmNodes = NULL, kpNodes = NULL, edgeDep = TRUE, nodeDep = FALSE, zoom = c("none", "manual", "auto"), keepAspectRatio = TRUE, node.function = NULL, doViewPort = TRUE, bgdata = NULL)
graphdata |
list, containing object of class "Ragraph" ,
object of class "kcca" and other parameters of graph created by
gcExplorer ). |
clsim |
matrix, new clsim to define removal or modification of edges. |
rmNodes |
character vector, names of nodes to remove.
(can not be used in combination with kpNodes ) |
kpNodes |
character vector, names of nodes to keep.
(can not be used in combination with rmNodes ) |
edgeDep |
logical. If TRUE edges are removed,
if they do not connect two nodes. |
nodeDep |
logical. If TRUE nodes are removed,
if they are not connected to other nodes. |
zoom |
one of:
"none" - no zoom.
"manual" - activate manual zoom, user interaction needed to
specify area to be enlarged.
"auto" - auto zoom, automatically enlarges graph to size of
graphic device. |
keepAspectRatio |
logical. If TRUE aspect ratio is preserved. |
node.function |
Grid based function for node plotting.
To work correctly, the function will take three arguments:
object is an object of class "kcca" .
cluster is an integer giving the node (i.e., cluster) number.
bgdata is a data.frame of external data. |
doViewPort |
logical. If TRUE node.function ist called
to draw nodes. |
bgdata |
data.frame. external data for node drawing.
(passed to node.function ). |
gcModify
is a tool to modify and plot graphs, created by
gcExplorer
, zoom certain areas of the plot and use grid
based functions to draw custom node plots.
Object of class "graphdata"
with the following slots: an object of
class "Ragraph"
(see package Rgraphviz
), object
,
bgdata
, node.function
, edge.method
, theme
and
colscale
.
Ingo Voglhuber
data("hsod") library(flexclust) set.seed(1111) cl1 <- qtclust(hsod, radius = 2, family = kccaFamily(dist = distEuclidean, cent = colMeans), save.data = TRUE) ## create Ragraph object from kcca object with gcExplorer graph <- gcExplorer(cl1, theme = "blue", node.function = node.size) ## extract and modify clsim clsim <- clusterSim(cl1) clsim[clsim < 0.5] <- 0 ## use modified clsim on Ragraph object to remove edges (<0.5) gcModify(graph, clsim) ## use nodeDep=TRUE to delete nodes without edges gcModify(graph, clsim, nodeDep = TRUE, zoom = "none") ## use zoom="auto" to center and maximize subgraph gcModify(graph, clsim, nodeDep = TRUE, zoom = "auto") ## Not run: ## R package symbols is available from Rforge: ## http://r-forge.r-project.org/projects/symbols/ require("symbols") ## create a grid based plotting function: plot cluster data and centers in matplot. gmatplot <- function (object, cluster, bgdata) { grid.rect() data <- object@data@get("designMatrix") ylimits <- c(min(data, na.rm = TRUE), max(data, na.rm = TRUE)) index <- (object@cluster == cluster) nodedata <- data[index,] symb.matplot(1:ncol(nodedata), t(nodedata), type = "l", col = "gray", ylim = ylimits, pch = 1) center <- object@centers[cluster,] symb.matplot(1:ncol(object@centers), center, type = "l", col = "red", ylim = ylimits, pch = 1) } ## use grid based node function to draw nodes gcModify(graph, clsim, nodeDep = TRUE, zoom = "auto", node.function = gmatplot) ## End(Not run)