Error in cut.default(a, breaks = 100) : 'x' must be numeric in pheatmap
0
0
Entering edit mode
20 months ago
bart ▴ 50

Hi,

I'm trying to create a heatmap of a dataset. All previous steps until the heatmap step do not return any errors. However, the following heatmap step:

pheatmap(t(scale(t(de_mat))),show_rownames = F,show_colnames = T,annotation_col =metadata_tpvspp,annotation_colors = ann_colors, fontsize = 5)

Returns this error and it does not result in a heatmap shown:

Error in cut.default(a, breaks = 100) : 'x' must be numeric

However, I'm sure my heatmap object is numeric because

apply(de_mat,2,class)

Only returns numeric class objects in all colums. Does anyone know what my mistake is? If the data object is not numeric it could never have been a deseq object so I'm not sure what the problem is here.

pheatmap • 4.1k views
ADD COMMENT
1
Entering edit mode

Turns out that I got this error because I did not include any rownames for my metadata object or colnames for my deseq object because I did not think this was necessary. Still, the error itself is not extremely helpful in pointing out my error. Also, the metadata was a tibble instead of a dataframe which did not give any errors upstream (eg in the deseq formulas).

ADD REPLY
0
Entering edit mode

Could you share an example of de_mat with dput(head(de_mat)) ? Thanks

ADD REPLY
0
Entering edit mode
structure(c(6.36148711174777, 6.36148711174777, 7.06162791080366, 
7.78735456875173, 7.75278685493008, 6.57447171697399, 6.99876860136753, 
6.36148711174777, 6.76649299512567, 8.13689414062528, 7.49891344159027, 
6.50508968435012, 6.6556289746562, 6.72142588198909, 7.13187612008561, 
9.82949314395495, 8.20008500245052, 6.98174935421472, 7.31693798400699, 
6.81825713890986, 7.50104087792544, 9.97965515464899, 9.04363816437676, 
6.49385025655139, 7.69770728106461, 6.96384181493304, 7.46134498621078, 
7.54177385794784, 7.53208269069827, 6.47412718383161, 7.4304106536733, 
6.36148711174777, 6.67418833669543, 8.91448985862592, 8.00310004182103, 
6.74981379801753, 6.36148711174777, 6.36148711174777, 6.36148711174777, 
8.01459936377809, 7.34956458358165, 6.73371258763747, 7.73557839522785, 
7.13573468108275, 7.47234538128227, 7.23998783375455, 10.2836353214021, 
6.57455482496852, 7.19744167691923, 6.36148711174777, 6.93166359419921, 
9.08298451118999, 7.44389031482581, 6.60590415506407, 7.48080915303953, 
6.36148711174777, 6.53341907331434, 8.31561558005298, 7.06384369133975, 
6.36148711174777, 6.6038097608467, 6.36148711174777, 6.90082798951893, 
8.65628808104956, 8.36620943807325, 7.19045352217651, 6.80040381716771, 
6.50829422592181, 6.50829422592181, 7.55588935140107, 7.24117403677513, 
6.88810752323235, 7.82133396527139, 8.02907737710056, 8.18636424795412, 
8.31180512152275, 8.11028026281927, 6.71812057799011, 8.49990901835783, 
7.40292717572071, 8.59067924278701, 7.41212462587246, 9.24235525518469, 
8.71461995291451, 7.20225046890087, 6.48856077224472, 6.54113840876368, 
7.63465429281318, 7.38791629676906, 6.92634664618836, 6.95937840067713, 
6.36148711174777, 6.7236630016982, 8.31772051807808, 7.25495919423877, 
6.36148711174777, 6.8519608966884, 6.67897244955942, 6.90920288586483, 
7.97191239710296, 7.60323444525264, 6.94411578641943, 6.83468018507694, 
6.71987080015563, 6.89736008057038, 9.33281414192275, 7.95493933416686, 
6.67205511429429, 7.2123942774854, 7.09290976337429, 6.71305503429575, 
8.25864564502231, 8.1493408436401, 6.36148711174777, 6.93378174188791, 
6.36148711174777, 6.51537114720941, 7.06015918123357, 6.86947638946812, 
7.02666261307734, 7.19865250971641, 6.59820478017698, 7.02589021251609, 
11.063102662425, 8.54450388363309, 6.55483842834427, 8.47874345819652, 
7.65055836860626, 9.02739543742799, 8.30077093341714, 10.3262460837029, 8.2688830004202, 6.90984053689646, 7.07262234496151, 7.4339312892578, 
10.4023011661722, 8.34442674470494, 6.80524153545838, 6.86482051768285, 
6.36148711174777, 6.36148711174777, 9.52600723773529, 7.3154654266184, 
6.81561304449848, 7.28500180904315, 7.58020314372871, 8.05911905167069, 
10.5676064527525, 10.2749630336593, 7.24410538041609, 7.10019053504678, 
9.08729598203113, 10.7238852275143, 11.4101912268229, 10.2121442714313, 
7.37118689354688, 6.62279162119211, 6.36148711174777, 6.49227323815633, 
9.32208020248028, 7.16798342600499, 6.65353501913236, 6.36148711174777, 
6.36148711174777, 6.90858898488712, 11.7057414922388, 8.70352013551567, 
6.36148711174777, 6.99597403288676, 7.16029709198918, 8.23035350346118, 
13.2328932842979, 9.27182713406238, 6.68064225390082, 7.10786517745406, 
6.36148711174777, 6.69824741002615, 8.52707178066871, 7.43056519316846, 
6.36148711174777, 6.36148711174777, 6.36148711174777, 7.61125977768721, 
8.05381714432601, 7.7793155527054, 6.6189889516521, 6.52980812302691, 
6.36148711174777, 6.36148711174777, 8.9903878499504, 8.58650286901218, 
6.52980812302691, 7.24129941670351, 6.87464555628488, 6.8953679200387, 
10.9562320026411, 8.48200683360361, 6.709884138818, 7.49783153589398, 
6.62859215904865, 6.36148711174777, 7.46894531543635, 7.19568459847055, 
6.91490570722422, 6.50648546143716, 6.36148711174777, 6.91980904187539, 
7.48430690881196, 10.2940525522888, 8.36321160804079, 6.36148711174777, 7.35083789828986, 6.91678596263748, 6.36148711174777, 7.21458899928621, 
8.00271477509308, 8.29021300460957, 7.10291982932719, 7.44277235501191, 
7.48978098621712, 8.00070928382151, 8.26186991957374, 8.70494535243204, 
7.16920915247682, 6.74104210978856, 6.531620618493, 6.531620618493, 
8.10300270062451, 7.58680045544159, 6.531620618493, 6.951583004945, 
6.36148711174777, 6.80887883304922, 8.16138953834714, 7.8925386069855, 
7.13036916702734, 6.96666728393067, 6.36148711174777, 6.36148711174777, 
8.25580297675018, 7.59838144366996, 6.57682285536143, 6.57483399795689, 
7.10810993404657, 7.36522816548424, 8.23108542253064, 9.50962250466209, 
7.32220654176946, 6.96039642271976, 6.93006420794657, 6.6911660438904, 
8.34999582052941, 8.85092889716654, 7.04291084952447, 6.58573339601777, 
6.63599387881139, 7.21821965034249, 12.3589283110371, 9.72825192442679, 
6.95126896833902, 6.36148711174777, 6.36148711174777, 6.53731271427796, 
8.21420551965151, 7.19365451725378, 6.88639043459033, 6.87163153188275, 
6.36148711174777, 6.56246376554451, 9.46241868344834, 7.92955009830352, 
7.02278576376677, 7.68308249250261, 6.93589465610864, 6.61972519428901, 
8.96982404475127, 7.54120486543431, 7.28961055808758, 7.04685654727845, 
6.36148711174777, 6.66052376794355, 8.12787601423238, 7.52775878012717, 
7.27743409217088, 7.05094354908706, 6.36148711174777, 6.90429534903277, 
12.1181569521216, 8.82754563982265, 7.07645880746338, 7.17695473470836, 
6.67321762798058, 6.80149142975307, 7.9221759938037, 7.4808021179802, 
7.08633495334663, 6.87991706530023, 6.36148711174777, 6.78553648469163, 
9.26004169865707, 8.0554734086954, 6.85806598118671, 6.36148711174777, 
6.36148711174777, 6.36148711174777, 7.56873541600437, 7.04967948313276, 
6.89655519203598, 6.98555773369841, 6.36148711174777, 6.72365846324073, 
8.59866870644183, 7.38002809484717, 6.52379509004797, 7.74353442575781, 
8.02066170327252, 10.1145776445763, 11.8940643866951, 9.47300767243205, 
7.07910432410646, 6.85057500293999, 6.56195261821062, 6.76145858113682, 
7.71561718141589, 7.62128794976226, 6.80831426564555, 6.85810766115507, 
6.36148711174777, 6.82631690712304, 7.27960165272504, 7.45135425390056, 
6.88791199376305, 6.93294027696131, 6.36148711174777, 6.79466559809534, 
7.89986952648963, 7.29286942481921, 6.5786856917634, 6.74822916925934, 
6.58521765096922, 6.67757443315158, 7.99332451518305, 7.43378381957545, 
7.02742368225558, 7.15140985176412, 6.71391461841623, 6.64036441428241, 
10.4003986076269, 7.58026981893592, 6.73517753561329, 7.31620060889518, 
7.61772742829698, 10.6759393108107, 12.9953568021281, 11.3343209875477, 
6.97735932425655, 7.8654224994017, 6.36148711174777, 6.82446395369831, 
6.99540973413084, 7.06475078276276, 7.01348564860592, 7.15614987661769, 
6.36148711174777, 6.73298526753942, 7.20953521359709, 7.56206988704352, 
7.15614987661769, 7.32739225060269, 6.36148711174777, 7.42513755137124, 
7.77161112376927, 8.35099528333973, 7.27396961912162, 6.99867211179865, 
6.36148711174777, 8.94564480073329, 11.5243659235936, 8.42843530406945, 
7.25556814736846), .Dim = c(6L, 102L), .Dimnames = list(c("ENSG00000005187.12", 
"ENSG00000005381.8", "ENSG00000012223.13", "ENSG00000090382.7", 
"ENSG00000096060.15", "ENSG00000100003.18"), c("665", "667", 
"669", "671", "673", "675", "677", "679", "681", "683", "685", 
"687", "689", "691", "693", "695", "697", "699", "701", "703", 
"705", "707", "709", "711", "713", "715", "717", "719", "721", 
"723", "725", "727", "729", "731", "733", "735", "737", "739", 
"741", "743", "745", "747", "749", "751", "753", "755", "757", 
"759", "761", "763", "765", "767", "769", "771", "773", "775", 
"777", "779", "781", "783", "785", "787", "789", "791", "793", 
"795", "797", "799", "801", "803", "805", "807", "809", "811", 
"813", "815", "817", "819", "821", "823", "825", "827", "829", 
"831", "833", "835", "837", "839", "841", "843", "845", "847", 
"849", "851", "853", "855", "857", "859", "861", "863", "865", 
"867")))
ADD REPLY
0
Entering edit mode

de_mat -->

                         665       667       669       671       673       675       677
ENSG00000005187.12  6.361487  6.998769  6.655629  7.316938  7.697707  7.430411  6.361487
ENSG00000005381.8   6.361487  6.361487  6.721426  6.818257  6.963842  6.361487  6.361487
ENSG00000012223.13  7.061628  6.766493  7.131876  7.501041  7.461345  6.674188  6.361487
ENSG00000090382.7   7.787355  8.136894  9.829493  9.979655  7.541774  8.914490  8.014599
ENSG00000096060.15  7.752787  7.498913  8.200085  9.043638  7.532083  8.003100  7.349565
ENSG00000100003.18  6.574472  6.505090  6.981749  6.493850  6.474127  6.749814  6.733713
ENSG00000100985.7   6.811875  6.361487  7.341734  6.888195  6.474127  6.771877  6.502510
ENSG00000101265.16  6.662421  6.648338  9.089444  7.809623  7.476956  8.491920  7.649241
ENSG00000101425.14  6.361487  6.966549  6.946768  7.079297  6.750602  6.674188  6.605551
ADD REPLY
0
Entering edit mode

Could you try dput(de_mat[1:9,1:7]) instead ? Because I can't load the data with that structure

ADD REPLY
0
Entering edit mode

Sorry for the late response

structure(c(5.6510439130968, 5.70611461940955, 6.8160215826215, 
8.25259069911565, 7.68473621793015, 6.02602701091044, 6.46510495671683, 
6.5457222988528, 5.76345159534619, 6.44964306333603, 5.77801647982583, 
6.56037590967188, 9.19501882100308, 7.53686720156106, 5.91100640188847, 
6.00775332865882, 6.77816010514494, 6.59869554180166, 6.07132850633634, 
6.04617812152183, 6.27132502999661, 8.67392736774454, 7.50434128009209, 
6.34390438263879, 6.58592670999573, 8.24145122651075, 6.25299985402213, 
6.91243993617563, 6.13023299176508, 6.99010640399601, 9.56566140084141, 
8.6660701730702, 5.90931491629161, 6.23763886558679, 7.23429189985872, 
6.4679519368557, 7.35139189793126, 6.3802543742663, 7.10241705660756, 
7.30237875851371, 7.13390491891206, 5.89227435756887, 5.85284227450336, 
7.14909830937756, 6.14262621308928, 7.03556295418303, 5.55858884096497, 
6.01908184333271, 8.47179367629539, 7.56180992252475, 6.2602639924102, 
6.13437418187523, 8.13646532906398, 5.98775547205717, 5.63654508747339, 
5.78635093179432, 6.07326798501492, 9.11178907794684, 7.39085369717263, 
6.20688824740853, 6.20953284724862, 8.07465286826137, 6.156808116178
), .Dim = c(9L, 7L), .Dimnames = list(c("ENSG00000005187.12", 
"ENSG00000005381.8", "ENSG00000012223.13", "ENSG00000090382.7", 
"ENSG00000096060.15", "ENSG00000100003.18", "ENSG00000100985.7", 
"ENSG00000101265.16", "ENSG00000101425.14"), c("665", "667", 
"669", "671", "673", "675", "677")))
ADD REPLY
0
Entering edit mode

Have you tried to run without annotation ? pheatmap(t(scale(t(de_mat))),show_rownames = F,show_colnames = T, fontsize = 5) It seems indeed your de_mat is okay so maybe the issue comes from your annotation

ADD REPLY
0
Entering edit mode

This doesn't give me a plot but also does not give me an error. So no solution yet unfortunately

ADD REPLY
0
Entering edit mode

The code shared by Basti generates the following plot. R image

ADD REPLY

Login before adding your answer.

Traffic: 2522 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6