Entering edit mode
Hi,
I have a data matrix with the missing values "NA" in between for some of the genes, I converted to a z-score data matrix in order to plot the heatmap . However, while plotting the heatmap in the ComplexHeatmap package in R, i get error message as below. Is there a way to handle missing values in the ComplexHeatmap package to avoid this error and to be able to plot on the z-score matrix. I understand that, na_col = "grey" could be used to color "NA". How can I pass the z-score matrix in the Heatmap.
Blockquote
NA/NaN/Inf
Blockquote
Thank you, Toufiq
Thank you Zuguang,
I have a question,
ms = t(apply(m, 1, function(x) (x - mean(x, na.rm = TRUE))/sd(x, na.rm = TRUE)))
Here, I understand, "x" is my data matrix with missing values (NA) and what is "m"?
Can I also use the below code?
for(i in 1: nrow(my_matrix))
{
mymatrixZ[i,]<- (mymatrix[i,]-mean(mymatrix[i,], na.rm = TRUE))/sd(my_matrix[i,], na.rm = TRUE)
}
m
is your matrix (yourmat_marix
). What you did in thefor
loop basically is the same as theapply()
function.Thank you Zuguang. It was helpful.
hi,Zuguang, I have same question about Z-score and plot Heatmap using ComplexHeatmap. my data is like this :
I know gene1-8 is difference.what I want to do is that i want to view the difference by Complexheatmap,maybe gene9 number is so big that the color range is very big and in order that some different genes like that gene1 color is not obvious.After I scaled my data by your above method,scaledwt,scaledsample,these number is same,why? help me.
thank you very much!!
It is because, for each gene, you only have two values.
thank you Zugaung!