-
Notifications
You must be signed in to change notification settings - Fork 22
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
Clustering order supersedes manual groups #116
Comments
Thanks for the heads up. If you could check if the behaviour occurs
|
Yes this also occurs also with two or more columns (my original data has more than 10 columns). Here is a replacement for the example above, where I added a second column and modified the values slightly. example <- tribble(~Compound_Name, ~Compound_Class, ~col, ~log2fc, Upon modifying the values, it seems that the issue might not stem from the clustering after all, so maybe it is related to the names?
I think this is what I did in example2 above, or how do you mean it? Indeed in this case the behavior does not occur. When grouping by the variable as character vector and then mutating it into a factor the behavior still occurs. example %>% |
Puzzling.. Right now, I don't have the throughput to debug the function. I will put it on the do-to list. If you happen to want to give it a shot, you might be able to fix the bug in a short time and become part of the tidy* family ;) |
Small addition: I just removed the "D-" and "L-" from "D-maltoseCH" and "L-homoserineAA" and indeed the behavior does not appear. Hope this info helps in finding the issue. Of course, those are globally not the most common names, but these are quite common in metabolomics and I could imagine similar names for e.g. cell lines, or strains, so I think this is still worth looking into. |
Sure. No worries and no hurry! I might try to look into it but I am not sure if I am experienced enough to solve it. I will report it here if I find anything. |
I can confirm that the issue can be fixed by converting the variable into a factor. I tried replacing all dots, spaces and dash characters with underscores, thinking that it could somehow be related to that, but this made no difference. But converting to factor works for now. |
Can you please send me the list of variables, in their simplest form, where they fail if not transformed into factors? This bit puzzles me a lot. Try to get them in the simplest form and the smallest number where the error appears, we might be able to identify what is the cause. We need to fix this. |
Hello all, thanks for bringing this to our attention. We will have a dedicated person for tidyomics who will also maintain tidyHeatmap. Hopefully, this will happen soon. |
on it.. |
Just to clarify I fixed converting the row names into factor. |
I was trying to use tidyHeatmap to make heatmaps of metabolomics data, when I noticed a strange behaviour that rows escaped their manually assigned grouping and ended up in the wrong grouping.
It is a bit tricky to explain, so I am providing a small example here:
example <- tribble(~Compound_Name, ~Compound_Class, ~col, ~log2fc,
"L-homoserineAA", "AA", 1, 2.93,
"cellobioseCH", "CH", 1, 2.09,
"D-maltoseCH", "CH", 1, 3.08,
"pectinCH", "CH", 1, -3.04,
"raffinoseCH", "CH", 1, -2.10)
example %>%
group_by(Compound_Class) %>%
heatmap(.row = Compound_Name, .col = col, .value = log2fc)
example2 <- example %>%
mutate(Compound_Name = as_factor(Compound_Name))
example2 %>%
group_by(Compound_Class) %>%
heatmap(.row = Compound_Name, .col = col, .value = log2fc)
AA stands for amino acid and CH stands for carbohydrate (this is not important for the understanding of the issue, just to provide some context). I also added the compound class to the end of the compound name.
When the .row variable is just a character vector D-maltoseCH is switched with L-homoserine and both show up in the wrong group (putatively due to the clustering by the value?)
![example](https://user-images.githubusercontent.com/73993884/231769453-bc82e157-d149-47cf-9851-3aa81b5ddc94.png)
When mutating Compound_Name into a factor they both get correctly assigned:
![example2](https://user-images.githubusercontent.com/73993884/231770006-c8693421-ad40-434f-ba69-6acace97ad15.png)
I don't know if this is an issue of tidyHeatmap or of the underlying ComplexHeatmap package but I think it would be important to find out and fix this behavior. Transforming the .row variable to a factor seems to work but I am not sure whether this is how this vector is most commonly used.
Let me know if something is unclear.
Sorry for this somewhat strange example. I tried to recreate the example with mtcars or diamonds but I wasn't able to achieve this strange behavior.
The text was updated successfully, but these errors were encountered: