[R] Fwd: Overlapping legend in a circular dendrogram

N Meriam meri@m@nef @ending from gm@il@com
Fri Jan 11 22:10:39 CET 2019


Yes I know. Sorry if I reposted this but it's simply because I've
received an email mentioning that the file was too big that's why I
modified my question and reposted it.
I don't want to oblige anyone to respond. I really thought the issue
was my file (too big so nobody received it).

Thanks for your understanding,
Best Myriam

On Fri, Jan 11, 2019 at 3:03 PM Bert Gunter <bgunter.4567 using gmail.com> wrote:
>
> This is the 3rd time you've posted this. Please stop re-posting!
>
> Your question is specialized and involved, and you have failed to provide a reproducible example/data. We are not obliged to respond.
>
> You may do better contacting the maintainer, found by ?maintainer, as recommended by the posting guide for specialized queries such as this.
>
>
> Bert Gunter
>
> "The trouble with having an open mind is that people keep coming along and sticking things into it."
> -- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )
>
>
> On Fri, Jan 11, 2019 at 12:47 PM N Meriam <meriam.nef using gmail.com> wrote:
>>
>> Hi, I'm facing some issues when generationg a circular dendrogram.
>> The labels on the left which are my countries are overlapping with the
>> circular dendrogram (middle). Same happens with the labels (regions)
>> located on the right.
>> I run the following code and I'd like to know what should be changed
>> in my code in order to avoid that.
>>
>> load("hc1.rda")
>> library(cluster)
>> library(ape)
>> library(dendextend)
>> library(circlize)
>> library(RColorBrewer)
>>
>> labels = hc1$labels
>> n = length(labels)
>> dend = as.dendrogram(hc1)
>> markcountry=as.data.frame(markcountry1)
>> #Country colors
>> groupCodes=as.character(as.factor(markcountry[,2]))
>> colorCodes=rainbow(length(unique(groupCodes))) #c("blue","red")
>> names(colorCodes)=unique(groupCodes)
>> labels_colors(dend) <- colorCodes[groupCodes][order.dendrogram(dend)]
>>
>> #Region colors
>> groupCodesR=as.character(as.factor(markcountry[,3]))
>> colorCodesR=rainbow(length(unique(groupCodesR))) #c("blue","red")
>> names(colorCodesR)=unique(groupCodesR)
>>
>> circos.par(cell.padding = c(0, 0, 0, 0))
>> circos.initialize(factors = "foo", xlim = c(1, n)) # only one sector
>> max_height = attr(dend, "height")  # maximum height of the trees
>>
>> #Region graphics
>> circos.trackPlotRegion(ylim = c(0, 1.5), panel.fun = function(x, y) {
>>   circos.rect(1:361-0.5, rep(0.5, 361), 1:361-0.1, rep(0.8,361), col =
>> colorCodesR[groupCodesR][order.dendrogram(dend)], border = NA)
>> }, bg.border = NA)
>>
>> #labels graphics
>> circos.trackPlotRegion(ylim = c(0, 0.5), bg.border = NA,
>>                        panel.fun = function(x, y) {
>>
>>                            circos.text(1:361-0.5,
>> rep(0.5,361),labels(dend), adj = c(0, 0.5),
>>                                        facing = "clockwise", niceFacing = TRUE,
>>                                        col = labels_colors(dend), cex = 0.45)
>>
>>                        })
>> dend = color_branches(dend, k = 6, col = 1:6)
>>
>> #Dendrogram graphics
>> circos.trackPlotRegion(ylim = c(0, max_height), bg.border = NA,
>>                        track.height = 0.4, panel.fun = function(x, y) {
>>                          circos.dendrogram(dend, max_height = 0.55)
>>                        })
>> legend("left",names(colorCodes),col=colorCodes,text.col=colorCodes,bty="n",pch=15,cex=0.8)
>> legend("right",names(colorCodesR),col=colorCodesR,text.col=colorCodesR,bty="n",pch=15,cex=0.35)
>>
>> Cheers,
>> Myriam
>>
>> ______________________________________________
>> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.



-- 
Meriam Nefzaoui
MSc. in Plant Breeding and Genetics
Universidade Federal Rural de Pernambuco (UFRPE) - Recife, Brazil



More information about the R-help mailing list