Question

So I am attempting to create a dendrogram of 42 different genes based on a distance matrix. The figure was created with:

d6 = dist( t( cildata ) )

hc6 = hclust( d6 )

plot( hc6 )

I then just saved that plot as a jpeg.

I need to save a version of the plot with the gene names italicized, though, and am not sure how to go about doing that. I have seen similar questions relating to how to change main plot titles to italics, but not the labels inside the plot.

Any and all help is greatly appreciated.

Thanks, Marcus G.

Was it helpful?

Solution

hc <- hclust(dist(USArrests), "ave")
italicLeafs <- c("Iowa", "New Hampshire") # select: italic leafs

den <- dendrapply(as.dendrogram(hc), FUN=function(n) {
  if(is.leaf(n)) 
    if (attr(n, "label") %in% italicLeafs) 
      attr(n, "label") <- as.expression(substitute(italic(leaf), list(leaf=attr(n, "label"))))
  n
})

plot(den)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top