Integrate the layers of a Seurat object.
integrate_layers.RdRuns the Seurat 5 IntegrateLayers() workflow. It adds what calling
IntegrateLayers() directly leaves for the caller to handle:
Usage
integrate_layers(
x,
assay = "RNA",
int_reduction = "cca",
num_dim,
k_anchor = 10,
k_weight = 100,
log_file = NULL,
...
)Arguments
- x
Seurat object with split layers and a "pca" reduction.
- assay
Assay to integrate.
- int_reduction
Integration method: "cca", "rpca", or "harmony".
- num_dim
Number of dimensions to use (5-50). For "cca"/"rpca", this value is passed as
dims = 1:num_dimtoCCAIntegration()/RPCAIntegration(), which both take a realdimsargument.HarmonyIntegration()has nodimsparameter. It runs on the full"pca"embedding as-is, throughEmbeddings(orig), unsliced. So forint_reduction = "harmony",num_dimonly takes effect indirectly, through however many componentsorig.reduction("pca") already has. The normalintegrate_seurat_object()pipeline is unaffected:split_layers_by_batch()already computes that "pca" reduction with exactlynum_dimcomponents. A direct call is different. Ifx's "pca" reduction already has more components thannum_dim, thennum_dimhas no effect on the harmony path.- k_anchor
Neighbors to use when picking anchors. Ignored by "harmony". A value larger than Seurat's default of 5 strengthens the alignment.
- k_weight
Neighbors to use when weighting the corrections. Must be smaller than the number of cells in the smallest batch. Reduced to 25 when the smallest batch has fewer than 100 cells. Batches smaller than 25 cells are an error.
- log_file
Filename for the log file.
- ...
Extra arguments for whichever method
IntegrateLayers()dispatches to - e.g.theta/lambda/sigma/tau/nclustfor "harmony", ork.filter/sample.tree/normalization.methodfor "cca"/"rpca". An unrecognized name errors (viarlang::check_dots_used()) rather than being silently dropped by the method function's own....
Value
A Seurat object with rejoined layers and an int_reduction-named
reduction ("cca", "rpca", or "harmony").
Details
Clamps
k_weightto fit the smallest batch. Seurat's own default of 100 errors outright below that size. Seek_weightbelow.Excludes
dims/k.anchorfor"harmony".HarmonyIntegration()silently ignores both instead of erroring, so passing them would rely on that silent drop. Seenum_dim/k_anchorbelow.Forces
future::plan(future::sequential). Benchmarks show multisession gives no gain here, and is a documented liability at this scale elsewhere in this package.Rejoins the split layers with
JoinLayers()afterward.IntegrateLayers()itself leaves this undone.
Unlike the older anchor workflow, this function creates no "integrated"
assay. Clustering and visualization use the corrected embedding directly,
instead of re-running PCA. This function expects
split_layers_by_batch() to have run first. It is the one step of
integrate_seurat_object() that calls IntegrateLayers() directly.