I've generated a heatmap from my 1st input file containing a ( 315 row * 48 column ) grid of 0s and 1s, plus column and row names - please see after downloading file1)
I need to use order of row names from this x, y clustered heatmap to constrain how I make my next plots, which need to be:
B. another heatmap a different input file with a ( 315 row * 100 column) grid of 0s and 1s, with same row and column names as for the first heatmap.
Please note that I am using heatmap from base R, rather than pheatmap or Pheatmap (should I switch over?). I hope to convert these plots, using as.grob(plot), to "grobs", and then combine then into a plot_grid-based series of sub-panels.
The 3 specific questions I seek help for are:
1. How do I FIX the improper extraction of my ordered row list from the heatmap object ?
2. How should I modify my other input files (add rownames, delete column header etc) BEFORE they can be used in the final step?
3. What should be my R syntax for using heatmap clustered row order + new input files = ordered bar plots & ordered (new) heatmap
This is what I've tried thus far, without success:
HMM_Binaries = read.table("HMM_binary",header=TRUE,sep="\t") HBM=data.matrix(HMM_Binaries, rownames.force = NA) HBM_hm = heatmap(HBM, labRow = FALSE, col=c("firebrick1", "forestgreen")) HBM_hm_row.order = HBM_hm$rowInd HBM_hm_row.list = as.list(HBM_hm$rowInd) > head(HBM_hm_row.order)  192 292 121 163 258 260 > head(HBM_hm_row.list) []  192 []  292 []  121 []  163 []  258 []  260 > nrow(HBM_hm_row.order) NULL > nrow(HBM_hm_row.list) NULL > typeof(HBM_hm_row.order)  "integer" > typeof(HBM_hm_row.list)  "list" > Lengths_Reordered = Lengths[names(HBM_hm_row.order)] > Lengths_Relisted = Lengths[names(HBM_hm_row.list)] > nrow(Lengths_Reordered)  315 > nrow(Lengths_Relisted)  315 > typeof(Lengths_Reordered)  "list" > typeof(Lengths_Relisted)  "list" > head(Lengths_Reordered) data frame with 0 columns and 6 rows > head(Lengths_Relisted) data frame with 0 columns and 6 rows