Question: Handle missing values in the z-score matrix while plotting heatmap in the ComplexHeatmap
0
gravatar for mohammedtoufiq91
4 weeks ago by
mohammedtoufiq910 wrote:

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

ADD COMMENTlink modified 4 weeks ago by Zuguang Gu170 • written 4 weeks ago by mohammedtoufiq910
Answer: Handle missing values in the z-score matrix while plotting heatmap in the Comple
1
gravatar for Zuguang Gu
4 weeks ago by
Zuguang Gu170
Germany / Heidelberg / DKFZ
Zuguang Gu170 wrote:

try:

m2 = t(apply(m, 1, function(x) (x - mean(x, na.rm = TRUE))/sd(x, na.rm = TRUE)))
Heatmap(m2)
ADD COMMENTlink modified 4 weeks ago • written 4 weeks ago by Zuguang Gu170

Thank you Zuguang,

I have a question,

Blockquote

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?

Blockquote

for(i in 1: nrow(my_matrix))

{

mymatrixZ[i,]<- (mymatrix[i,]-mean(mymatrix[i,], na.rm = TRUE))/sd(my_matrix[i,], na.rm = TRUE)

}

ADD REPLYlink modified 4 weeks ago • written 4 weeks ago by mohammedtoufiq910
1

m is your matrix (your mat_marix). What you did in the for loop basically is the same as the apply() function.

ADD REPLYlink written 4 weeks ago by Zuguang Gu170

Thank you Zuguang. It was helpful.

ADD REPLYlink written 4 weeks ago by mohammedtoufiq910
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 16.09
Traffic: 203 users visited in the last hour