0

Test RData: https://www.dropbox.com/s/hy56owg4mfjuxol/Test_Data.RData?dl=0

CSV: https://www.dropbox.com/s/hs6qpoxyg54ehid/Test_Data.csv?dl=0

Annotations: https://www.dropbox.com/s/akv66euwh3ulia2/Test_Data_Annotation?dl=0

Plotting this dataset runs as expected:

pheatmap(t(pred.MDSC), fontsize=8)

enter image description here

However, if I then attempt to add annotation to it (using the anno DF in the file):

pheatmap(t(pred.MDSC),fontsize=8,labels_col = rownames(anno), show_colnames = TRUE, annotation_col = anno)

It returns the error:

Error in annotation_colors[[colnames(annotation)[i]]] : 
  subscript out of bounds

What am I doing wrong?

user3012926
  • 117
  • 1
  • 9
  • What is the class of `pred.MDSC`? Is it a list ? Your RData file cannot be loaded by my computer. Maybe you can try other way to provide your data such as `dput`. – Darren Tsai Feb 11 '20 at 11:49
  • @DarrenTsai I've updated the file. pred.MDSC is now a simple DF. – user3012926 Feb 11 '20 at 12:06
  • The loading of your .Rdata is throwing error. Please provide the data in .csv or .txt format. – UseR10085 Feb 11 '20 at 12:06
  • 2
    This is the same issue as [this one](https://stackoverflow.com/q/53871845/10068985) I posted. Run `rownames(pred.MDSC) <- 1:nrow(pred.MDSC)` before plotting. The reason has been explained in the answer. – Darren Tsai Feb 11 '20 at 12:26
  • @DarrenTsai Thanks. That worked. Feel free to post it as an answer. – user3012926 Feb 11 '20 at 12:58
  • @user3012926 see my answer now. I have provided the data used for plotting. As it was a large data I could not provide it in `dput()` format. – UseR10085 Feb 11 '20 at 13:22
  • yeah it is not very obvious in the vignette. you can also check a post which I answered. https://stackoverflow.com/questions/58853068/missing-annotations-and-colors-in-pheatmap – StupidWolf Feb 11 '20 at 13:35

1 Answers1

0

To solve the issue you can transpose your data first so that the duplicate row names become column names. Then read the file as

df <- read.csv("Test_Data.csv", row.names = 1)

pheatmap(df, fontsize=8)

which gives you enter image description here

You can get the data used for plotting from here https://www.dropbox.com/s/vco1rd5uelyoui9/Test_Data.csv?dl=0

UseR10085
  • 7,120
  • 3
  • 24
  • 54