You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can parse the viewport name to get the slice number
Heatmap(matrix(rnorm(81), nrow=9),
layer_fun=function(j, i, x, y, w, h, fill) {
slice_numbers<-stringr::str_match_all(
grid::current.viewport()$name,
"_(\\d+)_(\\d+)$"
)[[1L]][1L, ]
# the second and third items are the slice row and column numberif (slice_numbers[[2L]] ==slice_numbers[[3L]]) {
grid::grid.rect(
gp= gpar(lty=2, lwd=2, col="red", fill=NA)
)
}
},
row_km=5, column_km=5L
)
hello
my code as follows:
Heatmap(expr,
col = colorRamp2(c(-5,0,5), c("navy","#F2F2F2","firebrick3")),
cluster_rows = F,
cluster_columns = F,
na_col = "white",
column_split = factor(anno$module),
row_split = gene_group$module,
column_title_rot = 90,
column_gap = unit(0.5, "mm"),
row_gap = unit(0.5, "mm"),
# column_title=NULL,
# row_title=NULL,
border = F,
use_raster = T,
heatmap_legend_param = list(title = "expr", at = seq(-4, 4, 2),color_bar = "continuous"),
top_annotation = ha,
layer_fun = function(j, i, x, y, width, height, fill){
v = pindex(expr, i, j)
if(min(i)==min(j)){
grid.rect(gp = gpar(lwd = 1, fill = "transparent" ,col="black",lty=2))
}
},
show_column_names = F,
show_row_names = F)
and I get this fig
![fig1](https://private-user-images.githubusercontent.com/114064141/321145891-43f47850-8d04-4275-a33a-9cfd1f1f5627.jpg?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjAxNjAzNDQsIm5iZiI6MTcyMDE2MDA0NCwicGF0aCI6Ii8xMTQwNjQxNDEvMzIxMTQ1ODkxLTQzZjQ3ODUwLThkMDQtNDI3NS1hMzNhLTljZmQxZjFmNTYyNy5qcGc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwNzA1JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDcwNVQwNjE0MDRaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1iZmYzZmM1ZTc0ZGY5ZjA1N2FiZGQyNzk3ZGYyNmYyZjMzNjlmZjA3NTFlZTM0NzhjODY1MTgyZDJlOTFjNTA2JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.xyZX59eKrUzkVG1Q5EGvcQd-R6TnMELYEN7_ebNcFh0)
However My ideal result would be like this
![fig2](https://private-user-images.githubusercontent.com/114064141/321146741-f273afd7-9611-465a-b27d-721c34b3f9ce.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjAxNjAzNDQsIm5iZiI6MTcyMDE2MDA0NCwicGF0aCI6Ii8xMTQwNjQxNDEvMzIxMTQ2NzQxLWYyNzNhZmQ3LTk2MTEtNDY1YS1iMjdkLTcyMWMzNGIzZjljZS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwNzA1JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDcwNVQwNjE0MDRaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1mODAxZDU2NjkwYTIwODUxMmI0ZmU1MDAxZTczNGU1OTIxZTU5NDU3NjRkNWI0ZTk3MzVlZTg4NmM3Y2Q1NDJkJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.Hn3pAGgGPaJ4LWXQu1pqRoHftxn9jppi6cib0uSZhec)
How Do I modify this code?
The text was updated successfully, but these errors were encountered: