Visualizes two numeric matrices of identical shape in a single heatmap by splitting each cell along a diagonal. The upper triangle encodes one matrix (default white to red) and the lower triangle enco
翻译准备中
数据R · CSSGitHub @gcol33在线运营者未确认
试用过了吗? 点一下就好,无需登录。
尚未检测到更新。GitHub 发布版本后会显示在这里。
个人 GitHub 账号下公开仓库的所有者可以登录并验证所有权,自行管理介绍,无需管理员批准。
登录并生成验证文件,在 30 分钟内将其提交到此仓库的默认分支。其他分支或分叉仓库中的文件无效。然后在下方检查文件,即可无需管理员批准直接管理项目。请保留文件以维持管理权限。
如需登录,将前往登录页面。登录后请回到此处,再次点击所选的验证按钮。
在项目文件夹中运行 /nomorevibe verify,即可验证所有权并自行管理介绍。
一分钟完成验证Visualizes two numeric matrices of identical shape in a single heatmap by splitting each cell along a diagonal. The upper triangle encodes one matrix (default white to red) and the lower triangle encodes the other (default white to blue). Useful for compact paired comparisons such as observed vs. predicted, mean vs. variance, correlation vs. significance, or train vs. test performance. Built on ggplot2.
翻译准备中
取自仓库 README
正在加载完整 README。
查看完整 README ↗two matrices in one heatmap
BiHeat draws two numeric matrices of the same shape in one heatmap, such as observed and predicted values, a mean and its variance, or correlations and their p-values.
Each cell is split along a diagonal. The upper triangle shows the value from one matrix and the lower triangle the value from the other, each on its own colour gradient, and the plots are built with ggplot2. Both values for a row and column sit in the same cell, so you can see where the two matrices agree and where they differ, and decide which cells to look at more closely.
BiHeat supports:
breed()
aligns the two on their shared names and reports the Pearson and
Spearman correlation, RMSE, MAE and the number of missing cells.geom_biheat()
draws the same cells as a layer, so facets, coordinate systems and
other layers work as usual, and the fill scale stays free for them.bi_legend() returns the paired
colour key as a standalone grob, for figures where the panel is
assembled separately.Other packages draw related displays.
corrplot has
corrplot.mixed(), which draws one display above the diagonal of a
correlation matrix and another below it.
ComplexHeatmap can
split a cell through a custom cell_fun, alongside its clustering and
annotation tools. BiHeat splits every cell of two plain matrices and
gives each half its own gradient.
# install.packages("pak")
pak::pak("gcol33/BiHeat")
biheat().breed(), set rendering
options with incubate() and draw with plot().comes_out().library(BiHeat)
set.seed(1)
species <- LETTERS[1:6]
sites <- letters[1:8]
observed <- matrix(runif(48), 6, 8, dimnames = list(species, sites))
noise <- matrix(rnorm(48, sd = 0.1), 6, 8)
predicted <- observed + noise
biheat(observed, predicted)
The first matrix fills the upper triangle (white to red) and the second the lower triangle (white to blue). Where the two disagree, the halves of a cell differ in shade.
The input is two numeric matrices. Where both carry row or column names, they are matched on the names they share; an axis without names on both sides is matched by position and needs the same length. Getting started with BiHeat describes how the matrices are aligned and how missing cells are drawn.
biheat() is a shortcut for three steps. breed() pairs the two
matrices into a clutch, an object holding both matrices aligned on their
shared names together with their comparison statistics:
clutch <- breed(observed, predicted)
clutch
#> <clutch>
#> upper: observed (6 x 8)
#> lower: predicted (6 x 8)
#> align: intersect (6 rows x 8 cols kept)
#> cells: 48 finite / 48 total (0 NA)
#> pearson: 0.955 rmse: 0.0908 mae: 0.0693
incubate() adds rendering options to a clutch, and each call adds to
the options set before. plot() draws it:
clutch |>
incubate(scale = "shared", split = "up") |>
plot()
The verbs take a clutch and return one, so they chain. switch_sides()
swaps which matrix is on top, straighten() flips the direction of the
diagonal and bothways() toggles between separate and shared colour
scales:
clutch |>
switch_sides() |>
straighten() |>
bothways() |>
plot()
scale = "separate" (the default) gives the upper and lower triangles
their own ranges. Use it when the two matrices measure different
things, such as a correlation and its p-value or a mean and its
variance.scale = "shared" puts both triangles on one range, so the colours of
the two halves can be compared directly. Use it when the matrices are
in the same units, such as observed and predicted values or the
accuracy of two models.Styling and layout covers palettes, printed values, cell geometry, skewed values and the order of rows and columns.
geom_biheat() draws the split cells as a ggplot2 layer from a data
frame with one row per cell, which is the shape comes_out() returns:
library(ggplot2)
cells <- comes_out(clutch)
ggplot(cells, aes(col, row, upper = upper, lower = lower)) +
geom_biheat() +
theme_biheat()
Each triangle carries its own gradient, so neither uses the fill
scale, which stays free for another layer. Split cells inside a
ggplot
shows faceting, continuous axes and layers drawn on top.
Start with Getting started with
BiHeat: from two
matrices to a split heatmap, how the matrices are aligned and what
plot() returns.
geom_biheat() layer with facets, continuous axes and other
layers.Questions and bug reports go to the GitHub issues. A bug report is easiest to act on with a small reproducible example, for instance made with reprex.
“Software is like sex: it’s better when it’s free.” — Linus Torvalds
I’m a PhD student who builds R packages in my free time because I believe good tools should be free and open. I started these projects for my own work and figured others might find them useful too.
If this package saved you some time, buying me a coffee is a nice way to say thanks. It helps with my coffee addiction.
BiHeat is licensed under MIT.
Colling G (2026). _BiHeat: Diagonally Split Heatmaps for Paired Matrix
Visualization_. R package version 0.1.0,
<https://gillescolling.com/BiHeat/>.
BibTeX:
@Manual{colling2026biheat,
title = {BiHeat: Diagonally Split Heatmaps for Paired Matrix Visualization},
author = {Gilles Colling},
year = {2026},
note = {R package version 0.1.0},
url = {https://gillescolling.com/BiHeat/},
}