Hello Kevin Blighe,
Thank so much for the reply, Yes i have referred to the ComplexHeatmap package tutorials.
I could extract the subcluster matrix following this code given in the link, http://r.789695.n4.nabble.com/Advice-on-exploration-of-sub-clusters-in-hierarchical-dendrogram-td4414277.html And now i have the heatmap with me too for this subcluster matrix.
referring to my last Question (If i plot this subcluster matrix using heatmap.2, will the pattern i have obtained in the master heatmap change in this subcluster one?)
The heatmap I have generated is not as same as it looks in the master heatmap.
for this subcluster heatmap i have used heatmap.2 function with default options.
so from the heatmap images, i can see that the observed pattern is not same in the subcluster heatmp. So is it right to have change in pattern? can you explain me this problem?
here is the code i have used to subcluster,
`#row and column clustering`
hr3 <- hclust(as.dist(1-cor(t(vv_E), method="pearson")),method="complete")
hc3 <- hclust(as.dist(1-cor(vv_E, method="spearman")), method="complete")
#heatmap after the column and row side colors
heatmap.2(vv_E, main="Hierarchical Cluster", Rowv=as.dendrogram(hr3), Colv=as.dendrogram(hc3), dendrogram="both", scale = "row", col=colorpanel(75,"green","black","red"), density.info="none", trace="none", RowSideColors= myClusterSideBar,ColSideColors = colSidecol,colsep=c(10), rowsep=c(292), sepcolor='yellow')
#subclustering using http://r.789695.n4.nabble.com/Advice-on-exploration-of-sub-clusters-in-hierarchical-dendrogram-td4414277.html
#Advice on exploration of sub-clusters in hierarchical dendrogram
# for column
#column clustering (sample)
x_col <- as.dendrogram(hc3)
plot(x_col, xlab="sample culster") #visualization of the dendrogram
clusters<-cutree(hc3, h=0.6) #obtain clusters at cutoff height=0.6
ord<-cmdscale(as.dist(1-cor(vv_E)), k=2) #Multidimensional scaling of the data down to 2 dimensions
#row clusteirng (gene )
x_row <- as.dendrogram(hr3)
library(dendextend)
plot(x_row, xlab="gene cluster") #visualization of the dendrogram
cluster_gene <- cutree(hr3, h=1.8)
d2=color_branches(x_row,k=2)
plot(d2)
ord_gene <- cmdscale(as.dist(1-cor(t(vv_E))),k=2)
library(cluster)
clusplot(ord,clusters, color=TRUE, shade=TRUE,labels=5, lines=0) #visualization of the clusters in 2D map
clusplot(ord_gene,cluster_gene, color = TRUE, labels=4,lines=0)
#extract cluster memberships for samples:
clids = as.data.frame(clusters)
names(clids) = c("id")
clids
clids$cdr = row.names(clids)
clids$cdr
row.names(clids)
row.names(clids) = c(1:dim(clids)[1])
row.names(clids)
clstructure = lapply(unique(clids$id), function(x){clids[clids$id == x,'cdr']})
clstructure
clstructure[[1]] #get memberships of cluster 1
clstructure[[2]] #get memberships of cluster 2
##extract cluster memberships for genes
clids_gene = as.data.frame(cluster_gene)
clids_gene
names(clids_gene) = c("id_gene")
head(clids_gene)
clids_gene$cdr = row.names(clids_gene)
clids_gene$cdr
row.names(clids_gene)
clstructure_genes = lapply(unique(clids_gene$id_gene), function(x){clids_gene[clids_gene$id_gene == x,'cdr']})
clstructure_genes
clstructure_genes[[1]] #get memberships of cluster 1
clstructure_genes[[2]] #get memberships of cluster 2
length(clstructure_genes[[2]])
#to get the expression set of only samples of WZ and GEF.
cluster_WZ_GR_samples_genes <-cluster_gene_WZ_GR[,clstructure[[2]]]
cluster_WZ_GR_samples_genes
dim(cluster_WZ_GR_samples_genes)
colnames(cluster_WZ_GR_samples_genes)
write.table(cluster_WZ_GR_samples_genes, file = "Upper_Right_side_genes_291_samples_12.txt",sep="\t")
heatmap.2(cluster_WZ_GR_samples_genes,main="Hierarchical Cluster of 291 genes and 12 samples", dendrogram="both", scale = "row", col=colorpanel(75,"green","black","red"), density.info="none", trace="none")
