raivokolde / pheatmap

Pretty heatmaps
225 stars 83 forks source link

BUG: annotation_col and annotation_row have problems with DataFrame (S4Vectors) #61

Open kmpf opened 4 years ago

kmpf commented 4 years ago

I have been following the manual for DESeq2. With slight modifications so her comes the "fixed" code:

sampleDists <- stats::dist(t(SummarizedExperiment::assay(vst.dds)))
sampleDistMatrix <- as.matrix(sampleDists)
rownames(sampleDistMatrix) <- labels(sampleDists)
colnames(sampleDistMatrix) <- labels(sampleDists)
# Note: pheatmap does not work properly with DataFrame S4Vectors
anno.hm = as.data.frame(SummarizedExperiment::colData(dds)[,c("condition","type")])
pheatmap(sampleDistMatrix,
         clustering_distance_rows=sampleDists,
         clustering_distance_cols=sampleDists,
         annotation_col=anno.hm)

The code breaks if you remove the as.data.frame, that transforms the Formal class 'DataFrame' [package "S4Vectors"] into a normal data.frame.

If you want to call this a bug is up to you, but it was quit tedious to track down the problem. Cause the error message wasn't very helpful.