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

Strange heatmap behavior when handling missing (NA) values #176

Open
alkaZeltser opened this issue Apr 6, 2024 · 2 comments
Open

Strange heatmap behavior when handling missing (NA) values #176

alkaZeltser opened this issue Apr 6, 2024 · 2 comments

Comments

@alkaZeltser
Copy link

I'm working with create.heatmap and encountering odd behavior when dealing with NA values and single-row heatmaps.
The weirdest thing is that the NA missing values seem to be contaminating adjacent cells in certain cases.

I will have to resort to manually replacing NA with a pre-defined color as opposed to using the fill.colour option, which is kind of a waste of a nice feature.

For example:

real.continuous.test.data <-  t(data.frame(
    continuous.data = c(NA, '#3FDADC', '#BFF2F3', '#1FD4D6', NA,'#7FE6E8', '#5FE0E2', '#DFF8F9', '#FFFFFF', '#9FECED')
    ));

categorical.test.data <- t(data.frame(
    categorical.data = c(NA, 'red', 'blue', 'red', NA, 'green', 'yellow', 'purple', 'orange', 'pink')
    ));

# Ex1 Second column inherits NA from first column but the other NA is handled fine?
create.heatmap(
    x = real.continuous.test.data,
    input.colours = TRUE,
    clustering.method = 'none',
    same.as.matrix = TRUE,
    print.colour.key = FALSE
    );

# Ex2 Both second and fourth columns inherit NA from first and fifth column?
create.heatmap(
    x = categorical.test.data,
    input.colours = TRUE,
    clustering.method = 'none',
    same.as.matrix = TRUE,
    print.colour.key = FALSE
    )

# Ex3 Two rows, now the categorical data looks correct but continuous data remains contaminated
create.heatmap(
    x = rbind(categorical.test.data, real.continuous.test.data),
    input.colours = TRUE,
    clustering.method = 'none',
    same.as.matrix = TRUE,
    print.colour.key = FALSE
    )

Ex1:
Screenshot 2024-04-06 at 12 50 11 AM

Ex2:
Screenshot 2024-04-06 at 12 51 04 AM

Ex3:
Screenshot 2024-04-06 at 12 51 52 AM

@jarbet
Copy link
Contributor

jarbet commented May 31, 2024

@alkaZeltser I didn't see your issue, but I posted a similar issue recently with a potential solution #181

@alkaZeltser
Copy link
Author

alkaZeltser commented May 31, 2024

@alkaZeltser I didn't see your issue, but I posted a similar issue recently with a potential solution #181

Yeah I guess I already mentioned this workaround above, which is to replace NAs explicitly with colors. It's just unfortunate because the entire point of the fill.colour parameter is to generalize away this extra step.

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

No branches or pull requests

2 participants