I have two columns or variables. When I use cluster_col = T
, my pheatmap is difficult to interpret trying to distinguish salinity and population. When I use cluster_col = F
, pheatmap automatically clusters population first, then salinity. I want it to first cluster salinity and within each salinity cluster each population. How can I do this? I have already tried rearranging the order of population and salinity.
df <- data.frame(colData(dds)[,c("salinity","population")])
rownames(df) <- colnames(dds)
colnames(df) <- c("salinity","population")
pheatmap(
assay(vsd)[lfcorder[1:10],],
cluster_rows=F,
show_rownames=T,
cluster_cols=T,
annotation_col=df
)
pheatmap(
assay(vsd)[lfcorder[1:10],],
cluster_rows=F,
show_rownames=T,
cluster_cols=F,
annotation_col=df
)
Thanks Ram!
I ended up using
I think this is the same idea you were talking about.
Yep - dplyr vs base R for sorting is the difference between our approaches. Glad things worked out!
Given it was the same concept, can you please accept my answer to mark the post resolved? I'll edit it and add a statement about how dplyr can be used as well.