Comments (5)
Hi,
You can pass clusters
to split
options:
set.seed(12345)
mat = matrix(rnorm(100), nr = 25)
hr = hclust(dist(mat), method = "average")
clusters = dendextend::cutree(hr, k = 5)
Heatmap(mat, split = clusters)
from complexheatmap.
another way is to mark subtrees with different colors instead of splitting the heatmap
set.seed(12345)
mat = matrix(rnorm(100), nr = 25)
hr <- hclust(dist(mat), method = "average")
hr = as.dendrogram(hr)
clusters <- dendextend::cutree(hr, k = 5)
Heatmap(mat, name = "foo", cluster_rows = hr)
add_alpha = function(col, alpha = 0.5) {
rgb(t(col2rgb(col)/255), alpha=alpha)
}
decorate_row_dend("foo", {
ind = clusters[order.dendrogram(hr)]
first_index = function(l) which(l)[1]
last_index = function(l) { x = which(l); x[length(x)] }
x1 = sapply(1:5, function(i) first_index(ind == i)) - 1
x2 = sapply(1:5, function(i) last_index(ind == i))
grid.rect(y = 1-x1/length(ind), height = (x2 - x1)/length(ind), just = "top",
default.units = "npc", gp = gpar(fill = add_alpha(1:5, 0.2), col = NA))
})
from complexheatmap.
Thanks for the suggestion.
I think given that my matrix is quite large, I was hoping to split the tree into smaller subtree rather than highlighting the dendrogram with different colours.
Unfortunately when I tried passing the split = clusters to the Heatmap( ), I am now getting a different error: Error in object@row_dend_list[[k]] : subscript out of bounds
The toy dataset works for me - is there a limit to the size of dataframe that I can plot with Heatmap?
from complexheatmap.
Is it possible for you to send me the data matrix? I simulated a huge matrix and split into 100 pieces and it works fine.
On the other hand, why do you want to split rows into 100 parts? I think it is not a good way for visualization. (See following heatmap, the heatmap is split into 100 parts)
from complexheatmap.
Hmm I see what you meant. It doesn't really look that great.
Just sent you an email with the dataframe to your gmail.
from complexheatmap.
Related Issues (20)
- Question: How to format labels in anno_barplot
- Question about setting color function
- Conditional coloring of heatmap
- Asterisks to indicate significant associations
- picking new set of random colors for annotations
- Anno_textbox not scaling when saving image
- ComplexHeatmap crashing R session HOT 1
- Change pch size and color in legend
- Not getting correct row order in the row split ComplexHeatmap R HOT 1
- Help with anno_boxplot
- `column_order` is ignored when `column_split` is used HOT 2
- Making a heatmap with categorical value such as CNV(AMP, DEL) status
- Cluster column slices but not columns within slices
- Feature request: integrate ` heatmap_legend_side` into ` heatmap_legend_param`?
- Oncoprint - Customize with continuous color scale
- Color Branches w/ K-Means
- Padding not working with heatmap list HOT 1
- ComplexHeatmap with specific rownames
- How to use layer_fun to add a box in the aim areas
- Error in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y, :
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from complexheatmap.