Browse code

generate documentations by pkgdown

Zuguang Gu authored on 18/10/2019 11:34:02
Showing1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,79 +0,0 @@
1
-\name{restore_matrix}
2
-\alias{restore_matrix}
3
-\title{
4
-Restore the index vector to index matrix in layer_fun
5
-}
6
-\description{
7
-Restore the index vector to index matrix in layer_fun
8
-}
9
-\usage{
10
-restore_matrix(j, i, x, y)
11
-}
12
-\arguments{
13
-
14
-  \item{j}{Column indices directly from \code{layer_fun}.}
15
-  \item{i}{Row indices directly from \code{layer_fun}.}
16
-  \item{x}{Position on x-direction directly from \code{layer_fun}.}
17
-  \item{y}{Position on y-direction directly from \code{layer_fun}.}
18
-
19
-}
20
-\details{
21
-The values that are sent to \code{layer_fun} are all vectors (for the vectorization
22
-of the grid graphic functions), however, the heatmap slice where
23
-\code{layer_fun} is applied to, is still represented by a matrix, thus, it would be
24
-very convinient if all the arguments in \code{layer_fun} can be converted to the
25
-sub-matrix for the current slice. Here, as shown in above example,
26
-\code{\link{restore_matrix}} does the job. \code{\link{restore_matrix}} directly accepts the first
27
-four argument in \code{layer_fun} and returns an index matrix, where rows and
28
-columns correspond to the rows and columns in the current slice, from top to
29
-bottom and from left to right. The values in the matrix are the natural order
30
-of e.g. vector \code{j} in current slice.
31
-
32
-For following code:
33
-
34
-  \preformatted{
35
-    Heatmap(small_mat, name = "mat", col = col_fun,
36
-        row_km = 2, column_km = 2,
37
-        layer_fun = function(j, i, x, y, w, h, fill) \{
38
-            ind_mat = restore_matrix(j, i, x, y)
39
-            print(ind_mat)
40
-        \}
41
-    )  }
42
-
43
-The first output which is for the top-left slice:
44
-
45
-  \preformatted{
46
-         [,1] [,2] [,3] [,4] [,5]
47
-    [1,]    1    4    7   10   13
48
-    [2,]    2    5    8   11   14
49
-    [3,]    3    6    9   12   15  }
50
-
51
-As you see, this is a three-row and five-column index matrix where the first
52
-row corresponds to the top row in the slice. The values in the matrix
53
-correspond to the natural index (i.e. 1, 2, ...) in \code{j}, \code{i}, \code{x}, \code{y},
54
-... in \code{layer_fun}. Now, if we want to add values on the second column in the
55
-top-left slice, the code which is put inside \code{layer_fun} would look like:
56
-
57
-  \preformatted{
58
-    for(ind in ind_mat[, 2]) \{
59
-        grid.text(small_mat[i[ind], j[ind]], x[ind], y[ind], ...)
60
-    \}  }
61
-}
62
-\examples{
63
-set.seed(123)
64
-mat = matrix(rnorm(81), nr = 9)
65
-Heatmap(mat, row_km = 2, column_km = 2,
66
-    layer_fun = function(j, i, x, y, width, height, fill) {
67
-       ind_mat = restore_matrix(j, i, x, y)
68
-       print(ind_mat)
69
-})
70
-
71
-set.seed(123)
72
-mat = matrix(round(rnorm(81), 2), nr = 9)
73
-Heatmap(mat, row_km = 2, column_km = 2,
74
-    layer_fun = function(j, i, x, y, width, height, fill) {
75
-       ind_mat = restore_matrix(j, i, x, y)
76
-       ind = unique(c(ind_mat[2, ], ind_mat[, 3]))
77
-       grid.text(pindex(mat, i[ind], j[ind]), x[ind], y[ind])
78
-})
79
-}
Browse code

gp in anno_text() supports fill and border

Zuguang Gu authored on 24/03/2019 22:20:59
Showing1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,79 @@
1
+\name{restore_matrix}
2
+\alias{restore_matrix}
3
+\title{
4
+Restore the index vector to index matrix in layer_fun
5
+}
6
+\description{
7
+Restore the index vector to index matrix in layer_fun
8
+}
9
+\usage{
10
+restore_matrix(j, i, x, y)
11
+}
12
+\arguments{
13
+
14
+  \item{j}{Column indices directly from \code{layer_fun}.}
15
+  \item{i}{Row indices directly from \code{layer_fun}.}
16
+  \item{x}{Position on x-direction directly from \code{layer_fun}.}
17
+  \item{y}{Position on y-direction directly from \code{layer_fun}.}
18
+
19
+}
20
+\details{
21
+The values that are sent to \code{layer_fun} are all vectors (for the vectorization
22
+of the grid graphic functions), however, the heatmap slice where
23
+\code{layer_fun} is applied to, is still represented by a matrix, thus, it would be
24
+very convinient if all the arguments in \code{layer_fun} can be converted to the
25
+sub-matrix for the current slice. Here, as shown in above example,
26
+\code{\link{restore_matrix}} does the job. \code{\link{restore_matrix}} directly accepts the first
27
+four argument in \code{layer_fun} and returns an index matrix, where rows and
28
+columns correspond to the rows and columns in the current slice, from top to
29
+bottom and from left to right. The values in the matrix are the natural order
30
+of e.g. vector \code{j} in current slice.
31
+
32
+For following code:
33
+
34
+  \preformatted{
35
+    Heatmap(small_mat, name = "mat", col = col_fun,
36
+        row_km = 2, column_km = 2,
37
+        layer_fun = function(j, i, x, y, w, h, fill) \{
38
+            ind_mat = restore_matrix(j, i, x, y)
39
+            print(ind_mat)
40
+        \}
41
+    )  }
42
+
43
+The first output which is for the top-left slice:
44
+
45
+  \preformatted{
46
+         [,1] [,2] [,3] [,4] [,5]
47
+    [1,]    1    4    7   10   13
48
+    [2,]    2    5    8   11   14
49
+    [3,]    3    6    9   12   15  }
50
+
51
+As you see, this is a three-row and five-column index matrix where the first
52
+row corresponds to the top row in the slice. The values in the matrix
53
+correspond to the natural index (i.e. 1, 2, ...) in \code{j}, \code{i}, \code{x}, \code{y},
54
+... in \code{layer_fun}. Now, if we want to add values on the second column in the
55
+top-left slice, the code which is put inside \code{layer_fun} would look like:
56
+
57
+  \preformatted{
58
+    for(ind in ind_mat[, 2]) \{
59
+        grid.text(small_mat[i[ind], j[ind]], x[ind], y[ind], ...)
60
+    \}  }
61
+}
62
+\examples{
63
+set.seed(123)
64
+mat = matrix(rnorm(81), nr = 9)
65
+Heatmap(mat, row_km = 2, column_km = 2,
66
+    layer_fun = function(j, i, x, y, width, height, fill) {
67
+       ind_mat = restore_matrix(j, i, x, y)
68
+       print(ind_mat)
69
+})
70
+
71
+set.seed(123)
72
+mat = matrix(round(rnorm(81), 2), nr = 9)
73
+Heatmap(mat, row_km = 2, column_km = 2,
74
+    layer_fun = function(j, i, x, y, width, height, fill) {
75
+       ind_mat = restore_matrix(j, i, x, y)
76
+       ind = unique(c(ind_mat[2, ], ind_mat[, 3]))
77
+       grid.text(pindex(mat, i[ind], j[ind]), x[ind], y[ind])
78
+})
79
+}