I'm trying to plot a picture by pheatmap package, but when clusting the rows, the tree's direction is downside rather than upwards. pls help me, thank you.
The reason is likely the clustering_method = 'median' as explained in the documentation:
Note however, that methods "median" and "centroid" are not leading to a monotone distance measure, or equivalently the resulting dendrograms can have so called inversions or reversals which are hard to interpret, but note the trichotomies in Legendre and Legendre (2012).
So apparently it's not unexpected, as to what you should do, I don't know. Maybe don't use median as a method, or you can try and follow this suggestion.