JoinLayers to find markers in merged or integrated analysis in seurat
Entering edit mode
20 days ago


I have a question about the joining data layers in scRNA-Seq data in R performed via seurat. I merged 4 samples, performed integration of data (steps below), and while running either FindConservedMarkers or FindMarkers step, I always encounter with the below error, is it mandatory to use JoinLayers in order to find markers for merged or integrated data always?

I did not find JoinLayers function in seurat as part of standard scRNA-Seq integration workflow (maybe I would have missed it), however, while I reading found below resources which discusses about this function.

## Seurat analysis
CB30_list <- lapply(c(CB30_1, CB30_2, CB30_3, CB30_4), function(x) {
  x <- NormalizeData(x)
  x <- FindVariableFeatures(x, selection.method = "vst", nfeatures = 2000)
features <- SelectIntegrationFeatures(object.list = CB30_list, nfeatures=10000)
CB30_anchors <- FindIntegrationAnchors(object.list = CB30_list, anchor.features = features)
CB30_combined <- IntegrateData(anchorset = CB30_anchors)
DefaultAssay(CB30_combined) <- "integrated"
CB30_combined <- ScaleData(CB30_combined, verbose = FALSE)
CB30_combined <- RunPCA(CB30_combined, npcs = 30, verbose = FALSE)
CB30_combined <- RunUMAP(CB30_combined, reduction = "pca", dims = 1:30)
CB30_combined <- FindNeighbors(CB30_combined, dims = 1:30)
CB30_combined <- FindClusters(CB30_combined, resolution = 0.8)
Idents(CB30_combined) <- "celltype"
DefaultAssay(CB30_combined) <- "RNA"
## Error
markers_1 <- FindConservedMarkers(CB30_combined, ident.1 = "CD4", grouping.var = "Vector", verbose = FALSE)
Warning: Identity: CD4+ not present in group 41BBz. Skipping 41BBz
Error in FindMarkers.StdAssay(object = data.use, slot = slot, cells.1 = cells$cells.1,  :
    data layers are not joined. Please run JoinLayers OR,
    markers_2 <- FindMarkers(CB30_combined, ident.1 = "CD4+", ident.2 = "CD4+ UT", verbose = FALSE)
## Error resolved after running:
CB30_combined <- JoinLayers(object = CB30_combined)
markers_2 <- FindMarkers(CB30_combined, ident.1 = "CD4+", ident.2 = "CD4+ UT", verbose = FALSE)

Best Regards,

scRNA-seq seurat FindMarkers • 496 views
Entering edit mode
19 days ago
fracarb8 ★ 1.4k

JoinLayers is new in v5, and it is "discussed" in the integration vignettes.

...Once integrative analysis is complete, you can rejoin the layers - which collapses the individual datasets together and recreates the original counts and data layers. 
You will need to do this before performing any differential expression analysis. However, you can always resplit the layers in case you would like to reperform integrative analysis ...

Working with layers makes sense when you are integrating a huge number of cells, as you are generating the global matrix only when you really need it.

Entering edit mode

Login before adding your answer.

Traffic: 1006 users visited in the last hour
Help About
Access RSS

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6