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

More specific error for unexpected data types when adding annotations #86

Open
Nelson-Gon opened this issue Mar 16, 2022 · 0 comments
Open

Comments

@Nelson-Gon
Copy link

Hello there,

Thank you for this awesome package. While trying to create a pretty heatmap with annotations, I faced the error

Error in cut.default(a, breaks = 100) : 'x' must be numeric

However, digging into the issue, I noticed that the error was in fact because I was using a tibble instead of a data.frame for the annotation_col argument. A reprex follows below

test = matrix(rnorm(200), 20, 10)
test[1:10, seq(1, 10, 2)] = test[1:10, seq(1, 10, 2)] + 3
test[11:20, seq(2, 10, 2)] = test[11:20, seq(2, 10, 2)] + 2
test[15:20, seq(2, 10, 2)] = test[15:20, seq(2, 10, 2)] + 4
colnames(test) = paste("Test", 1:10, sep = "")
rownames(test) = paste("Gene", 1:20, sep = "")
annotation_col = data.frame(
  CellType = factor(rep(c("CT1", "CT2"), 5)), 
  Time = 1:5
)
rownames(annotation_col) = paste("Test", 1:10, sep = "")
pheatmap::pheatmap(test, annotation_col = annotation_col)

The above works as expected. However the following fails with the above error

pheatmap::pheatmap(test, annotation_col = dplyr::as_tibble(annotation_col))

I think it may be more useful in such a case to specify that we expect a data.frame object. I am using pheatmap 1.0.12

Thank you,

NelsonGon

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