Browse code

update

Zuguang Gu authored on 12/10/2018 20:21:24
Showing4 changed files

... ...
@@ -192,7 +192,7 @@ setMethod(f = "make_layout",
192 192
                 for(i in seq_len(nr_slice)) {
193 193
                     slice_leaf_pos[i] = slice_leaf_pos[i] - slice_height[i]*p[i]
194 194
                 }
195
-                row_dend_slice = merge(row_dend_slice, object@row_dend_list, only_parent = TRUE)
195
+                row_dend_slice = merge_dendrogram(row_dend_slice, object@row_dend_list, only_parent = TRUE)
196 196
                 row_dend_slice = adjust_dend_by_x(row_dend_slice, slice_leaf_pos)
197 197
                 grid.dendrogram(row_dend_slice, facing = ifelse(row_dend_side == "left", "right", "left"))
198 198
                 popViewport()
... ...
@@ -243,7 +243,7 @@ setMethod(f = "make_layout",
243 243
                 for(i in seq_len(nc_slice)) {
244 244
                     slice_leaf_pos[i] = slice_leaf_pos[i] + slice_width[i]*p[i]
245 245
                 }
246
-                column_dend_slice = merge(column_dend_slice, object@column_dend_list, only_parent = TRUE)
246
+                column_dend_slice = merge_dendrogram(column_dend_slice, object@column_dend_list, only_parent = TRUE)
247 247
                 column_dend_slice = adjust_dend_by_x(column_dend_slice, slice_leaf_pos)
248 248
                 grid.dendrogram(column_dend_slice, facing = ifelse(column_dend_side == "top", "bottom", "top"))
249 249
                 popViewport()
... ...
@@ -321,10 +321,10 @@ grid.dendrogram = function(dend, ..., test = FALSE) {
321 321
 # dend2 = as.dendrogram(hclust(dist(m2)))
322 322
 # dend3 = as.dendrogram(hclust(dist(m3)))
323 323
 # dend_p = as.dendrogram(hclust(dist(rbind(colMeans(m1), colMeans(m2), colMeans(m3)))))
324
-# dend_m = merge(dend_p, list(dend1, dend2, dend3))
324
+# dend_m = merge_dendrogram(dend_p, list(dend1, dend2, dend3))
325 325
 # grid.dendrogram(dend_m, test = TRUE)
326 326
 #
327
-# dend_m = merge(dend_p, list(dend1, dend2, dend3), only_parent = TRUE)
327
+# dend_m = merge_dendrogram(dend_p, list(dend1, dend2, dend3), only_parent = TRUE)
328 328
 # grid.dendrogram(dend_m, test = TRUE)
329 329
 #
330 330
 # require(dendextend)
... ...
@@ -332,9 +332,9 @@ grid.dendrogram = function(dend, ..., test = FALSE) {
332 332
 # dend2 = color_branches(dend2, k = 1, col = "blue")
333 333
 # dend3 = color_branches(dend3, k = 1, col = "green")
334 334
 # dend_p = color_branches(dend_p, k = 1, col = "orange")
335
-# dend_m = merge(dend_p, list(dend1, dend2, dend3))
335
+# dend_m = merge_dendrogram(dend_p, list(dend1, dend2, dend3))
336 336
 # grid.dendrogram(dend_m, test = TRUE)
337
-merge.dendrogram = function(x, y, only_parent = FALSE, ...) {
337
+merge_dendrogram = function(x, y, only_parent = FALSE, ...) {
338 338
     parent = x
339 339
     children = y
340 340
 
... ...
@@ -549,7 +549,7 @@ dend_xy = function(dend) {
549 549
 # == details
550 550
 # The clustering is firstly applied in each group, then clustering is applied
551 551
 # to group means. The within-group dendrograms and between-group dendrogram
552
-# are finally connected by `merge.dendrogram`.
552
+# are finally connected by `merge_dendrogram`.
553 553
 #
554 554
 # In the final dendrogram, the within group dendrograms are enforced to be 
555 555
 # flat lines to emphasize that the within group dendrograms have no sense to 
... ...
@@ -591,7 +591,7 @@ cluster_within_group = function(mat, factor) {
591 591
         attr(node, "height") = 0
592 592
         node
593 593
     }))
594
-    dend = merge(parent, dend_list)
594
+    dend = merge_dendrogram(parent, dend_list)
595 595
     order.dendrogram(dend) = unlist(order_list)
596 596
     return(dend)
597 597
    
... ...
@@ -21,6 +21,8 @@
21 21
 # -show_row_names Whether show row names?
22 22
 # -row_names_side side of the row names
23 23
 # -row_names_gp Graphic parameters of row names.
24
+# -row_order row order
25
+# -column_order column order
24 26
 # -remove_empty_columns if there is no alteration in that sample, whether remove it on the heatmap
25 27
 # -remove_empty_rows if there is no alteration in that sample, whether remove it on the heatmap
26 28
 # -show_column_names Whether show column names?
... ...
@@ -58,6 +60,9 @@ oncoPrint = function(mat,
58 60
 	show_row_names = TRUE,
59 61
 	row_names_side = "right",
60 62
 	row_names_gp = pct_gp,
63
+
64
+	row_order = NULL,
65
+	column_order = NULL,
61 66
 	
62 67
 	remove_empty_columns = FALSE,
63 68
 	remove_empty_rows = FALSE,
... ...
@@ -246,11 +251,9 @@ oncoPrint = function(mat,
246 251
 	count_matrix = apply(arr, c(1, 2), sum)
247 252
 	n_mut = rowSums(apply(arr, 1:2, any))
248 253
 
249
-	row_order = NULL
250 254
 	if(!"row_order" %in% arg_names) {
251 255
 		row_order = oncoprint_row_order()
252 256
 	}
253
-	column_order = NULL
254 257
 	if(!"column_order" %in% arg_names) {
255 258
 		column_order = oncoprint_column_order()
256 259
 	}
... ...
@@ -27,6 +27,9 @@ oncoPrint(mat,
27 27
     row_names_side = "right",
28 28
     row_names_gp = pct_gp,
29 29
     
30
+    row_order = NULL,
31
+    column_order = NULL,
32
+    
30 33
     remove_empty_columns = FALSE,
31 34
     remove_empty_rows = FALSE,
32 35
     show_column_names = FALSE,
... ...
@@ -49,6 +52,8 @@ oncoPrint(mat,
49 52
   \item{show_row_names}{Whether show row names?}
50 53
   \item{row_names_side}{side of the row names}
51 54
   \item{row_names_gp}{Graphic parameters of row names.}
55
+  \item{row_order}{row order}
56
+  \item{column_order}{column order}
52 57
   \item{remove_empty_columns}{if there is no alteration in that sample, whether remove it on the heatmap}
53 58
   \item{remove_empty_rows}{if there is no alteration in that sample, whether remove it on the heatmap}
54 59
   \item{show_column_names}{Whether show column names?}