Closed Stfort52 closed 4 months ago
I found the same issue when FeaturePlot calls LabelClusters.
I had 'ident' in my meta.data so have removed it. After that, the problem solved!
Thanks for using Seurat!
It appears that this issue has gone stale. In an effort to keep our Issues board from getting more unruly than it already is, we’re going to begin closing out issues that haven’t had any activity since the release of v4.4.0.
If this issue is still relevant we strongly encourage you to reopen or repost it, especially if you didn’t initially receive a response from us.
Expected Behavior
LabelClusters
should show correct number of clusters being labeled.When testing with pbmc example, it should show:
Actual Outcome
LabelClusters
is reporting wrong number of clusters being labeled.When testing with pbmc example, it however shows:
Therefore puzzling error messages like these can happen:
Possibly related code
length(x = labels.loc)
seems to be causing problem. Maybe you meantlength(x = unique(x = labels.loc[, id]))
?Environment Info
Session Info
Reproduce-able example
```r $ radian R version 4.1.3 (2022-03-10) -- "One Push-Up" Platform: x86_64-conda-linux-gnu (64-bit) r$> library(magrittr) r$> library(Seurat) Attaching SeuratObject Attaching sp r$> pbmc.data <- Read10X(data.dir = 'filtered_gene_bc_matrices/hg19/') r$> pbmc <- CreateSeuratObject(counts = pbmc.data, project = "pbmc3k", min.cells = 3, min.features = 200) Warning: Feature names cannot have underscores ('_'), replacing with dashes ('-') r$> pbmc[["percent.mt"]] <- PercentageFeatureSet(pbmc, pattern = "^MT-") r$> pbmc <- subset(pbmc, subset = nFeature_RNA > 200 & nFeature_RNA < 2500 & percent.mt < 5) r$> pbmc <- NormalizeData(pbmc, normalization.method = "LogNormalize", scale.factor = 10000) Performing log-normalization 0% 10 20 30 40 50 60 70 80 90 100% [----|----|----|----|----|----|----|----|----|----| **************************************************| r$> pbmc <- FindVariableFeatures(pbmc, selection.method = "vst", nfeatures = 2000) Calculating gene variances 0% 10 20 30 40 50 60 70 80 90 100% [----|----|----|----|----|----|----|----|----|----| **************************************************| Calculating feature variances of standardized and clipped values 0% 10 20 30 40 50 60 70 80 90 100% [----|----|----|----|----|----|----|----|----|----| **************************************************| r$> all.genes <- rownames(pbmc) pbmc <- ScaleData(pbmc, features = all.genes) Centering and scaling data matrix |======================================================================================================================================================================================================================| 100% r$> pbmc <- RunPCA(pbmc, features = VariableFeatures(object = pbmc)) PC_ 1 Positive: CST3, TYROBP, LST1, AIF1, FTL, FTH1, LYZ, FCN1, S100A9, TYMP FCER1G, CFD, LGALS1, S100A8, CTSS, LGALS2, SERPINA1, IFITM3, SPI1, CFP PSAP, IFI30, SAT1, COTL1, S100A11, NPC2, GRN, LGALS3, GSTP1, PYCARD Negative: MALAT1, LTB, IL32, IL7R, CD2, B2M, ACAP1, CD27, STK17A, CTSW CD247, GIMAP5, AQP3, CCL5, SELL, TRAF3IP3, GZMA, MAL, CST7, ITM2A MYC, GIMAP7, HOPX, BEX2, LDLRAP1, GZMK, ETS1, ZAP70, TNFAIP8, RIC3 PC_ 2 Positive: CD79A, MS4A1, TCL1A, HLA-DQA1, HLA-DQB1, HLA-DRA, LINC00926, CD79B, HLA-DRB1, CD74 HLA-DMA, HLA-DPB1, HLA-DQA2, CD37, HLA-DRB5, HLA-DMB, HLA-DPA1, FCRLA, HVCN1, LTB BLNK, P2RX5, IGLL5, IRF8, SWAP70, ARHGAP24, FCGR2B, SMIM14, PPP1R14A, C16orf74 Negative: NKG7, PRF1, CST7, GZMB, GZMA, FGFBP2, CTSW, GNLY, B2M, SPON2 CCL4, GZMH, FCGR3A, CCL5, CD247, XCL2, CLIC3, AKR1C3, SRGN, HOPX TTC38, APMAP, CTSC, S100A4, IGFBP7, ANXA1, ID2, IL32, XCL1, RHOC PC_ 3 Positive: HLA-DQA1, CD79A, CD79B, HLA-DQB1, HLA-DPB1, HLA-DPA1, CD74, MS4A1, HLA-DRB1, HLA-DRA HLA-DRB5, HLA-DQA2, TCL1A, LINC00926, HLA-DMB, HLA-DMA, CD37, HVCN1, FCRLA, IRF8 PLAC8, BLNK, MALAT1, SMIM14, PLD4, LAT2, IGLL5, P2RX5, SWAP70, FCGR2B Negative: PPBP, PF4, SDPR, SPARC, GNG11, NRGN, GP9, RGS18, TUBB1, CLU HIST1H2AC, AP001189.4, ITGA2B, CD9, TMEM40, PTCRA, CA2, ACRBP, MMD, TREML1 NGFRAP1, F13A1, SEPT5, RUFY1, TSC22D1, MPP1, CMTM5, RP11-367G6.3, MYL9, GP1BA PC_ 4 Positive: HLA-DQA1, CD79B, CD79A, MS4A1, HLA-DQB1, CD74, HLA-DPB1, HIST1H2AC, PF4, TCL1A SDPR, HLA-DPA1, HLA-DRB1, HLA-DQA2, HLA-DRA, PPBP, LINC00926, GNG11, HLA-DRB5, SPARC GP9, AP001189.4, CA2, PTCRA, CD9, NRGN, RGS18, GZMB, CLU, TUBB1 Negative: VIM, IL7R, S100A6, IL32, S100A8, S100A4, GIMAP7, S100A10, S100A9, MAL AQP3, CD2, CD14, FYB, LGALS2, GIMAP4, ANXA1, CD27, FCN1, RBP7 LYZ, S100A11, GIMAP5, MS4A6A, S100A12, FOLR3, TRABD2A, AIF1, IL8, IFI6 PC_ 5 Positive: GZMB, NKG7, S100A8, FGFBP2, GNLY, CCL4, CST7, PRF1, GZMA, SPON2 GZMH, S100A9, LGALS2, CCL3, CTSW, XCL2, CD14, CLIC3, S100A12, CCL5 RBP7, MS4A6A, GSTP1, FOLR3, IGFBP7, TYROBP, TTC38, AKR1C3, XCL1, HOPX Negative: LTB, IL7R, CKB, VIM, MS4A7, AQP3, CYTIP, RP11-290F20.3, SIGLEC10, HMOX1 PTGES3, LILRB2, MAL, CD27, HN1, CD2, GDI2, ANXA5, CORO1B, TUBA1B FAM110A, ATP1A1, TRADD, PPA1, CCDC109B, ABRACL, CTD-2006K23.1, WARS, VMO1, FYB r$> pbmc <- FindNeighbors(pbmc, dims = 1:10) pbmc <- FindClusters(pbmc, resolution = 0.5) Computing nearest neighbor graph Computing SNN Modularity Optimizer version 1.3.0 by Ludo Waltman and Nees Jan van Eck Number of nodes: 2638 Number of edges: 95965 Running Louvain algorithm... 0% 10 20 30 40 50 60 70 80 90 100% [----|----|----|----|----|----|----|----|----|----| **************************************************| Maximum modularity in 10 random starts: 0.8723 Number of communities: 9 Elapsed time: 0 seconds r$> pbmc <- RunUMAP(pbmc, dims = 1:10) Warning: The default method for RunUMAP has changed from calling Python UMAP via reticulate to the R-native UWOT using the cosine metric To use Python UMAP via reticulate, set umap.method to 'umap-learn' and metric to 'correlation' This message will be shown once per session 14:53:59 UMAP embedding parameters a = 0.9922 b = 1.112 14:53:59 Read 2638 rows and found 10 numeric columns 14:53:59 Using Annoy for neighbor search, n_neighbors = 30 14:53:59 Building Annoy index with metric = cosine, n_trees = 50 0% 10 20 30 40 50 60 70 80 90 100% [----|----|----|----|----|----|----|----|----|----| **************************************************| 14:54:00 Writing NN index file to temp file /tmp/RtmpE4wsTH/file4c8fa3a69dfea 14:54:00 Searching Annoy index using 1 thread, search_k = 3000 14:54:02 Annoy recall = 100% 14:54:02 Commencing smooth kNN distance calibration using 1 thread 14:54:04 Initializing from normalized Laplacian + noise 14:54:04 Commencing optimization for 500 epochs, with 105124 positive edges 0% 10 20 30 40 50 60 70 80 90 100% [----|----|----|----|----|----|----|----|----|----| **************************************************| 14:54:11 Optimization finished r$> plot = DimPlot(pbmc, reduction = "umap") r$> LabelClusters(plot, id='ident', labels = 1:4) Error in LabelClusters(plot, id = "ident", labels = 1:4) : Length of labels (4) must be equal to the number of clusters being labeled (4). r$> ```