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

Handle cases where all annotation values are missing (i.e. NA). #75

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

T-Heide
Copy link

@T-Heide T-Heide commented Nov 12, 2020

Minor changes as per title.

Also includes a change to make sure that opened pdf device is also closed if there is a error.

This allows slicing the data even if annotations are missing in some cases:

> d = data.frame(matrix(1:9, nrow = 3))

> annot =
    data.frame(
      row.names = colnames(d),
      A = 1:3,
      B = c("A", NA, NA),
      C = c(1, NA, NA),
      D = factor(c("A", NA, NA))
    )

> pheatmap::pheatmap(d, annotation_col = annot)

# this would fail before:
> pheatmap::pheatmap(d[,-1], annotation_col = annot)
@T-Heide T-Heide changed the title Handle cases where all annotation values are missing (i.e. NA) in the annotation. Handle cases where all annotation values are missing (i.e. NA). Nov 12, 2020
@T-Heide
Copy link
Author

T-Heide commented Nov 12, 2020

Example:

d = data.frame(matrix(1:6, nrow = 3))
annot = data.frame(row.names = colnames(d), "Label A" = 1:2, "Label B" = c(NA, NA))
pheatmap::pheatmap(d, annotation_col = annot)

image

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

Successfully merging this pull request may close these issues.

1 participant