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

Support missing values in continuous annotations #55

Open
ahmohamed opened this issue Sep 26, 2019 · 1 comment
Open

Support missing values in continuous annotations #55

ahmohamed opened this issue Sep 26, 2019 · 1 comment
Labels

Comments

@ahmohamed
Copy link
Contributor

First of all, thanks a lot for this awesome package.

Currently, plotting fails with an ambiguous message if row/col annotation is continuous and contains missing values:

library(iheatmapr)
library(datasets)
library(reshape2)

Indometh_matrix <- acast(Indometh, Subject ~ time, value.var = "conc")
Indometh_matrix <- Indometh_matrix[as.character(1:6),]
rownames(Indometh_matrix) <- paste("Patient",rownames(Indometh_matrix))
Indometh_patient_cor <- cor(t(Indometh_matrix))

patient_max_conc <- apply(Indometh_matrix,1,max)
patient_min_conc <- apply(Indometh_matrix,1,min)
patient_groups <- c("A","A","B","A","B","A") # Arbitrary groups

patient_max_conc[[1]] <- NA

iheatmap(Indometh_patient_cor, 
  row_annotation = data.frame("Max" = patient_max_conc))

# Error in if (diverging) { : missing value where TRUE/FALSE needed

The issue stems from these lines not using na.rm=TRUE

tmp_colors <- pick_continuous_colors(zmid = 0,
zmin = min(x[,i]),
zmax = max(x[,i]), p)
}

iheatmapr/R/annotations.R

Lines 161 to 164 in b9fd1bc

tmp_colors <- pick_continuous_colors(zmid = 0,
zmin = min(x[,i]),
zmax = max(x[,i]), p)
}

Alternatively, you can modify pick_conitnuous_colors to accommodate diverging=NA.

Cheers.

@AliciaSchep
Copy link
Contributor

Thanks for bringing up the issue and identifying the code responsible -- have now put in a PR with a fix for this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants