Entering edit mode
4.0 years ago
luzglongoria ▴ 40
I would like to do a heat map by using pheatmap. The problem is that when I tried to run it (with a very basic command) I get this error message:
head(dataset) # A tibble: 6 x 11 ID s21 s22 s23 s24 s25 s31 s32 s33 s34 s35 <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> 1 TRINITY_DN31277_c0_… 7.80 2.65e+0 2.12e0 1.93e+0 6.35e+0 0.0258 0.00541 0.00004 0.0132 0.0182 2 TRINITY_DN38059_c1_… 2671. 1.13e+4 1.62e4 1.64e+4 3.13e+4 19.0 4.38 1.61 3.07 7.69 3 TRINITY_DN29156_c0_… 0.960 2.56e+0 2.81e0 2.56e+0 6.93e+0 0.156 0.180 0.0934 0.156 0.0568 4 TRINITY_DN36493_c2_… 0.468 1.10e+0 1.75e0 1.70e+0 4.36e+0 0.0587 0.0907 0.0523 0.0483 0.0928 5 TRINITY_DN22456_c0_… 0.428 1.17e+0 1.71e0 1.42e+0 4.26e+0 0.0862 0.149 0.0845 0.0904 0.0545 6 TRINITY_DN24468_c0_… 0.0965 1.93e-1 0. 1.23e-1 8.12e-2 0 0 0 0 0 pheatmap(as.matrix(dataset)) Error in hclust(d, method = method) : NA/NaN/Inf in foreign function call (arg 11) In addition: Warning messages: 1: In dist(mat, method = distance) : NAs introduced by coercion 2: In dist(mat, method = distance) : NAs introduced by coercion
I have been reading and apparently is a problem with removing the zero variance columns in my matrix. but I don't know how to do it.
Any help will be appreciate!
There are some strange entries like
2671.Can you confirm this is indeed in your data or is this a copy/paste error when you made the post?
It appears like this when I do head() but the dataset appears like this in R:
I have also imported the data by using a .txt file by:
and then if I do:
But it didn't solve the problem:
Well, you obviously cannot cluster the first column,
ID; so, you will have to set that as the rownames and then remove that column from the object before you convert it to a data matrix.
Thank you Kevin.
I have tried to do what you have said:
I have checked:
And then I try to do the heatmap by:
And now R doesn't do anything. No error message, no warnings messages.
What I am doing wrongly?
Do you have a plot window or some output stream open? Try running
dev.off()multiple times until that shows an error, and then try the
Also, what is the output of
str(data)? It will help to see how your columns are encoded.
I am not sure that you need these lines:
I have also done the dev.off() and now I get a plot!
The problem is that it doesn't seem to be very informative since I have some very high values and other quite low. but I know that there is significant differences between the two species (s21,22,23,24,25) and (s31,32,33,34,35)
image of the heatmap: https://ibb.co/9qy7xW4
I see, you could try to scale the data (transform to Z-scores) and then set custom breaks:
That is just copied from another example that I did. Please edit as per your needs.
Edit: using my
pheatmap(..., scale = 'none',... )is actually the same as using
pheatmap(..., scale = 'row',... )on its own