Browse code

remove reversed axes in some anno functions

Zuguang Gu authored on 18/04/2019 20:46:49
Showing2 changed files

... ...
@@ -2,6 +2,7 @@ CHANGES in VERSION 1.99.7
2 2
 
3 3
 * `UpSet()` supports adding complement sets.
4 4
 * `make_comb_set()`: add `universal_set` and `complement_size` arguments.
5
+* axes can be reversed in anno_* functions.
5 6
 
6 7
 ========================
7 8
 
... ...
@@ -1578,15 +1578,12 @@ anno_histogram = function(x, which = c("column", "row"), n_breaks = 11,
1578 1578
 	yscale[2] = yscale[2]*1.05
1579 1579
 
1580 1580
 	gp = recycle_gp(gp, n)
1581
+	axis_param$direction = "normal"
1581 1582
 	axis_param = validate_axis_param(axis_param, which)
1582 1583
 	axis_grob = if(axis) construct_axis_grob(axis_param, which, xscale) else NULL
1583 1584
 
1584 1585
 	row_fun = function(index, k = 1, N = 1) {
1585 1586
 
1586
-		if(axis_param$direction == "reverse") {
1587
-			value = lapply(value, function(x) data_scale[2] - x + data_scale[1])
1588
-		}
1589
-		
1590 1587
 		n_all = length(value)
1591 1588
 		value = value[index]
1592 1589
 		
... ...
@@ -1613,10 +1610,6 @@ anno_histogram = function(x, which = c("column", "row"), n_breaks = 11,
1613 1610
 	}
1614 1611
 	column_fun = function(index, k = 1, N = 1) {
1615 1612
 
1616
-		if(axis_param$direction == "reverse") {
1617
-			value = lapply(value, function(x) data_scale[2] - x + data_scale[1])
1618
-		}
1619
-		
1620 1613
 		n_all = length(value)
1621 1614
 		value = value[index]
1622 1615
 		
... ...
@@ -1774,14 +1767,11 @@ anno_density = function(x, which = c("column", "row"),
1774 1767
 			length = length(heatmap_colors)), heatmap_colors)
1775 1768
 	}
1776 1769
 
1770
+	axis_param$direction = "normal"
1777 1771
 	axis_param = validate_axis_param(axis_param, which)
1778 1772
 	axis_grob = if(axis) construct_axis_grob(axis_param, which, xscale) else NULL
1779 1773
 
1780 1774
 	row_fun = function(index, k = 1, N = 1) {
1781
-
1782
-		if(axis_param$direction == "reverse") {
1783
-			value = lapply(value, function(x) data_scale[2] - x + data_scale[1])
1784
-		}
1785 1775
 		
1786 1776
 		n = length(index)
1787 1777
 		value = value[index]
... ...
@@ -1836,10 +1826,6 @@ anno_density = function(x, which = c("column", "row"),
1836 1826
 		popViewport()
1837 1827
 	}
1838 1828
 	column_fun = function(index, k = 1, N = 1) {
1839
-		
1840
-		if(axis_param$direction == "reverse") {
1841
-			value = lapply(value, function(x) data_scale[2] - x + data_scale[1])
1842
-		}
1843 1829
 
1844 1830
 		n_all = length(value)
1845 1831
 		value = value[index]
... ...
@@ -2214,15 +2200,12 @@ anno_joyplot = function(x, which = c("column", "row"), gp = gpar(fill = "#000000
2214 2200
 	} 
2215 2201
 	gp = recycle_gp(gp, n)
2216 2202
 	gp$fill = add_transparency(gp$fill, transparency)
2203
+	axis_param$direction = "normal"
2217 2204
 	axis_param = validate_axis_param(axis_param, which)
2218 2205
 	axis_grob = if(axis) construct_axis_grob(axis_param, which, xscale) else NULL
2219 2206
 
2220 2207
 	row_fun = function(index, k = 1, N = 1) {
2221 2208
 
2222
-		if(axis_param$direction == "reverse") {
2223
-			value = lapply(value, function(x) data_scale[2] - x + data_scale[1])
2224
-		}
2225
-
2226 2209
 		n_all = length(value)
2227 2210
 		value = value[index]
2228 2211
 		
... ...
@@ -2256,10 +2239,6 @@ anno_joyplot = function(x, which = c("column", "row"), gp = gpar(fill = "#000000
2256 2239
 	}
2257 2240
 	column_fun = function(index, k = 1, N = 1) {
2258 2241
 
2259
-		if(axis_param$direction == "reverse") {
2260
-			value = lapply(value, function(x) data_scale[2] - x + data_scale[1])
2261
-		}
2262
-
2263 2242
 		n_all = length(value)
2264 2243
 		value = value[index]
2265 2244
 		
... ...
@@ -2439,15 +2418,12 @@ anno_horizon = function(x, which = c("column", "row"),
2439 2418
 	xscale = range(lapply(value, function(x) x[, 1]), na.rm = TRUE)
2440 2419
 	yscale = range(lapply(value, function(x) abs(x[, 2])), na.rm = TRUE)
2441 2420
 	
2421
+	axis_param$direction = "normal"
2442 2422
 	axis_param = validate_axis_param(axis_param, which)
2443 2423
 	axis_grob = if(axis) construct_axis_grob(axis_param, which, xscale) else NULL
2444 2424
 
2445 2425
 	row_fun = function(index, k = 1, N = 1) {
2446 2426
 
2447
-		if(axis_param$direction == "reverse") {
2448
-			value = lapply(value, function(x) data_scale[2] - x + data_scale[1])
2449
-		}
2450
-
2451 2427
 		n_all = length(value)
2452 2428
 		value = value[index]
2453 2429