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

not correctly plotting heatmap (only grey) when object called "as.double.factor" is in the global environment #96

Open
PStaus opened this issue Jun 9, 2023 · 0 comments

Comments

@PStaus
Copy link

PStaus commented Jun 9, 2023

Thank you for the nice plotting package for heatmaps.
When I defined a function called as.double.factor in my global environment the pheatmap function stopped plotting correctly.
Here a reproducible example.
It seems, that the package uses a function with the same name, but tries to load it from the global environment.
I never wrote a package so I am not very firm with working environments.

library("pheatmap")
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 = "")

# Draw heatmaps
pheatmap(test)

as.double.factor<- function(x) {as.numeric(levels(x))[x]}

pheatmap(test)

Best wishes,

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