lazappi / clustree

Visualise Clusterings at Different Resolutions
https://lazappi.github.io/clustree/
GNU General Public License v3.0
214 stars 15 forks source link

Problem using clustree with a Seurat object #86

Closed Elena983 closed 1 year ago

Elena983 commented 1 year ago

Please see my code. I can't help running my data with clustree Even just clustree (analysis)

analysis <- CreateSeuratObject(counts =input, project = "resolve", min.cells = 20, min.features = 8, meta.data = countTable$seurat_clusters)

analysis <- NormalizeData(analysis, normalization.method = "LogNormalize", scale.factor = 1)

analysis <- FindVariableFeatures(analysis, selection.method = "vst", nfeatures = 100)

all.genes <- rownames(analysis) analysis <- ScaleData(analysis, features = all.genes)

analysis <- RunPCA(analysis, features = VariableFeatures(object = analysis), approx=FALSE)

VizDimLoadings (analysis, dims = 1:9, reduction = 'pca') & theme(axis.text=element_text(size=5), axis.title=element_text(size=8, face="bold"))

analysis <- FindNeighbors(analysis, dims = dimensions, reduction = "pca")

analysis <- FindClusters(analysis, resolution = 2, random.seed = 2, algorithm = 1, graph.name = "RNA_snn")

This is a standard vignette from Seurat

lazappi commented 1 year ago

Hi @Elena983. Thanks for giving {clustree} a go! Please provide some details of the error message you are getting, without that I'm not sure what to help. Please also check the past issues in case you question has been answered before.

Elena983 commented 1 year ago

Many thanks for your reply after creating the seurat object I run Clustree

clustree(analysis) Error: Less than two column names matched the prefix: RNA_snn_res

lazappi commented 1 year ago

As the error says the prefix value you have provided to the clustree() function matches less than two columns in your Seurat object. From your code above this is probably because you have only performed clustering with one resolution. To draw a clustering tree you need clusters from multiple different resolutions.

Elena983 commented 1 year ago

Many thanks for your answer How is it better to create a proper seurat object with multiple resolutions?

lazappi commented 1 year ago

You need to supply a vector to the {Seurat} clustering function, something like resolution = seq(0, 1, 0.1). You can see an example in ?sc_example.

Elena983 commented 1 year ago

thanks. it works well!