Skip to contents

This function generates a projection plot, which can be used to compare two groups of cells in a dimensionality reduction space.

Usage

ProjectionPlot(
  srt_query,
  srt_ref,
  query_group = NULL,
  ref_group = NULL,
  query_reduction = "ref.embeddings",
  ref_reduction = srt_query[[query_reduction]]@misc[["reduction.model"]] %||% NULL,
  query_param = list(palette = "Set1", cells.highlight = TRUE),
  ref_param = list(palette = "Paired"),
  xlim = NULL,
  ylim = NULL,
  pt.size = 0.8,
  stroke.highlight = 0.5
)

Arguments

srt_query

An object of class Seurat storing the query group cells.

srt_ref

An object of class Seurat storing the reference group cells.

query_group

The grouping variable for the query group cells.

ref_group

The grouping variable for the reference group cells.

query_reduction

The name of the reduction in the query group cells.

ref_reduction

The name of the reduction in the reference group cells.

query_param

A list of parameters for customizing the query group plot. Available parameters: palette (color palette for groups) and cells.highlight (whether to highlight cells).

ref_param

A list of parameters for customizing the reference group plot. Available parameters: palette (color palette for groups) and cells.highlight (whether to highlight cells).

xlim

The x-axis limits for the plot. If not provided, the limits will be calculated based on the data.

ylim

The y-axis limits for the plot. If not provided, the limits will be calculated based on the data.

pt.size

The size of the points in the plot.

stroke.highlight

The size of the stroke highlight for cells.

Examples

data(panc8_sub)
srt_ref <- panc8_sub[, panc8_sub$tech != "fluidigmc1"]
srt_query <- panc8_sub[, panc8_sub$tech == "fluidigmc1"]
srt_ref <- integration_scop(
  srt_ref,
  batch = "tech",
  integration_method = "Seurat"
)
#>  [2025-09-20 13:24:45] Run Seurat integration...
#>  [2025-09-20 13:24:45] Spliting `srt_merge` into `srt_list` by column "tech"...
#>  [2025-09-20 13:24:46] Checking a list of <Seurat> object...
#> ! [2025-09-20 13:24:46] Data 1/4 of the `srt_list` is "unknown"
#>  [2025-09-20 13:24:46] Perform `NormalizeData()` with `normalization.method = 'LogNormalize'` on the data 1/4 of the `srt_list`...
#>  [2025-09-20 13:24:47] Perform `Seurat::FindVariableFeatures()` on the data 1/4 of the `srt_list`...
#> ! [2025-09-20 13:24:47] Data 2/4 of the `srt_list` is "unknown"
#>  [2025-09-20 13:24:47] Perform `NormalizeData()` with `normalization.method = 'LogNormalize'` on the data 2/4 of the `srt_list`...
#>  [2025-09-20 13:24:49] Perform `Seurat::FindVariableFeatures()` on the data 2/4 of the `srt_list`...
#> ! [2025-09-20 13:24:49] Data 3/4 of the `srt_list` is "unknown"
#>  [2025-09-20 13:24:49] Perform `NormalizeData()` with `normalization.method = 'LogNormalize'` on the data 3/4 of the `srt_list`...
#>  [2025-09-20 13:24:51] Perform `Seurat::FindVariableFeatures()` on the data 3/4 of the `srt_list`...
#> ! [2025-09-20 13:24:51] Data 4/4 of the `srt_list` is "unknown"
#>  [2025-09-20 13:24:51] Perform `NormalizeData()` with `normalization.method = 'LogNormalize'` on the data 4/4 of the `srt_list`...
#>  [2025-09-20 13:24:53] Perform `Seurat::FindVariableFeatures()` on the data 4/4 of the `srt_list`...
#>  [2025-09-20 13:24:53] Use the separate HVF from srt_list
#>  [2025-09-20 13:24:53] Number of available HVF: 2000
#>  [2025-09-20 13:24:54] Finished check
#>  [2025-09-20 13:24:55] Perform FindIntegrationAnchors
#> Warning: Different features in new layer data than already exists for scale.data
#> Warning: Different features in new layer data than already exists for scale.data
#> Warning: Different features in new layer data than already exists for scale.data
#> Warning: Different features in new layer data than already exists for scale.data
#> Warning: The `slot` argument of `SetAssayData()` is deprecated as of SeuratObject 5.0.0.
#>  Please use the `layer` argument instead.
#>  The deprecated feature was likely used in the Seurat package.
#>   Please report the issue at <https://github.com/satijalab/seurat/issues>.
#>  [2025-09-20 13:25:15] Perform integration(Seurat)
#> Warning: Layer counts isn't present in the assay object; returning NULL
#> Warning: Different cells in new layer data than already exists for scale.data
#> Warning: Layer counts isn't present in the assay object; returning NULL
#> Warning: Different cells in new layer data than already exists for scale.data
#> Warning: Layer counts isn't present in the assay object; returning NULL
#>  [2025-09-20 13:25:23] Perform ScaleData
#>  [2025-09-20 13:25:23] Perform linear dimension reduction ("pca")
#>  [2025-09-20 13:25:24] Perform FindClusters ("louvain")
#>  [2025-09-20 13:25:24] Reorder clusters...
#> ! [2025-09-20 13:25:24] Using `Seurat::AverageExpression()` to calculate pseudo-bulk data for <Assay>
#>  [2025-09-20 13:25:24] Perform nonlinear dimension reduction (umap)
#>  [2025-09-20 13:25:24] Non-linear dimensionality reduction (umap) using (Seuratpca) dims (1-11) as input
#>  [2025-09-20 13:25:28] Non-linear dimensionality reduction (umap) using (Seuratpca) dims (1-11) as input
#>  [2025-09-20 13:25:34] Run Seurat integration done
CellDimPlot(
  srt_ref,
  group.by = c("celltype", "tech")
)
#> Warning: No shared levels found between `names(values)` of the manual scale and the
#> data's fill values.
#> Warning: No shared levels found between `names(values)` of the manual scale and the
#> data's fill values.


# Projection
srt_query <- RunKNNMap(
  srt_query = srt_query,
  srt_ref = srt_ref,
  ref_umap = "SeuratUMAP2D"
)
#>  [2025-09-20 13:25:34] Use the features to calculate distance metric
#> Error in CheckDataType(data = GetAssayData5(srt_query, layer = "data",     assay = query_assay, verbose = FALSE)): argument "object" is missing, with no default
ProjectionPlot(
  srt_query = srt_query,
  srt_ref = srt_ref,
  query_group = "celltype",
  ref_group = "celltype"
)
#> Error in srt_query[[query_reduction]]: ‘ref.embeddings’ not found in this Seurat object
#>