Browse code

add pct_include argument

Zuguang Gu authored on 02/09/2022 07:57:24
Showing 11 changed files

... ...
@@ -2,6 +2,7 @@ CHANGES in VERSION 2.13.2
2 2
 
3 3
 * `HeatmapAnnotation()`: fixed a bug where annotation legends are not all generated when `df` is set.
4 4
 * `UpSet()`: now `bg_col` can be a vector of length more than two.
5
+* `oncoPrint()`: Add `pct_include` argument.
5 6
 
6 7
 ========================
7 8
 
... ...
@@ -1,32 +1,32 @@
1
-setGeneric('draw_dimnames', function(object, ...) standardGeneric('draw_dimnames'))
1
+setGeneric('get_legend_param_list', function(object, ...) standardGeneric('get_legend_param_list'))
2 2
 setGeneric('row_dend', function(object, ...) standardGeneric('row_dend'))
3
-setGeneric('draw', function(object, ...) standardGeneric('draw'))
4
-setGeneric('get_color_mapping_list', function(object, ...) standardGeneric('get_color_mapping_list'))
3
+setGeneric('prepare', function(object, ...) standardGeneric('prepare'))
5 4
 setGeneric('draw_heatmap_body', function(object, ...) standardGeneric('draw_heatmap_body'))
6
-setGeneric('draw_annotation_legend', function(object, ...) standardGeneric('draw_annotation_legend'))
7
-setGeneric('color_mapping_legend', function(object, ...) standardGeneric('color_mapping_legend'))
8
-setGeneric('get_legend_param_list', function(object, ...) standardGeneric('get_legend_param_list'))
9
-setGeneric('draw_title', function(object, ...) standardGeneric('draw_title'))
10
-setGeneric('component_width', function(object, ...) standardGeneric('component_width'))
11
-setGeneric('draw_annotation', function(object, ...) standardGeneric('draw_annotation'))
12
-setGeneric('draw_heatmap_legend', function(object, ...) standardGeneric('draw_heatmap_legend'))
13
-setGeneric('heatmap_legend_size', function(object, ...) standardGeneric('heatmap_legend_size'))
14
-setGeneric('column_order', function(object, ...) standardGeneric('column_order'))
15 5
 setGeneric('row_order', function(object, ...) standardGeneric('row_order'))
6
+setGeneric('adjust_heatmap_list', function(object, ...) standardGeneric('adjust_heatmap_list'))
7
+setGeneric('draw_dimnames', function(object, ...) standardGeneric('draw_dimnames'))
8
+setGeneric('draw_heatmap_legend', function(object, ...) standardGeneric('draw_heatmap_legend'))
16 9
 setGeneric('re_size', function(object, ...) standardGeneric('re_size'))
17
-setGeneric('annotation_legend_size', function(object, ...) standardGeneric('annotation_legend_size'))
18
-setGeneric('make_column_cluster', function(object, ...) standardGeneric('make_column_cluster'))
19 10
 setGeneric('map_to_colors', function(object, ...) standardGeneric('map_to_colors'))
20
-setGeneric('draw_heatmap_list', function(object, ...) standardGeneric('draw_heatmap_list'))
21
-setGeneric('component_height', function(object, ...) standardGeneric('component_height'))
22
-setGeneric('attach_annotation', function(object, ...) standardGeneric('attach_annotation'))
23
-setGeneric('adjust_heatmap_list', function(object, ...) standardGeneric('adjust_heatmap_list'))
24
-setGeneric('add_heatmap', function(object, ...) standardGeneric('add_heatmap'))
25
-setGeneric('set_component_width', function(object, ...) standardGeneric('set_component_width'))
11
+setGeneric('color_mapping_legend', function(object, ...) standardGeneric('color_mapping_legend'))
12
+setGeneric('make_row_cluster', function(object, ...) standardGeneric('make_row_cluster'))
13
+setGeneric('draw_annotation_legend', function(object, ...) standardGeneric('draw_annotation_legend'))
26 14
 setGeneric('copy_all', function(object, ...) standardGeneric('copy_all'))
15
+setGeneric('heatmap_legend_size', function(object, ...) standardGeneric('heatmap_legend_size'))
27 16
 setGeneric('make_layout', function(object, ...) standardGeneric('make_layout'))
28
-setGeneric('prepare', function(object, ...) standardGeneric('prepare'))
29
-setGeneric('make_row_cluster', function(object, ...) standardGeneric('make_row_cluster'))
30 17
 setGeneric('column_dend', function(object, ...) standardGeneric('column_dend'))
18
+setGeneric('draw_heatmap_list', function(object, ...) standardGeneric('draw_heatmap_list'))
19
+setGeneric('annotation_legend_size', function(object, ...) standardGeneric('annotation_legend_size'))
20
+setGeneric('component_height', function(object, ...) standardGeneric('component_height'))
21
+setGeneric('draw_annotation', function(object, ...) standardGeneric('draw_annotation'))
22
+setGeneric('draw_title', function(object, ...) standardGeneric('draw_title'))
23
+setGeneric('column_order', function(object, ...) standardGeneric('column_order'))
24
+setGeneric('make_column_cluster', function(object, ...) standardGeneric('make_column_cluster'))
25
+setGeneric('attach_annotation', function(object, ...) standardGeneric('attach_annotation'))
26
+setGeneric('component_width', function(object, ...) standardGeneric('component_width'))
27
+setGeneric('get_color_mapping_list', function(object, ...) standardGeneric('get_color_mapping_list'))
28
+setGeneric('draw', function(object, ...) standardGeneric('draw'))
31 29
 setGeneric('set_component_height', function(object, ...) standardGeneric('set_component_height'))
30
+setGeneric('add_heatmap', function(object, ...) standardGeneric('add_heatmap'))
32 31
 setGeneric('draw_dend', function(object, ...) standardGeneric('draw_dend'))
32
+setGeneric('set_component_width', function(object, ...) standardGeneric('set_component_width'))
... ...
@@ -23,6 +23,7 @@
23 23
 # -pct_gp Graphic paramters for percent values
24 24
 # -pct_digits Digits for the percent values.
25 25
 # -pct_side Side of the percent values to the oncoPrint. This argument is currently disabled.
26
+# -pct_include Alteration types that are included for the calculation of percent values.
26 27
 # -row_labels Labels as the row names of the oncoPrint.
27 28
 # -show_row_names Whether show row names?
28 29
 # -row_names_side Side of the row names to the oncoPrint. This argument is currently disabled.
... ...
@@ -69,6 +70,7 @@ oncoPrint = function(mat, name,
69 70
 	pct_gp = gpar(fontsize = 10), 
70 71
 	pct_digits = 0,
71 72
 	pct_side = "left",
73
+	pct_include = NULL,
72 74
 
73 75
 	row_labels = NULL,
74 76
 	show_row_names = TRUE,
... ...
@@ -368,7 +370,10 @@ oncoPrint = function(mat, name,
368 370
 	}
369 371
 
370 372
 	# for each gene, percent of samples that have alterations
371
-	pct_num = rowSums(apply(arr, 1:2, any)) / ncol(mat_list[[1]])
373
+	if(is.null(pct_include)) {
374
+		pct_include = dimnames(arr)[[3]]
375
+	}
376
+	pct_num = rowSums(apply(arr[, , dimnames(arr)[[3]] %in% pct_include, drop = FALSE], 1:2, any)) / ncol(mat_list[[1]])
372 377
 	pct = paste0(round(pct_num * 100, digits = pct_digits), "%")
373 378
 
374 379
 	### now the annotations
... ...
@@ -10,9 +10,9 @@ Method dispatch page for \code{add_heatmap}.
10 10
 \code{add_heatmap} can be dispatched on following classes:
11 11
 
12 12
 \itemize{
13
-\item \code{\link{add_heatmap,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method
14
-\item \code{\link{add_heatmap,HeatmapAnnotation-method}}, \code{\link{HeatmapAnnotation-class}} class method
15 13
 \item \code{\link{add_heatmap,Heatmap-method}}, \code{\link{Heatmap-class}} class method
14
+\item \code{\link{add_heatmap,HeatmapAnnotation-method}}, \code{\link{HeatmapAnnotation-class}} class method
15
+\item \code{\link{add_heatmap,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method
16 16
 }
17 17
 }
18 18
 \examples{
... ...
@@ -10,8 +10,8 @@ Method dispatch page for \code{column_order}.
10 10
 \code{column_order} can be dispatched on following classes:
11 11
 
12 12
 \itemize{
13
-\item \code{\link{column_order,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method
14 13
 \item \code{\link{column_order,Heatmap-method}}, \code{\link{Heatmap-class}} class method
14
+\item \code{\link{column_order,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method
15 15
 }
16 16
 }
17 17
 \examples{
... ...
@@ -11,10 +11,10 @@ Method dispatch page for \code{draw}.
11 11
 
12 12
 \itemize{
13 13
 \item \code{\link{draw,AnnotationFunction-method}}, \code{\link{AnnotationFunction-class}} class method
14
-\item \code{\link{draw,HeatmapAnnotation-method}}, \code{\link{HeatmapAnnotation-class}} class method
15
-\item \code{\link{draw,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method
16 14
 \item \code{\link{draw,SingleAnnotation-method}}, \code{\link{SingleAnnotation-class}} class method
15
+\item \code{\link{draw,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method
17 16
 \item \code{\link{draw,Heatmap-method}}, \code{\link{Heatmap-class}} class method
17
+\item \code{\link{draw,HeatmapAnnotation-method}}, \code{\link{HeatmapAnnotation-class}} class method
18 18
 \item \code{\link{draw,Legends-method}}, \code{\link{Legends-class}} class method
19 19
 }
20 20
 }
... ...
@@ -10,8 +10,8 @@ Method dispatch page for \code{draw_title}.
10 10
 \code{draw_title} can be dispatched on following classes:
11 11
 
12 12
 \itemize{
13
-\item \code{\link{draw_title,Heatmap-method}}, \code{\link{Heatmap-class}} class method
14 13
 \item \code{\link{draw_title,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method
14
+\item \code{\link{draw_title,Heatmap-method}}, \code{\link{Heatmap-class}} class method
15 15
 }
16 16
 }
17 17
 \examples{
... ...
@@ -10,8 +10,8 @@ Method dispatch page for \code{make_layout}.
10 10
 \code{make_layout} can be dispatched on following classes:
11 11
 
12 12
 \itemize{
13
-\item \code{\link{make_layout,Heatmap-method}}, \code{\link{Heatmap-class}} class method
14 13
 \item \code{\link{make_layout,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method
14
+\item \code{\link{make_layout,Heatmap-method}}, \code{\link{Heatmap-class}} class method
15 15
 }
16 16
 }
17 17
 \examples{
... ...
@@ -22,6 +22,7 @@ oncoPrint(mat, name,
22 22
     pct_gp = gpar(fontsize = 10),
23 23
     pct_digits = 0,
24 24
     pct_side = "left",
25
+    pct_include = NULL,
25 26
     
26 27
     row_labels = NULL,
27 28
     show_row_names = TRUE,
... ...
@@ -60,6 +61,7 @@ oncoPrint(mat, name,
60 61
   \item{pct_gp}{Graphic paramters for percent values}
61 62
   \item{pct_digits}{Digits for the percent values.}
62 63
   \item{pct_side}{Side of the percent values to the oncoPrint. This argument is currently disabled.}
64
+  \item{pct_include}{Alteration types that are included for the calculation of percent values.}
63 65
   \item{row_labels}{Labels as the row names of the oncoPrint.}
64 66
   \item{show_row_names}{Whether show row names?}
65 67
   \item{row_names_side}{Side of the row names to the oncoPrint. This argument is currently disabled.}
... ...
@@ -10,8 +10,8 @@ Method dispatch page for \code{row_dend}.
10 10
 \code{row_dend} can be dispatched on following classes:
11 11
 
12 12
 \itemize{
13
-\item \code{\link{row_dend,Heatmap-method}}, \code{\link{Heatmap-class}} class method
14 13
 \item \code{\link{row_dend,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method
14
+\item \code{\link{row_dend,Heatmap-method}}, \code{\link{Heatmap-class}} class method
15 15
 }
16 16
 }
17 17
 \examples{
... ...
@@ -10,12 +10,12 @@ Method dispatch page for \code{show}.
10 10
 \code{show} can be dispatched on following classes:
11 11
 
12 12
 \itemize{
13
-\item \code{\link{show,ColorMapping-method}}, \code{\link{ColorMapping-class}} class method
14
-\item \code{\link{show,AnnotationFunction-method}}, \code{\link{AnnotationFunction-class}} class method
15
-\item \code{\link{show,SingleAnnotation-method}}, \code{\link{SingleAnnotation-class}} class method
16
-\item \code{\link{show,HeatmapAnnotation-method}}, \code{\link{HeatmapAnnotation-class}} class method
17 13
 \item \code{\link{show,HeatmapList-method}}, \code{\link{HeatmapList-class}} class method
14
+\item \code{\link{show,SingleAnnotation-method}}, \code{\link{SingleAnnotation-class}} class method
18 15
 \item \code{\link{show,Heatmap-method}}, \code{\link{Heatmap-class}} class method
16
+\item \code{\link{show,HeatmapAnnotation-method}}, \code{\link{HeatmapAnnotation-class}} class method
17
+\item \code{\link{show,ColorMapping-method}}, \code{\link{ColorMapping-class}} class method
18
+\item \code{\link{show,AnnotationFunction-method}}, \code{\link{AnnotationFunction-class}} class method
19 19
 }
20 20
 }
21 21
 \examples{