I am a beginner in using R-studio to create a heat map from RNA-Seq data. I have imported csv format of cuffdiff file including FPKMs of control and treated samples, Log2, and p-value. After installing the packages "pheatmap"and "RColorBrewer", I ran the function pheatmap(file.csv):
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 would guess your Negin_AD_BD objet isn't what you think it is.It needs to be a numeric matrix, with no missing values.
Check the output of the following:
class(Negin_AD_BD) (is it matrix?)
class(Negin_AD_BD[1]) (is it numeric?)
anyis.na(Negin_AD_BD)) (is it FALSE?)
Also, you'll probably want minimally log2 your fpkms.
There are a number of tutorials out there to work with RNA-seq data, ie. an official bioconductor wofklow and a number of them on f1000research.com, and it might be beneficial to peruse those ...
Thank you for your comments. I think you could guess my problem. I tried once again, but I got another problem error message:
>Error in heatmap3(Negin_AE_BD) : 'x' must be a numeric matrix
Now, I have realised that the problem is in the gene ID column, which is not numeric. When I try to import the Negin_AD_BD file, the header of this column is "character"not numeric that I think it is correct. I should change the header to something else or I have to run a command in Rstudio after importing the file?
You need to create a numeric matrix from your data.frame. You would do this by calling as.matrix(XXX) where XXX is the subset of columns in your Negin_AE_BD data.frame that have the numeric values you are trying to plot. You would then set rownames()<- of your numeric matrix to be the geneID column that you removed to create XXX
Please don't take offense, but these are all extremely basic R data moves and I'd strongly encourage you to first get familiar with the basics of R before you try to hammer out a figure by stabbing at the dark until a heatmap materializes. It'll be much more fruitful in the long term, and in the short term you can be more confident of the results you are beginning to generate and explore.
There are many free beginner R tutorial courses out there, and I'd suggest you find one and run through it.
You need to create a numeric matrix from your data.frame. You would do this by calling
as.matrix(XXX)
whereXXX
is the subset of columns in yourNegin_AE_BD
data.frame that have the numeric values you are trying to plot. You would then setrownames()<-
of your numeric matrix to be the geneID column that you removed to createXXX
Please don't take offense, but these are all extremely basic R data moves and I'd strongly encourage you to first get familiar with the basics of R before you try to hammer out a figure by stabbing at the dark until a heatmap materializes. It'll be much more fruitful in the long term, and in the short term you can be more confident of the results you are beginning to generate and explore.
There are many free beginner R tutorial courses out there, and I'd suggest you find one and run through it.
Good luck!