I am doing WGBS data analysis, where I am using MethylKIT package. I used clusterSamples(object, dist= "correlation", method= "ward", plot=TRUE) to get a dendrogram. How can I change the color of the line according to my need. I mean what argument or whatever should I put.
1 answer
You can inspect the internals of functions in R by calling the function without parentheses, e.g. clusterSamples. If the function is written in C/Fortran etc. its internals will remain elusive, but for functions written in R, you usually get to see what you need to know.
if(plot){
my.cols=rainbow(length(unique(treatment)), start=1, end=0.6)
dend = as.dendrogram(hc)
dend_colored <- dendrapply(dend, colLab,col.list)
plot(dend_colored, ...);
# end of plot
}
return(hc)
}
Evidently, there are no parameters to customize the colors, since they are auto-generated. The function, however, returns hc, which is the result of the hierarchical clustering. It is fairly straightforward to feed this into the wonderful ggtree package by Guangchuang Yu that will generate beautiful and highly customizable trees. See chapter 9.2 of the book.
Log in to answer this question.