drisso / SingleCellExperiment

Clone of the Bioconductor repository for the SingleCellExperiment package, see https://bioconductor.org/packages/devel/bioc/html/SingleCellExperiment.html for the official development version.
63 stars 17 forks source link

Hierarchical clustering dendrogram #52

Closed atflores closed 4 years ago

atflores commented 4 years ago

Hello, I'm attempting to create a tree based on hierarchical clustering using Euclidean distances. I have performed clustering using Seurat, converted to an SingleCellExperiment object, and used hclust to create a clustering tree. I then cut the tree to form distinct clusters. I ran the following:

library(SingleCellExperiment) control.sce <- as.SingleCellExperiment(control.cc) distance.cc <- dist(reducedDim(control.cc, "PCA")) distance <- dist(reducedDim(control.sce, "PCA")) tree <- hclust(distance, "ward.D2") plot(tree, main = "dist = euclidean, Ward linkage")

library(dendextend) tree$labels <- seq_along(tree$labels) dend <- as.dendrogram(tree, hang=0.1)

library(dynamicTreeCut) clust <- cutreeDynamic(tree, distM=as.matrix(distance), minClusterSize=18, deepSplit=1) table(clust) labels_colors(dend) <- clust[order.dendrogram(dend)] plot(dend)

But this results in a dendrogram that has a different number of clusters than my original analysis (e.g. 18 vs. 15 clusters in the dendrogram), and does not label the cluster identities in my plot making it unclear where each cluster lies on the tree. Any suggestions on how to create a hierarchical tree based on prior clustering? The plot would ideally show up as something similar to this: https://www.jneurosci.org/content/jneuro/28/1/264/F2.medium.gif

Many thanks for your help-

LTLA commented 4 years ago

What makes you think this is an issue for SingleCellExperiment? This package just implements a data structure. What you do with the data inside it is your own business.

Normally I would suggest that you post at the Bioconductor support site, but none of the analysis steps that you show involve Bioconductor packages. Instead, I assume you got those steps from some documentation, so you may find the authors of those docs to be a more willing audience.

Closing as out of scope.