Hi. For the unsupervised methods, like the heatmap, you are not allowed to explicitly use any of the condition variables (sample information) because it would not be "unsupervised" anymore. Sorting the genes by SD does not use any information of the groupings but the presumption is that genes with large variation (or SD) are actually/mostly driven by some of these biological conditions. Compare this to the differential expression testing, where you explicitly define groups, and the top features are conditioned on the groupings, this is "supervised". Does it answer your question? Any other variable you want to use for prioritizing genes (for unsupervised methods) should not use any sample information (e.g. information on samples), otherwise it would be "cheating".
Ivo