This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Heatmap error: 'x' must be a numeric matrix

hi;

It's repeated but I'm trying to make heatmap from matrix data but i'm receiving this error every time, Error: "x" must be a numeric matrix.

1st row and colum with names as shown below, Please guide. Thanks

kisshion.influent
Toba.influent
kisshion.effluent
Toba.effluent
NTR.1.Dry
NTR.2.Dry
NTR.3.Dry
NTR.4.Dry
NTR.1.Rain.Start
NTR.1.Rain.High.Flow
NTR.2.Rain
NTR.3.Rain
NTR.4.Rain
p__Bacteroidetes;c__Bacteroidia
0.15807803
0.089749759
0
0.002657773
0.00168062
0.000954514
0.011313115
0.001059835
0.000557278
0.333735829
0.164297121
0.234835771
0.122873472
p__Bacteroidetes;c__Cytophagia
0
0.00240616
0.01053446
0.010370525
0.073324826
0.006608172
0.046760876
0.009054021
0.061509526
0.000201248
0
0
0
p__Bacteroidetes;c__Flavobacteriia
0.073840408
0.206147738
0.38626354
heatmap

Check str(your_matrix)

chr [1:17, 1:13] "0.15807803" "0" "0.073840408" "0.001968405" "0.000403775" ...

attr(*, "dimnames")=List of 2 ..$ : chr [1:17] "p__Bacteroidetes;c__Bacteroidia" "p__Bacteroidetes;c__Cytophagia" "p__Bacteroidetes;c__Flavobacteriia" "p__Bacteroidetes;c__Sphingobacteriia" ... ..$ : chr [1:13] "kisshion.influent" "Toba.influent" "kisshion.effluent" "Toba.effluent" ... Thats answer

Then you have your answer, all the content is of class "character" you must convert your data to matrix/numeric

as.matrix(df)

or

  apply(df, 2 ,as.numeric)

etc... depending on your data

chr [1:17, 1:13] "0.15807803" "0" "0.073840408" "0.001968405" "0.000403775" ...

  • attr(*, "dimnames")=List of 2 ..$ : chr [1:17] "p__Bacteroidetes;c__Bacteroidia" "p__Bacteroidetes;c__Cytophagia" "p__Bacteroidetes;c__Flavobacteriia" "p__Bacteroidetes;c__Sphingobacteriia" ... ..$ : chr [1:13] "kisshion.influent" "Toba.influent" "kisshion.effluent" "Toba.effluent" ...

Thats answer

0 answers

No answers yet.

Log in to answer this question.