Browse code

columns in oncoPrint now are correct sorted

Zuguang Gu authored on 06/10/2015 18:09:27
Showing 3 changed files

... ...
@@ -1,7 +1,7 @@
1 1
 Package: ComplexHeatmap
2 2
 Type: Package
3 3
 Title: Making Complex Heatmaps
4
-Version: 1.4.4
4
+Version: 1.5.0
5 5
 Date: 2015-10-1
6 6
 Author: Zuguang Gu
7 7
 Maintainer: Zuguang Gu <z.gu@dkfz.de>
... ...
@@ -30,6 +30,9 @@
30 30
 # The 'memo sort' method is from https://gist.github.com/armish/564a65ab874a770e2c26 . Thanks to
31 31
 # B. Arman Aksoy for contributing the code.
32 32
 #
33
+# The function would be a little bit slow if you plot it in an interactive device because all alterations
34
+# are added through a foo loop.
35
+#
33 36
 # For more explanation, please go to the vignette.
34 37
 #
35 38
 # == value
... ...
@@ -101,7 +104,7 @@ oncoPrint = function(mat, get_type = function(x) x,
101 104
 			score = 0
102 105
 			for(i in 1:length(x)) {
103 106
 				if(x[i]) {
104
-					score = score + 2^(length(x)-i)
107
+					score = score + 2^(length(x)-i*1/x[i])
105 108
 				}
106 109
 			}
107 110
 			return(score)
... ...
@@ -116,15 +119,12 @@ oncoPrint = function(mat, get_type = function(x) x,
116 119
 	if(is.character(column_order)) {
117 120
 		column_order = structure(seq_len(dim(arr)[2]), names = dimnames(arr)[[2]])[column_order]
118 121
 	}
119
-
122
+	column_order = column_order
123
+	names(column_order) = as.character(column_order)
120 124
 	if(remove_empty_columns) {
121 125
 		l = rowSums(apply(arr, c(2, 3), sum)) > 0
122 126
 		arr = arr[, l, , drop = FALSE]
123
-		count_matrix = count_matrix[, l, drop = FALSE]
124
-		column_order = column_order
125
-		if(length(column_order) > ncol(count_matrix)) {
126
-			column_order = order(column_order[l])
127
-		}
127
+		column_order = structure(seq_len(sum(l)), names = which(l))[as.character(intersect(column_order, which(l)))]
128 128
 	}
129 129
 
130 130
 	# validate alter_fun_list
... ...
@@ -128,7 +128,7 @@ rownames(mat) = mat[, 1]
128 128
 mat = mat[, -1]
129 129
 mat=  mat[, -ncol(mat)]
130 130
 mat = t(as.matrix(mat))
131
-head(mat)
131
+mat[1:3, 1:3]
132 132
 ```
133 133
 
134 134
 There are three different alterations in `mat`: `HOMDEL`, `AMP` and `MUT`. We first