سؤال

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.

هل كانت مفيدة؟

المحلول

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)
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top