cell_fun_bivariate | R Documentation |
ComplexHeatmap cell function with bivariant color
cell_fun_bivariate(
m,
prefix = "",
suffix = "",
cex = 1,
col_hm,
outline = FALSE,
outline_style = c("none", "darker", "contrast", "lighter", "black", "same"),
abbrev = FALSE,
show = NULL,
rot = 0,
sep = "\n",
mcolor = NULL,
pch = NULL,
size_fun = NULL,
size_by = 1,
grid_color = "grey80",
type = c("bivariate", "univariate"),
invert = FALSE,
verbose = FALSE,
...
)
m |
|
prefix , suffix |
|
cex |
|
col_hm |
|
outline |
|
outline_style |
|
abbrev |
|
show |
|
rot |
|
sep |
|
mcolor |
|
pch |
|
size_fun |
|
grid_color |
|
type |
|
invert |
|
... |
additional arguments are passed to |
This function serves as a convenient method to use a bivariate color scale (biscale) to color heatmap cells.
See:
https://kwstat.github.io/pals/
https://nowosad.github.io/post/cbc-bp2/
https://cran.r-project.org/web/packages/biscale/vignettes/biscale.html
This function takes two numeric
data matrices, a color function
that accepts two numeric values as input and returns a color.
This function can also optionally display a text label
inside each heatmap cell, use argument show
to indicate which matrix
or matrices in m
to use for the label.
Other jam utility functions:
avg_angles()
,
avg_colors_by_list()
,
call_fn_ellipsis_deprecated()
,
collapse_mem_clusters()
,
colorRamp2D()
,
deconcat_df2()
,
display_colorRamp2D()
,
enrichList2geneHitList()
,
filter_mem_genes()
,
filter_mem_sets()
,
find_colname()
,
get_hull_data()
,
get_igraph_layout()
,
gsubs_remove()
,
handle_igraph_param_list()
,
isColorBlank()
,
make_legend_bivariate()
,
make_point_hull()
,
mem_find_overlap()
,
order_colors()
,
rank_mem_clusters()
,
rotate_coordinates()
,
subgraph_jam()
,
subset_mem()
,
summarize_node_spacing()
,
xyAngle()
set.seed(12);
m <- matrix(rnorm(36)*2.5, ncol=4)
colnames(m) <- LETTERS[1:4]
rownames(m) <- letters[1:9]
m2 <- m;
m2[] <- abs(rnorm(36)*3);
mcolor <- matrix(ncol=3,
c("white", "white", "white",
"royalblue4", "gold", "red"),
byrow=TRUE);
col_bivariate <- colorRamp2D(
column_breaks=seq(from=-2, to=2, length.out=3),
row_breaks=seq(from=0, to=5, length.out=2),
mcolor);
display_colorRamp2D(col_bivariate)
# the heatmap can be created in one step
hm <- ComplexHeatmap::Heatmap(m * m2,
border=TRUE,
col=col_bivariate,
heatmap_legend_param=list(
color_bar="discrete",
border=TRUE,
at=-4:4),
cell_fun=cell_fun_bivariate(list(m, m2),
col_hm=col_bivariate,
prefix=c("-log10P: ", "z-score: "),
show=2:1),
show_heatmap_legend=FALSE,
)
lgds <- make_legend_bivariate(col_bivariate,
ylab="-log10pvalue",
xlab="z-score");
ComplexHeatmap::draw(hm, annotation_legend_list=lgds)
lgds2 <- make_legend_bivariate(col_bivariate,
row_breaks=seq(from=0, to=2, by=0.25),
ylab="-log10pvalue");
ComplexHeatmap::draw(hm, annotation_legend_list=lgds2)
# heatmap using point circles
ctmax <- 6;
point_size_max <- 12;
point_size_min <- 1;
size_fun_custom <- approxfun(
x=c(1, ctmax),
yleft=0,
ties="ordered",
yright=point_size_max,
y=c(1,
point_size_max));
ct_ticks <- seq(from=0, to=6);
ct_tick_sizes <- size_fun_custom(ct_ticks);
hm2 <- ComplexHeatmap::Heatmap(m * m2,
border=TRUE,
col=col_bivariate,
heatmap_legend_param=list(
color_bar="discrete",
border=TRUE,
at=-4:4),
cell_fun=cell_fun_bivariate(list(m, m2),
pch=21,
size_fun=size_fun_custom,
size_by=2,
outline_style="black",
col_hm=col_bivariate,
prefix=c("-log10P: ", "z-score: "),
show=NULL),
show_heatmap_legend=FALSE,
)
ComplexHeatmap::draw(hm2, annotation_legend_list=lgds)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.