I have an expression matrix that contains 20 rows (20 genes) and 435 columns (435 samples), all columns represent seven stages of a disease, I want to create a heatmap between genes and each stage. can I convert multiple columns to one column by averaging? In other words, convert the columns of each stage into one column by averaging.
why don't you annotate them using ComplexHeatmap? if you wanted to average over the stages then I wouldn't use heatmap for it, probably a boxplot with the different categories on one axis and the distribution of gene expression on the second axis.
You can combine the columns how you like as long that it makes sense. For example, averaging doesn't make much sense if the underlying distribution of the data is multimodal or heavily skewed.
Yes you can do this. But if you have analysed the data using something like limma or edgeR, then your differential expression pipeline might already have computed the treatment means. You might be able to skip your averaging step and use precomputed results.