Permalink
Browse files

solve conflicts

git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/ComplexHeatmap@109710 bc3139a8-67e5-0310-9ffc-ced21a209358
  • Loading branch information...
jokergoo committed Oct 16, 2015
1 parent cfb8a57 commit d7e872f77d698c86ef6ac4886417440769fe556c
View
0 .Rbuildignore 100644 → 100755
No changes.
View
0 .gitignore 100644 → 100755
No changes.
View
0 .travis.yml 100644 → 100755
No changes.
View
@@ -1,7 +1,7 @@
Package: ComplexHeatmap
Type: Package
Title: Making Complex Heatmaps
Version: 1.7.0
Version: 1.7.1
Date: 2015-10-10
Author: Zuguang Gu
Maintainer: Zuguang Gu <z.gu@dkfz.de>
View
@@ -4,6 +4,7 @@ exportMethods(column_order)
export(ColorMapping)
export(HeatmapAnnotation)
export(column_anno_boxplot)
export(selectArea)
export(row_anno_barplot)
export(Heatmap)
export(row_anno_points)
@@ -85,7 +86,6 @@ export(rowAnnotation)
export(columnAnnotation)
export(decorate_row_names)
export(anno_text)
export(selectArea)
export(anno_density)
import(grid)
View
7 NEWS
@@ -1,3 +1,10 @@
CHANGES in VERSION 1.7.1
* `x` and `y` are `unit` object now in `cell_fun`
* add an example to visualize GO game
================================
CHANGES in VERSION 1.5.1
* `oncoPrint`: there are default graphics if type of alterations is
@@ -25,10 +25,10 @@ setGeneric('prepare', function(object, ...) standardGeneric('prepare'))
setGeneric('draw_annotation', function(object, ...) standardGeneric('draw_annotation'))
setGeneric('get_color_mapping_param_list', function(object, ...) standardGeneric('get_color_mapping_param_list'))
setGeneric('draw_dimnames', function(object, ...) standardGeneric('draw_dimnames'))
setGeneric('get_color_mapping_param_list', function(object, ...) standardGeneric('get_color_mapping_param_list'))
setGeneric('color_mapping_legend', function(object, ...) standardGeneric('color_mapping_legend'))
setGeneric('draw', function(object, ...) standardGeneric('draw'))
View
@@ -122,7 +122,7 @@ Heatmap = setClass("Heatmap",
# -cell_fun self-defined function to add graphics on each cell. Seven parameters will be passed into
# this function: ``i``, ``j``, ``x``, ``y``, ``width``, ``height``, ``fill`` which are row index,
# column index in ``matrix``, coordinate of the middle points in the heatmap body viewport,
# the width and height of the cell and the filled color.
# the width and height of the cell and the filled color. ``x``, ``y``, ``width`` and ``height`` are all `grid::unit` objects.
# -row_title title on row.
# -row_title_side will the title be put on the left or right of the heatmap?
# -row_title_gp graphic parameters for drawing text.
@@ -1248,7 +1248,7 @@ setMethod(f = "draw_heatmap_body",
cell_fun = object@matrix_param$cell_fun
for(i in row_order) {
for(j in column_order) {
cell_fun(j, i, x[which(column_order == j)], y[which(row_order == i)], unit(1/nc, "npc"), unit(1/nr, "npc"), col_matrix[which(row_order == i), which(column_order == j)])
cell_fun(j, i, unit(x[which(column_order == j)], "npc"), unit(y[which(row_order == i)], "npc"), unit(1/nc, "npc"), unit(1/nr, "npc"), col_matrix[which(row_order == i), which(column_order == j)])
}
}
View
0 R/enhanced.R 100644 → 100755
No changes.
View
@@ -76,7 +76,7 @@ Heatmap(matrix, col, name,
\item{na_col}{color for \code{NA} values.}
\item{rect_gp}{graphic parameters for drawing rectangles (for heatmap body).}
\item{color_space}{the color space in which colors are interpolated. Only used if \code{matrix} is numeric and \code{col} is a vector of colors. Pass to \code{\link[circlize]{colorRamp2}}.}
\item{cell_fun}{self-defined function to add graphics on each cell. Seven parameters will be passed into this function: \code{i}, \code{j}, \code{x}, \code{y}, \code{width}, \code{height}, \code{fill} which are row index,column index in \code{matrix}, coordinate of the middle points in the heatmap body viewport,the width and height of the cell and the filled color. }
\item{cell_fun}{self-defined function to add graphics on each cell. Seven parameters will be passed into this function: \code{i}, \code{j}, \code{x}, \code{y}, \code{width}, \code{height}, \code{fill} which are row index,column index in \code{matrix}, coordinate of the middle points in the heatmap body viewport,the width and height of the cell and the filled color. \code{x}, \code{y}, \code{width} and \code{height} are all \code{\link[grid]{unit}} objects.}
\item{row_title}{title on row.}
\item{row_title_side}{will the title be put on the left or right of the heatmap?}
\item{row_title_gp}{graphic parameters for drawing text.}
View
0 man/enhanced_basicplot.rd 100644 → 100755
No changes.
View
0 man/unify_mat_list.rd 100644 → 100755
No changes.
@@ -497,6 +497,98 @@ Heatmap(cor_mat, name = "correlation", col = col_fun, rect_gp = gpar(type = "non
Note `cell_fun` is applied to every cell through a `for` loop, so it will be a little bit slow
for large matrix.
One last example is to visualize a [GO game](https://en.wikipedia.org/wiki/Go_(game)). The input data takes
records of moves in the game.
```{r}
str = "B[cp];W[pq];B[dc];W[qd];B[eq];W[od];B[de];W[jc];B[qk];W[qn]
;B[qh];W[ck];B[ci];W[cn];B[hc];W[je];B[jq];W[df];B[ee];W[cf]
;B[ei];W[bc];B[ce];W[be];B[bd];W[cd];B[bf];W[ad];B[bg];W[cc]
;B[eb];W[db];B[ec];W[lq];B[nq];W[jp];B[iq];W[kq];B[pp];W[op]
;B[po];W[oq];B[rp];W[ql];B[oo];W[no];B[pl];W[pm];B[np];W[qq]
;B[om];W[ol];B[pk];W[qp];B[on];W[rm];B[mo];W[nr];B[rl];W[rk]
;B[qm];W[dp];B[dq];W[ql];B[or];W[mp];B[nn];W[mq];B[qm];W[bp]
;B[co];W[ql];B[no];W[pr];B[qm];W[dd];B[pn];W[ed];B[bo];W[eg]
;B[ef];W[dg];B[ge];W[gh];B[gf];W[gg];B[ek];W[ig];B[fd];W[en]
;B[bn];W[ip];B[dm];W[ff];B[cb];W[fe];B[hp];W[ho];B[hq];W[el]
;B[dl];W[fk];B[ej];W[fp];B[go];W[hn];B[fo];W[em];B[dn];W[eo]
;B[gp];W[ib];B[gc];W[pg];B[qg];W[ng];B[qc];W[re];B[pf];W[of]
;B[rc];W[ob];B[ph];W[qo];B[rn];W[mi];B[og];W[oe];B[qe];W[rd]
;B[rf];W[pd];B[gm];W[gl];B[fm];W[fl];B[lj];W[mj];B[lk];W[ro]
;B[hl];W[hk];B[ik];W[dk];B[bi];W[di];B[dj];W[dh];B[hj];W[gj]
;B[li];W[lh];B[kh];W[lg];B[jn];W[do];B[cl];W[ij];B[gk];W[bl]
;B[cm];W[hk];B[jk];W[lo];B[hi];W[hm];B[gk];W[bm];B[cn];W[hk]
;B[il];W[cq];B[bq];W[ii];B[sm];W[jo];B[kn];W[fq];B[ep];W[cj]
;B[bk];W[er];B[cr];W[gr];B[gk];W[fj];B[ko];W[kp];B[hr];W[jr]
;B[nh];W[mh];B[mk];W[bb];B[da];W[jh];B[ic];W[id];B[hb];W[jb]
;B[oj];W[fn];B[fs];W[fr];B[gs];W[es];B[hs];W[gn];B[kr];W[is]
;B[dr];W[fi];B[bj];W[hd];B[gd];W[ln];B[lm];W[oi];B[oh];W[ni]
;B[pi];W[ki];B[kj];W[ji];B[so];W[rq];B[if];W[jf];B[hh];W[hf]
;B[he];W[ie];B[hg];W[ba];B[ca];W[sp];B[im];W[sn];B[rm];W[pe]
;B[qf];W[if];B[hk];W[nj];B[nk];W[lr];B[mn];W[af];B[ag];W[ch]
;B[bh];W[lp];B[ia];W[ja];B[ha];W[sf];B[sg];W[se];B[eh];W[fh]
;B[in];W[ih];B[ae];W[so];B[af]"
```
Then we convert it into a matrix:
```{r}
str = gsub("\\n", "", str)
step = strsplit(str, ";")[[1]]
type = gsub("(B|W).*", "\\1", step)
row = gsub("(B|W)\\[(.).\\]", "\\2", step)
column = gsub("(B|W)\\[.(.)\\]", "\\2", step)
mat = matrix(nrow = 19, ncol = 19)
rownames(mat) = letters[1:19]
colnames(mat) = letters[1:19]
for(i in seq_along(row)) {
mat[row[i], column[i]] = type[i]
}
mat
```
Black and white stones are put based on the values in the matrix:
```{r, fig.width = 8, fig.height = 8}
Heatmap(mat, name = "go", rect_gp = gpar(type = "none"),
cell_fun = function(j, i, x, y, w, h, col) {
grid.rect(x, y, w, h, gp = gpar(fill = "#dcb35c", col = NA))
if(i == 1) {
grid.segments(x, y-h*0.5, x, y)
} else if(i == nrow(mat)) {
grid.segments(x, y, x, y+h*0.5)
} else {
grid.segments(x, y-h*0.5, x, y+h*0.5)
}
if(j == 1) {
grid.segments(x, y, x+w*0.5, y)
} else if(j == ncol(mat)) {
grid.segments(x-w*0.5, y, x, y)
} else {
grid.segments(x-w*0.5, y, x+w*0.5, y)
}
if(i %in% c(4, 10, 16) & j %in% c(4, 10, 16)) {
grid.points(x, y, pch = 16, size = unit(2, "mm"))
}
r = min(unit.c(w, h))*0.45
if(is.na(mat[i, j])) {
} else if(mat[i, j] == "W") {
grid.circle(x, y, r, gp = gpar(fill = "white", col = "white"))
} else if(mat[i, j] == "B") {
grid.circle(x, y, r, gp = gpar(fill = "black", col = "black"))
}
},
col = c("B" = "black", "W" = "white"),
show_row_names = FALSE, show_column_names = FALSE,
column_title = "One famous GO game",
heatmap_legend_param = list(title = "Player", at = c("B", "W"),
labels = c("player1", "player2"), grid_border = "black")
)
```
## Session info
```{r}

0 comments on commit d7e872f

Please sign in to comment.