Just to clarify and provide some data...
I do not want to drop any of the rows; instead of plotting/interpreting 831 branches, I would like to interpret 3 branches, and so would like the row dendrogram to be constrained to 3 branches (at height 150) and the corresponding heatmap of all 831 rows to be clustered into the 3 upper branches of the original dendrogram.
#Here is a random n=10 subset of my data; which for 10 observed fish has the %of time each spent within
#a depth bin (Bin1-Bin8)
zz <- "ID Bin1 Bin2 Bin3 Bin4 Bin5 Bin6 Bin7 Bin8
1 0 0 0 0 0 0.0 0.0 100.0
2 0 0 0 0 0 0.0 0.0 100.0
3 0 0 0 0 0 0.0 0.0 100.0
4 0 0 0 0 0 70.8 29.2 0.0
5 0 0 0 100 0 0.0 0.0 0.0
6 0 0 0 0 0 0.0 93.3 6.7
7 0 0 0 0 0 27.5 72.5 0.0
8 0 0 0 0 0 53.5 46.5 0.0
9 0 0 0 0 0 0.0 100.0 0.0
10 0 0 0 0 0 0.0 72.1 27.9 "
TAD <- read.table(text=zz, header = TRUE)
IDnames <- TAD[,1]
x<-data.matrix(TAD[,2:ncol(TAD)])
rownames(x) <- IDnames
Without worrying about heatmap for the time being, the distance matrix and hclustering is done on the numeric matrix x
TAD.dist <- dist(x, method="manhattan", diag=FALSE, upper=FALSE)
TAD.cluster <- hclust(TAD.dist, method="average", members=NULL)
a plot of this resultant dendrogram reveals all ten branches,
plot(TAD.cluster)
but a cutoff height of 150 will restrain to only 3 branches
hcd = as.dendrogram(TAD.cluster)
rowDend<- cut(hcd, h = 150)$upper
plot(rowDend)
the dendrogram plotted with plot(rowDend) is what I would like to see on the row dendrogram for the following heatmap
heatmap.2 (x,
distfun = function(x) dist(x, method='manhattan', diag=FALSE, upper=FALSE),
hclustfun = function(x) hclust(x,method = 'average'),
dendrogram = "row",
#Rowv=rowDend, #this is where I thought I could restrain the row dendrogram
Colv="NA",
trace="none",
)
But I can not find any way to restrain the row dendrogram in heatmap for the desired number of interpretable branches. Plotting all 831 branches is extremely messy.