GreenleafLab / ArchR

ArchR : Analysis of Regulatory Chromatin in R (www.ArchRProject.com)
MIT License
388 stars 140 forks source link

Weird clustering results #1533

Closed Larrycpan closed 2 years ago

Larrycpan commented 2 years ago

I performed analysis as follows without reported error:

proj_PC_1 <- addIterativeLSI(ArchRProj = proj_PC_1, useMatrix = "TileMatrix", name = "IterativeLSI", 
  iterations = 4, clusterParams = list(resolution = c(0.6), sampleCells = 12000, n.start = 10), 
  varFeatures = 15000, dimsToUse = 1:30, seed = 1234, threads = 40, force=T)
proj_PC_1 <- addHarmony(ArchRProj = proj_PC_1, reducedDims = "IterativeLSI", name = "Harmony", groupBy = "Sample", force=T)
proj_PC_1 <- addClusters(input = proj_PC_1, reducedDims = "IterativeLSI", method = "Seurat", name = "Clusters", resolution = 0.6, force = T)
proj_PC_1 <- addUMAP(ArchRProj = proj_PC_1, reducedDims = "IterativeLSI", name = "UMAP",
                     nNeighbors = 40, minDist = 0.4, metric = "euclidean", threads = 40, force=T)

p1 <- plotEmbedding(ArchRProj = proj_PC_1, colorBy = "cellColData", name = "Sample", embedding = "UMAP")
p2 <- plotEmbedding(ArchRProj = proj_PC_1, colorBy = "cellColData", name = "Clusters", embedding = "UMAP")
plotPDF(p1, p2, name = "UMAP-Sample-Clusters.pdf", ArchRProj = proj_PC_1, addDOC = F, width = 5, height = 5)

proj_PC_1 <- addUMAP(ArchRProj = proj_PC_1, reducedDims = "Harmony", name = "UMAPHarmony", nNeighbors = 40, minDist = 0.4, metric = "euclidean", threads = 40, force=T)

p3 <- plotEmbedding(ArchRProj = proj_PC_1, colorBy = "cellColData", name = "Sample", embedding = "UMAPHarmony")
p4 <- plotEmbedding(ArchRProj = proj_PC_1, colorBy = "cellColData", name = "Clusters", embedding = "UMAPHarmony")
plotPDF(p3, p4, name = "UMAP-Harmony-Sample-Clusters.pdf", ArchRProj = proj_PC_1, addDOC = FALSE, width = 5, height = 5)

But I got the results of mixed clusters, how can I fix it? image

rcorces commented 2 years ago

Hi @KeWXiong! Thanks for using ArchR! Please make sure that your post belongs in the Issues section. Only bugs and error reports belong in the Issues section. Usage questions and feature requests should be posted in the Discussions section, not in Issues.
Before we help you, you must respond to the following questions unless your original post already contained this information: 1. If you've encountered an error, have you already searched previous Issues to make sure that this hasn't already been solved? 2. Can you recapitulate your error using the tutorial code and dataset? If so, provide a reproducible example. 3. Did you post your log file? If not, add it now. 4. Remove any screenshots that contain text and instead copy and paste the text using markdown's codeblock syntax (three consecutive backticks). You can do this by editing your original post.

rcorces commented 2 years ago

Unless I'm mis-reading your code, the problem is here:

proj_PC_1 <- addClusters(input = proj_PC_1, reducedDims = "IterativeLSI", method = "Seurat", name = "Clusters", resolution = 0.6, force = T)

You are adding clusters based on the IterativeLSI reducedDims and then plotting the UMAP based on the Harmony reducedDims. You should add clusters based on Harmony instead.

Larrycpan commented 2 years ago

Unless I'm mis-reading your code, the problem is here:

proj_PC_1 <- addClusters(input = proj_PC_1, reducedDims = "IterativeLSI", method = "Seurat", name = "Clusters", resolution = 0.6, force = T)

You are adding clusters based on the IterativeLSI reducedDims and then plotting the UMAP based on the Harmony reducedDims. You should add clusters based on Harmony instead.

Thanks, it looks much better!

Larrycpan commented 2 years ago

@rcorces @jgranja24 Thanks for helping. Further, I use another dataset for the analysis, but the results are not consistent with previously published studies that points are relatively separate. Instead, my result seems a little strange. I have changed the parameters of dimensionality reduction and no big changes happen. How can I deal with it?

proj <- addIterativeLSI(ArchRProj = proj, useMatrix = "TileMatrix", name = "IterativeLSI", 
                           iterations = 2, clusterParams = list(resolution = seq(0.2), sampleCells = 10000, n.start = 10), 
                           varFeatures = 15000, dimsToUse = 1:30, threads = 40, seed = 1234, force = T)
proj <- addHarmony(ArchRProj = proj, reducedDims = "IterativeLSI", name = "Harmony", groupBy = "Sample", force = T)
proj <- addClusters(input = proj, reducedDims = "Harmony", method = "Seurat", name = "Clusters", force = T, resolution = 0.2)
proj <- addUMAP(ArchRProj = proj, reducedDims = "Harmony", name = "UMAPHarmony", nNeighbors = 30, minDist = 0.4, metric = "cosine", force = T)

p1 <- plotEmbedding(ArchRProj = proj, colorBy = "cellColData", name = "Sample", embedding = "UMAPHarmony")
p2 <- plotEmbedding(ArchRProj = proj, colorBy = "cellColData", name = "Clusters", embedding = "UMAPHarmony")

image

rcorces commented 2 years ago

Sorry - We cannot provide help with individual analyses and do not provide recommendations beyond what is in the manual and function parameter definitions.