Hi there, I constructed a co-expression network using WGCNA. As you could know, we identify co-expressed gene modules by performing hierarchical clustering method based on TOM-based dissimilarity. So, a distance matrix was computed here to draw a dendrogram of eigen-genes is TOM-based dissimilarity.
Now, I want to draw a heatmap that visualizes the overlap of eigen-genes among inter-modules using the function heatmap by the package ComplexHeatmap. But the problem is, the function heatmap does not provide the above TOM-based dissimilarity distance method. I wonder how to do it? The code lines I used to draw heatmap as follows:
> plotTOM = dissTOM^7; #Transform dissTOM with a power to make moderately strong connections more visible in the heatmap
> diag(plotTOM) = NA; #Set diagonal to NA for a nicer plot
> sizeGrWindow(9,9)
> heatmap(plotTOM, show_row_names = TRUE, show_column_names = FALSE,
row_dend_reorder = TRUE, column_dend_reorder = TRUE,
clustering_distance_rows = ???,
clustering_distance_columns = ???,
clustering_method_rows = "ward.D2",
clustering_method_columns = "ward.D2")
I define my own distance in R like:
> softPower = 6;
> adjacency = adjacency(df, power = softPower); #df is my gene expression data
> TOM = TOMsimilarity(adjacency);
> dissTOM = 1-TOM #distance matrix
Hey,
You can add any function that you want via:
Kevin
Hi @Kevin, my heatmap works well when following your advice:
But the thing is, the dendrogram height show on the top and the left of heatmap don't look right.
I do not believe you are implementing this in the right way. Basically, in order to use my solution in the way that you want, you have to understand really well how the WGCNA functions work.
I am not sure, but you may need something like this: