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

create.heatmap input.colours = TRUE cannot handle missing values #181

Open
jarbet opened this issue May 22, 2024 · 0 comments
Open

create.heatmap input.colours = TRUE cannot handle missing values #181

jarbet opened this issue May 22, 2024 · 0 comments

Comments

@jarbet
Copy link
Contributor

jarbet commented May 22, 2024

There is a bug when input.colours = TRUE and there are missing values (NA) in the input x, then the colours will not display correctly in the heatmap.

It seems one of the desired input colours is completely replaced with darkgray (the default missing value colour):

Solution

One can simply replace the NAs with a desired color beforehand (e.g. darkgray). Alternatively, we could make this change directly within create.heatmap where if any missing values are detected, they are replaced with fill.colour.

Example

suppressPackageStartupMessages(library(BoutrosLab.plotting.general));
n <- 10;
heat.data <- data.frame(rep('blue', n), rep('yellow', n), rep('red', n));
heat.data[1,1] <- NA;

# Notice yellow doesnt show up
create.heatmap(
    x = heat.data,
    input.colours = TRUE,
    clustering.method = 'none',
    main = 'Yellow does not show up'
    );

# once you replace NA's with a color, then the yellows will show up
ind.miss <- which(is.na(heat.data), arr.ind = TRUE);
heat.data[ind.miss] <- 'darkgray';
create.heatmap(
    x = heat.data,
    input.colours = TRUE,
    clustering.method = 'none',
    main = 'Now yellow correctly shows'
    )

Created on 2024-05-22 with reprex v2.0.2

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

1 participant