Function to visualise clusters/bases partitioned from a supra-hexagonal grid

Description

visDmatCluster is supposed to visualise clusters/bases partitioned from a supra-hexagonal grid

Usage

visDmatCluster(sMap, sBase, height = 7, margin = rep(0.1, 4), area.size = 1, gp = grid::gpar(cex = 0.8, 
  font = 2, col = "black"), border.color = "transparent", fill.color = NULL, lty = 1, 
      lwd = 1, lineend = "round", linejoin = "round", colormap = c("rainbow", "jet", 
          "bwr", "gbr", "wyr", "br", "yr", "wb"), clip = c("on", "inherit", "off"), 
      newpage = TRUE)

Arguments

sMap
an object of class "sMap"
sBase
an object of class "sBase"
height
a numeric value specifying the height of device
margin
margins as units of length 4 or 1
area.size
an inteter or a vector specifying the area size of each hexagon
gp
an object of class "gpar". It is the output from a call to the function "gpar" (i.e., a list of graphical parameter settings)
border.color
the border color for each hexagon
fill.color
the filled color for each hexagon
lty
the line type for each hexagon. 0 for 'blank', 1 for 'solid', 2 for 'dashed', 3 for 'dotted', 4 for 'dotdash', 5 for 'longdash', 6 for 'twodash'
lwd
the line width for each hexagon
lineend
the line end style for each hexagon. It can be one of 'round', 'butt' and 'square'
linejoin
the line join style for each hexagon. It can be one of 'round', 'mitre' and 'bevel'
colormap
short name for the colormap. It can be one of "jet" (jet colormap), "bwr" (blue-white-red colormap), "gbr" (green-black-red colormap), "wyr" (white-yellow-red colormap), "br" (black-red colormap), "yr" (yellow-red colormap), "wb" (white-black colormap), and "rainbow" (rainbow colormap, that is, red-yellow-green-cyan-blue-magenta). Alternatively, any hyphen-separated HTML color names, e.g. "blue-black-yellow", "royalblue-white-sandybrown", "darkgreen-white-darkviolet". A list of standard color names can be found in http://html-color-codes.info/color-names
clip
either "on" for clipping to the extent of this viewport, "inherit" for inheriting the clipping region from the parent viewport, or "off" to turn clipping off altogether
newpage
logical to indicate whether to open a new page. By default, it sets to true for opening a new page

Value

invisible

Note

none

Examples

# 1) generate an iid normal random matrix of 100x10 data <- matrix( rnorm(100*10,mean=0,sd=1), nrow=100, ncol=10) # 2) get trained using by default setup sMap <- sPipeline(data=data)
Start at 2018-01-18 16:56:15 First, define topology of a map grid (2018-01-18 16:56:15)... Second, initialise the codebook matrix (61 X 10) using 'linear' initialisation, given a topology and input data (2018-01-18 16:56:15)... Third, get training at the rough stage (2018-01-18 16:56:15)... 1 out of 7 (2018-01-18 16:56:15) updated (2018-01-18 16:56:15) 2 out of 7 (2018-01-18 16:56:15) updated (2018-01-18 16:56:15) 3 out of 7 (2018-01-18 16:56:15) updated (2018-01-18 16:56:15) 4 out of 7 (2018-01-18 16:56:15) updated (2018-01-18 16:56:15) 5 out of 7 (2018-01-18 16:56:15) updated (2018-01-18 16:56:15) 6 out of 7 (2018-01-18 16:56:15) updated (2018-01-18 16:56:15) 7 out of 7 (2018-01-18 16:56:15) updated (2018-01-18 16:56:15) Fourth, get training at the finetune stage (2018-01-18 16:56:15)... 1 out of 25 (2018-01-18 16:56:15) updated (2018-01-18 16:56:15) 2 out of 25 (2018-01-18 16:56:15) updated (2018-01-18 16:56:15) 3 out of 25 (2018-01-18 16:56:15) updated (2018-01-18 16:56:15) 4 out of 25 (2018-01-18 16:56:15) updated (2018-01-18 16:56:15) 5 out of 25 (2018-01-18 16:56:15) updated (2018-01-18 16:56:15) 6 out of 25 (2018-01-18 16:56:15) updated (2018-01-18 16:56:15) 7 out of 25 (2018-01-18 16:56:15) updated (2018-01-18 16:56:15) 8 out of 25 (2018-01-18 16:56:15) updated (2018-01-18 16:56:15) 9 out of 25 (2018-01-18 16:56:15) updated (2018-01-18 16:56:15) 10 out of 25 (2018-01-18 16:56:15) updated (2018-01-18 16:56:15) 11 out of 25 (2018-01-18 16:56:15) updated (2018-01-18 16:56:15) 12 out of 25 (2018-01-18 16:56:15) updated (2018-01-18 16:56:15) 13 out of 25 (2018-01-18 16:56:15) updated (2018-01-18 16:56:15) 14 out of 25 (2018-01-18 16:56:15) updated (2018-01-18 16:56:15) 15 out of 25 (2018-01-18 16:56:15) updated (2018-01-18 16:56:15) 16 out of 25 (2018-01-18 16:56:15) updated (2018-01-18 16:56:15) 17 out of 25 (2018-01-18 16:56:15) updated (2018-01-18 16:56:15) 18 out of 25 (2018-01-18 16:56:15) updated (2018-01-18 16:56:15) 19 out of 25 (2018-01-18 16:56:15) updated (2018-01-18 16:56:15) 20 out of 25 (2018-01-18 16:56:15) updated (2018-01-18 16:56:15) 21 out of 25 (2018-01-18 16:56:15) updated (2018-01-18 16:56:15) 22 out of 25 (2018-01-18 16:56:15) updated (2018-01-18 16:56:15) 23 out of 25 (2018-01-18 16:56:15) updated (2018-01-18 16:56:15) 24 out of 25 (2018-01-18 16:56:15) updated (2018-01-18 16:56:15) 25 out of 25 (2018-01-18 16:56:15) updated (2018-01-18 16:56:15) Next, identify the best-matching hexagon/rectangle for the input data (2018-01-18 16:56:15)... Finally, append the response data (hits and mqe) into the sMap object (2018-01-18 16:56:15)... Below are the summaries of the training results: dimension of input data: 100x10 xy-dimension of map grid: xdim=9, ydim=9, r=5 grid lattice: hexa grid shape: suprahex dimension of grid coord: 61x2 initialisation method: linear dimension of codebook matrix: 61x10 mean quantization error: 4.74358615221645 Below are the details of trainology: training algorithm: batch alpha type: invert training neighborhood kernel: gaussian trainlength (x input data length): 7 at rough stage; 25 at finetune stage radius (at rough stage): from 3 to 1 radius (at finetune stage): from 1 to 1 End at 2018-01-18 16:56:16 Runtime in total is: 1 secs
# 3) partition the grid map into clusters using region-growing algorithm sBase <- sDmatCluster(sMap=sMap, which_neigh=1, distMeasure="median", clusterLinkage="average") # 4) visualise clusters/bases partitioned from the sMap visDmatCluster(sMap,sBase) # 4a) also, the area size is proportional to the hits visDmatCluster(sMap,sBase, area.size=log2(sMap$hits+1)) # 4b) also, the area size is inversely proportional to the map distance dMat <- sDmat(sMap)
visDmatCluster(sMap,sBase, area.size=-1*log2(dMat)) # 5) customise the fill color and line type my_color <- visColormap(colormap="PapayaWhip-pink-Tomato")(length(sBase$seeds))[sBase$bases]
my_lty <- (sBase$bases %% 2) visDmatCluster(sMap,sBase, fill.color=my_color, lty=my_lty, border.color="black", lwd=2, area.size=0.9) # also, the area size is inversely proportional to the map distance visDmatCluster(sMap,sBase, fill.color=my_color, lty=my_lty, border.color="black", lwd=2, area.size=-1*log2(dMat))