0

I'm having some troubles by trying to set a specific column order for a heatmap with the Pheatmap package.

Actually I got mydata to be plot and I'm trying to set my_col as order for the columns:

my_col <- list("AL703GG", "AO641M", "CL374FF", "AO643DD", "CO438LL", "CE480L", "AE608H", "SM11", "AK83", "NGR", "AK58", "AK75", "BL225C", "CO431A", "H1", "AL703H", "1A42", "8A52", "T073", "4B41", "7B22")

pheatmap(mydata2,
         display_numbers = FALSE,
         annotation_row = my_rows,
         cluster_rows = F)

How can I do that? Thanks in advance!

  • Tru changing your certificate variable to `factor(..., Levels l=.)` where the levels of a list of unique names in the order you want – r2evans Aug 26 '23 at 15:55
  • I'm not sure I'm totally understanding, can you be more precise about the passages? Thank you – Iacopo Passeri Aug 26 '23 at 16:29
  • typed from my phone, sry ... I don't know your data, so I can only guess, but I'm assuming that one (or two) column in your data are categorical, the values that you want to change the order on the plot. If your data is `mydata2` and the categorical column is `mycat`, then `mycat_ord <- unique(mydata2$mycat)`, then reorder that vector, then `mydata2$mycat <- factor(mydata2$mycat, levels=mycat_ord)`. Then try to plot. If this doesn't work, then either [edit] your question to add [reproducible data](https://stackoverflow.com/q/5963269) or risk having it closed as not reproducible. – r2evans Aug 26 '23 at 17:46
  • Transcribed from @yixu501: `Did you also set cluster_cols = F?` – r2evans Aug 26 '23 at 19:10

0 Answers0