Reputation: 336
I am trying to make a phylogenic dendogram plot in R. I used the following code to get pretty much what I am after:
library(igraph)
library(proxy)
library(factoextra)
hc = hclust(dist(mtcars))
dend <- as.dendrogram(hc)
fviz_dend(dend, k = 5,
repel = TRUE,
type ="phylogenic", show_labels=T)
Now though, I would like to increase the size of the individual points. As per the package dendextend, I tried adding leaves_cex in two different ways, as below, both with no success (outcomes explained in code, below).
library(dendextend)
fviz_dend(dend, k = 5,
repel = TRUE, leaves_cex=50, # circle size is unchanged
type ="phylogenic", show_labels=T)
dend <- as.dendrogram(hc,type ="phylogenic") %>%
set("leaves_cex", 50) %>% #creates a rectangular dendogram, phylogenic layout lost
plot()
I can also try using the ape package, as below. Here I can specify the colours, with tip.color, but there is no variable for tip size/shape. Here, the layout is also not as nice as in the original plot above.
library(ape)
clus5 = cutree(hc, 5)
plot(as.phylo(hc),type="unrooted", tip.color = clus5 )
How can I change the leaf marker appearance for properties other than colour?
Upvotes: 1
Views: 361
Reputation: 1857
Using the package ape
, the leaves appearance are pretty easy to modify by plotting them separately using the tiplabels
function:
## The tree
my_tree <- as.phylo(hc)
## The plot without the tips
plot(my_tree,type = "unrooted", show.tip.label = FALSE)
## The tips (leaves) plotted separately with many options
tiplabels(my_tree$tip.label,
col = clus5, # Some colours
cex = 0.5, # The size
adj = -1, # Position adjustment
bg = "orange", # A background colour
frame = "circle" # Some circles
) #... Many more options
You can have a look at the ?tiplabels
for more info and options.
Upvotes: 2