Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: correct color order for tip labels and enable to change tip labels #234

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

takosa
Copy link

@takosa takosa commented Dec 5, 2023

The coloring by fac argument was incorrect because the order of the factors returned by the fac_dipatcher function was different from the order of the tips(leaves) in dendrograms, which has been corrected. Also, the code for changing tip labels by fac and/or labels arguments was ineffective, which has been corrected.

background

When I was coloring tip labels by fac argument in CLUST function, I noticed that the coloring is constant regardless of the topology of dendrograms. As an example, I ran the following code and found that there was a discrepancy between the tip labels and the colors.

hearts |> efourier() |> CLUST(fac=~aut) + coord_flip(xlim=c(25,35)) 

This may be due to the fact that the following code specifies the return value of fac_dispatcher as it is, when it should specify the colors in the same order as tip labels.

f <- fac_dispatcher(x, fac)
d %<>% dendextend::set("labels_colors",
                       palette(nlevels(f))[f])

Also, the following code seems to intend to change labels appropriately when fac or labels arguments are specified, but to no effect. It seems that this needs to be corrected appropriately as well.

# handle labels (could be shortened)
dendextend::`labels<-`(d, names(x))
if (!missing(fac) && !is.null(fac))          # if fac is provided, use it
  dendextend::`labels<-`(d, as.character(fac_dispatcher(x, fac)))
if (!missing(labels) && !is.null(labels))      # but if labels is provided, overwrite it
  dendextend::`labels<-`(d, as.character(fac_dispatcher(x, labels)))

The coloring by `fac` argument was incorrect because the order of the factors
returned by the `fac_dipatcher` function was different from the order of
the tips(leaves) in dendrograms, which has been corrected. Also, the code for
changing tip labels by `fac` and/or `labels` arguments was ineffective,
which has been corrected.
@takosa takosa changed the title fix: correct color order for tip and enable to change tip labels fix: correct color order for tip labels and enable to change tip labels Dec 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant