| Title: | Identifying Synergistic Gene Pairs in Single-Cell and Spatial Transcriptomics |
|---|---|
| Description: | Discovers synergistic gene pairs in single-cell RNA-seq and spatial transcriptomics data. Unlike conventional pairwise co-expression analyses that rely on a single correlation metric, scPairs integrates 14 complementary metrics across five orthogonal evidence layers to compute a composite synergy score with optional permutation-based significance testing. The five evidence layers span cell-level co-expression (Pearson, Spearman, biweight midcorrelation, mutual information, ratio consistency), neighbourhood-aware smoothing (KNN-smoothed correlation, neighbourhood co-expression, cluster pseudo-bulk, cross-cell-type, neighbourhood synergy), prior biological knowledge (GO/KEGG co-annotation Jaccard, pathway bridge score), trans-cellular interaction, and spatial co-variation (Lee's L, co-location quotient). This multi-scale design enables researchers to move beyond simple co-expression towards a comprehensive characterisation of cooperative gene regulation at transcriptomic and spatial resolution. For more information, see the package documentation at <https://github.com/zhaoqing-wang/scPairs>. |
| Authors: | Zhaoqing Wang [aut, cre] (ORCID: <https://orcid.org/0000-0001-8348-7245>) |
| Maintainer: | Zhaoqing Wang <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.9 |
| Built: | 2026-05-23 09:11:56 UTC |
| Source: | https://github.com/zhaoqing-wang/scpairs |
Given two genes, AssessGenePair performs an in-depth evaluation of their
co-regulatory relationship. In addition to the standard multi-metric
scoring, it computes:
Per-cluster co-expression – correlation within each cell cluster.
Expression distribution overlap – Jaccard index of expressing cells.
Permutation-based significance – 999 permutations by default.
AssessGenePair( object, gene1, gene2, assay = NULL, slot = "data", cluster_col = NULL, mode = c("all", "expression", "prior_only"), use_prior = TRUE, organism = "mouse", custom_pairs = NULL, use_neighbourhood = TRUE, neighbourhood_k = 20, neighbourhood_reduction = "pca", smooth_alpha = 0.3, use_spatial = TRUE, spatial_k = 6, n_perm = 999, verbose = TRUE )AssessGenePair( object, gene1, gene2, assay = NULL, slot = "data", cluster_col = NULL, mode = c("all", "expression", "prior_only"), use_prior = TRUE, organism = "mouse", custom_pairs = NULL, use_neighbourhood = TRUE, neighbourhood_k = 20, neighbourhood_reduction = "pca", smooth_alpha = 0.3, use_spatial = TRUE, spatial_k = 6, n_perm = 999, verbose = TRUE )
object |
A Seurat object. |
gene1 |
Character; first gene. |
gene2 |
Character; second gene. |
assay |
Character; assay name. |
slot |
Character; data slot. |
cluster_col |
Character; cluster column. |
mode |
Character; |
use_prior |
Logical; prior knowledge scores. |
organism |
Character; |
custom_pairs |
Optional data.frame of custom interactions. |
use_neighbourhood |
Logical; neighbourhood metrics. |
neighbourhood_k |
Integer; KNN k. |
neighbourhood_reduction |
Character; reduction for KNN. |
smooth_alpha |
Numeric; self-weight for smoothing. |
use_spatial |
Logical. |
spatial_k |
Integer; spatial KNN k. |
n_perm |
Integer; permutations (default 999). |
verbose |
Logical. |
The mode parameter controls which layers are scored:
"all" (default) – full multi-evidence assessment.
"expression" – expression and neighbourhood metrics only.
"prior_only" – prior knowledge scores only.
A list with class "scPairs_pair_result":
gene1, gene2
The query genes.
pairsSingle-row data.table with all metric columns and
synergy_score, rank, confidence (same format as FindAllPairs
output for unified downstream processing).
metricsNamed list of all computed metrics.
per_clusterdata.frame of per-cluster correlations.
synergy_scoreComposite score.
p_valuePermutation p-value.
confidenceCategorical confidence label.
jaccard_indexExpression overlap Jaccard index.
has_spatialLogical.
n_cellsInteger.
modeCharacter.
FindAllPairs for genome-wide screening,
FindGenePairs for query-centric partner search,
PlotPairSynergy and PlotPairSummary for
visualising pair-level evidence.
Other Section_1_Discovery:
FindAllPairs(),
FindGenePairs()
# Assess the injected co-expressed pair GENE3 & GENE4. result <- AssessGenePair(scpairs_testdata, gene1 = "GENE3", gene2 = "GENE4", mode = "expression", verbose = FALSE) print(result)# Assess the injected co-expressed pair GENE3 & GENE4. result <- AssessGenePair(scpairs_testdata, gene1 = "GENE3", gene2 = "GENE4", mode = "expression", verbose = FALSE) print(result)
The primary discovery function of scPairs.
Given a Seurat object, FindAllPairs identifies synergistic gene pairs by
integrating multiple lines of evidence: co-expression, neighbourhood
smoothing, prior biological knowledge, and spatial co-variation.
FindAllPairs( object, features = NULL, n_top_genes = 2000, assay = NULL, slot = "data", cluster_col = NULL, mode = c("all", "expression", "prior_only"), cor_method = c("pearson", "spearman", "biweight"), n_mi_bins = 5, min_cells_expressed = 10, use_prior = TRUE, organism = "mouse", custom_pairs = NULL, use_neighbourhood = TRUE, neighbourhood_k = 20, neighbourhood_reduction = "pca", smooth_alpha = 0.3, use_spatial = TRUE, spatial_k = 6, n_perm = 0, weights = NULL, top_n = NULL, verbose = TRUE )FindAllPairs( object, features = NULL, n_top_genes = 2000, assay = NULL, slot = "data", cluster_col = NULL, mode = c("all", "expression", "prior_only"), cor_method = c("pearson", "spearman", "biweight"), n_mi_bins = 5, min_cells_expressed = 10, use_prior = TRUE, organism = "mouse", custom_pairs = NULL, use_neighbourhood = TRUE, neighbourhood_k = 20, neighbourhood_reduction = "pca", smooth_alpha = 0.3, use_spatial = TRUE, spatial_k = 6, n_perm = 0, weights = NULL, top_n = NULL, verbose = TRUE )
object |
A Seurat object (scRNA-seq or spatial). |
features |
Character vector of gene names to consider.
NULL (default) uses Seurat |
n_top_genes |
Integer; maximum number of genes to analyse when
|
assay |
Character; assay to use. Default: |
slot |
Character; data slot. Default |
cluster_col |
Character; column in |
mode |
Character; |
cor_method |
Character vector; correlation methods to compute.
Default |
n_mi_bins |
Integer; bins for mutual information. 0 = skip MI. |
min_cells_expressed |
Integer; minimum co-expressing cells to keep a pair. Default 10. |
use_prior |
Logical; integrate prior knowledge (GO/KEGG). Default TRUE. |
organism |
Character; |
custom_pairs |
Optional data.frame with columns |
use_neighbourhood |
Logical; compute neighbourhood-aware metrics. Default TRUE. |
neighbourhood_k |
Integer; KNN k. Default 20. |
neighbourhood_reduction |
Character; reduction for KNN. Default |
smooth_alpha |
Numeric in [0,1]; self-weight for KNN smoothing. |
use_spatial |
Logical; compute spatial metrics when available. |
spatial_k |
Integer; spatial KNN k. |
n_perm |
Integer; permutations for p-values. 0 = skip. |
weights |
Named numeric; metric weights for score integration. |
top_n |
Integer or NULL; return only top n pairs. |
verbose |
Logical. |
Metrics are rank-normalised and combined via weighted summation. Optional permutation testing provides empirical p-values.
The mode parameter controls which metric layers are computed:
"all" (default) – compute all available metrics.
"expression" – expression and neighbourhood metrics only (no prior
knowledge).
"prior_only" – prior knowledge scores only (fast).
A list with class "scPairs_result" containing:
pairsdata.table of gene pairs with all metric columns,
synergy_score, rank, p_value (if permutation), p_adj,
confidence.
parametersList of analysis parameters.
n_genesNumber of genes analysed.
n_cellsNumber of cells.
has_spatialLogical.
modeCharacter; the mode used.
FindGenePairs for query-centric partner search,
AssessGenePair for in-depth single-pair assessment,
PlotPairNetwork and PlotPairHeatmap for
visualising discovery results.
Other Section_1_Discovery:
AssessGenePair(),
FindGenePairs()
# scpairs_testdata is a built-in Seurat object with 100 cells x 20 genes. # GENE3 & GENE4 are injected as the top co-expressed pair. result <- FindAllPairs(scpairs_testdata, n_top_genes = 20, top_n = 10, mode = "expression", verbose = FALSE) print(result)# scpairs_testdata is a built-in Seurat object with 100 cells x 20 genes. # GENE3 & GENE4 are injected as the top co-expressed pair. result <- FindAllPairs(scpairs_testdata, n_top_genes = 20, top_n = 10, mode = "expression", verbose = FALSE) print(result)
Given a gene of interest, FindGenePairs identifies and ranks all genes
that act synergistically with it. Uses the same multi-evidence framework
as FindAllPairs() but focuses computation on pairs involving the query
gene, making it much faster for targeted queries.
FindGenePairs( object, gene, candidates = NULL, n_top_genes = 2000, assay = NULL, slot = "data", cluster_col = NULL, mode = c("all", "expression", "prior_only"), cor_method = c("pearson", "spearman", "biweight"), n_mi_bins = 5, min_cells_expressed = 10, use_prior = TRUE, organism = "mouse", custom_pairs = NULL, use_neighbourhood = TRUE, neighbourhood_k = 20, neighbourhood_reduction = "pca", smooth_alpha = 0.3, use_spatial = TRUE, spatial_k = 6, n_perm = 0, weights = NULL, top_n = NULL, verbose = TRUE )FindGenePairs( object, gene, candidates = NULL, n_top_genes = 2000, assay = NULL, slot = "data", cluster_col = NULL, mode = c("all", "expression", "prior_only"), cor_method = c("pearson", "spearman", "biweight"), n_mi_bins = 5, min_cells_expressed = 10, use_prior = TRUE, organism = "mouse", custom_pairs = NULL, use_neighbourhood = TRUE, neighbourhood_k = 20, neighbourhood_reduction = "pca", smooth_alpha = 0.3, use_spatial = TRUE, spatial_k = 6, n_perm = 0, weights = NULL, top_n = NULL, verbose = TRUE )
object |
A Seurat object. |
gene |
Character; the query gene name. |
candidates |
Character vector of candidate partner genes. NULL = auto-select. |
n_top_genes |
Integer; max candidates when |
assay |
Character; assay name. |
slot |
Character; data slot. |
cluster_col |
Character; cluster column in meta.data. |
mode |
Character; |
cor_method |
Correlation methods. |
n_mi_bins |
Bins for mutual information. |
min_cells_expressed |
Minimum cells co-expressing both genes. |
use_prior |
Logical; compute prior knowledge metrics. |
organism |
Character; |
custom_pairs |
Optional data.frame of custom interactions. |
use_neighbourhood |
Logical; compute neighbourhood metrics. |
neighbourhood_k |
Integer; KNN k. |
neighbourhood_reduction |
Character; reduction for KNN. |
smooth_alpha |
Numeric; self-weight for smoothing. |
use_spatial |
Logical; compute spatial metrics. |
spatial_k |
Integer; spatial neighbourhood k. |
n_perm |
Integer; permutations for p-values. |
weights |
Named numeric; metric weights. |
top_n |
Integer; return only top partners. |
verbose |
Logical. |
The mode parameter controls which metric layers are computed:
"all" (default) – all available metrics.
"expression" – expression and neighbourhood only.
"prior_only" – prior knowledge scores only.
A list with class "scPairs_gene_result":
query_geneThe input gene.
pairsdata.table of partners ranked by synergy score.
parametersAnalysis parameters.
n_candidatesNumber of candidates tested.
n_cellsNumber of cells.
has_spatialLogical.
modeCharacter.
FindAllPairs for genome-wide screening,
AssessGenePair for in-depth single-pair assessment,
PlotPairNetwork for visualising partner networks.
Other Section_1_Discovery:
AssessGenePair(),
FindAllPairs()
# Find synergistic partners of GENE3. GENE4 is expected to rank first. result <- FindGenePairs(scpairs_testdata, gene = "GENE3", top_n = 10, mode = "expression", verbose = FALSE) print(result)# Find synergistic partners of GENE3. GENE4 is expected to rank first. result <- FindGenePairs(scpairs_testdata, gene = "GENE3", top_n = 10, mode = "expression", verbose = FALSE) print(result)
Draws a publication-ready radial bridge gene network showing the
prior-knowledge connections between a focal gene pair via shared GO/KEGG
pathway intermediaries (bridge genes). Focal genes are placed at the
centre; bridge genes are arranged on a ring whose radius is inversely
proportional to their shared pathway count with the focal pair (more
shared terms => closer to centre, reflecting stronger biological relevance).
Solid edges connect focal genes to bridge genes: red edges originate from
gene1, blue edges from gene2. Edge width encodes shared
term count. Pairwise Jaccard similarity between bridge genes is overlaid
as thin dotted lines, whose opacity reflects similarity strength,
revealing functional clusters among the intermediaries.
PlotBridgeNetwork( object, gene1, gene2, organism = "mouse", prior_net = NULL, top_bridges = 15, layout = "auto", assay = NULL, slot = "data", label_size = 3, pt_size_range = c(3, 9), edge_width_range = c(0.4, 2), sim_threshold = 0.05, title = NULL )PlotBridgeNetwork( object, gene1, gene2, organism = "mouse", prior_net = NULL, top_bridges = 15, layout = "auto", assay = NULL, slot = "data", label_size = 3, pt_size_range = c(3, 9), edge_width_range = c(0.4, 2), sim_threshold = 0.05, title = NULL )
object |
A Seurat object. |
gene1 |
Character; first focal gene. |
gene2 |
Character; second focal gene. |
organism |
Character; |
prior_net |
Optional prior network object from
|
top_bridges |
Integer; maximum number of bridge genes to display. Default 15. |
layout |
Ignored; layout is always radial (kept for API compatibility). |
assay |
Character; assay name. NULL uses the default assay. |
slot |
Character; data layer/slot. Default |
label_size |
Numeric; gene label font size. Default 3. |
pt_size_range |
Numeric vector of length 2; minimum and maximum node
sizes for bridge genes. Default |
edge_width_range |
Numeric vector of length 2; minimum and maximum
edge widths for focal-to-bridge connections, scaled by shared term
count. Default |
sim_threshold |
Numeric (0 to 1); minimum Jaccard similarity between two bridge genes required to draw a dotted similarity edge. Default 0.05. |
title |
Character; plot title. NULL generates a default title. |
A ggplot object. Focal genes appear as large red nodes at
the centre. Bridge genes are arranged radially, sized by node degree and
coloured by mean expression. Solid coloured edges (red = gene1,
blue = gene2) connect focal genes to bridge genes, with width proportional
to shared term count. Thin dotted grey lines between bridge genes encode
Jaccard pathway similarity.
PlotPairSynergy for the 4-panel synergy dashboard
that embeds this network as one panel, AssessGenePair for
extracting bridge genes programmatically.
Other Section_2_Visualization:
PlotPairCrossType(),
PlotPairDimplot(),
PlotPairHeatmap(),
PlotPairNetwork(),
PlotPairScatter(),
PlotPairSmoothed(),
PlotPairSpatial(),
PlotPairSummary(),
PlotPairSynergy(),
PlotPairViolin()
## Not run: # Requires Bioconductor annotation packages (org.Hs.eg.db or org.Mm.eg.db) PlotBridgeNetwork(seurat_obj, gene1 = "Adora2a", gene2 = "Ido1", organism = "mouse") ## End(Not run)## Not run: # Requires Bioconductor annotation packages (org.Hs.eg.db or org.Mm.eg.db) PlotBridgeNetwork(seurat_obj, gene1 = "Adora2a", gene2 = "Ido1", organism = "mouse") ## End(Not run)
Visualises the cross-cell-type interaction structure for a gene pair as a
heatmap. Each tile represents a directed cell-type pair
(source type neighbour type), coloured by the Pearson correlation
between gene A expression in the source cells and gene B expression in the
neighbouring cells.
This is the primary visualisation for the trans-cellular synergy metric introduced in scPairs 0.1.3. It reveals which cell-type interfaces carry the cross-type signal (e.g. Adora2a in T-cells correlated with Ido1 in dendritic cells).
PlotPairCrossType( object, gene1, gene2, result = NULL, assay = NULL, slot = "data", cluster_col = NULL, neighbourhood_k = 20, neighbourhood_reduction = "pca", min_cross_pairs = 30, min_pct_expressed = 0.01, show_n = TRUE, show_reverse = TRUE, diverging = TRUE, title = NULL )PlotPairCrossType( object, gene1, gene2, result = NULL, assay = NULL, slot = "data", cluster_col = NULL, neighbourhood_k = 20, neighbourhood_reduction = "pca", min_cross_pairs = 30, min_pct_expressed = 0.01, show_n = TRUE, show_reverse = TRUE, diverging = TRUE, title = NULL )
object |
A Seurat object. |
gene1 |
Character; first gene. |
gene2 |
Character; second gene. |
result |
Optional |
assay |
Character; assay name. Default: |
slot |
Character; data slot. Default |
cluster_col |
Character; meta.data column with cell-type labels.
NULL = use |
neighbourhood_k |
Integer; k for KNN graph. Default 20. |
neighbourhood_reduction |
Character; reduction for KNN graph.
Default |
min_cross_pairs |
Integer; minimum cross-type pairs per tile. Tiles with fewer pairs are greyed out. Default 30. |
min_pct_expressed |
Numeric; minimum percentage of cells (0-1) in a cell type that must express a gene. Default 0.01 (1%). Prevents spurious correlations with very sparse genes. |
show_n |
Logical; annotate each tile with the number of cross-type neighbour pairs. Default TRUE. |
show_reverse |
Logical; if TRUE (default), show a second panel for
the reverse direction (gene2 in source |
diverging |
Logical; use a diverging red–white–blue colour scale centred at 0. Default TRUE. |
title |
Character; overall title. NULL = auto-generated. |
A ggplot heatmap (or two-panel patchwork when
show_reverse = TRUE) with cell-type pairs on axes and synergy
enrichment encoded by colour.
AssessGenePair for cross-cell-type metrics,
PlotPairDimplot for individual-cell UMAP display.
Other Section_2_Visualization:
PlotBridgeNetwork(),
PlotPairDimplot(),
PlotPairHeatmap(),
PlotPairNetwork(),
PlotPairScatter(),
PlotPairSmoothed(),
PlotPairSpatial(),
PlotPairSummary(),
PlotPairSynergy(),
PlotPairViolin()
# scpairs_testdata has clusters (seurat_clusters) and PCA already built in. PlotPairCrossType(scpairs_testdata, gene1 = "GENE3", gene2 = "GENE4")# scpairs_testdata has clusters (seurat_clusters) and PCA already built in. PlotPairCrossType(scpairs_testdata, gene1 = "GENE3", gene2 = "GENE4")
Displays the co-expression of two genes on the UMAP (or other reduction) embedding. Three panels show: gene 1 expression, gene 2 expression, and their element-wise product (co-expression intensity). This allows visual assessment of whether co-expressing cells cluster together.
PlotPairDimplot( object, gene1, gene2, reduction = "umap", assay = NULL, slot = "data", pt_size = 0.5, alpha = 0.8, title = NULL )PlotPairDimplot( object, gene1, gene2, reduction = "umap", assay = NULL, slot = "data", pt_size = 0.5, alpha = 0.8, title = NULL )
object |
A Seurat object with a dimensionality reduction. |
gene1 |
Character; first gene. |
gene2 |
Character; second gene. |
reduction |
Character; reduction to use. Default |
assay |
Character; assay. |
slot |
Character; data slot. |
pt_size |
Numeric; point size. |
alpha |
Numeric; point alpha. |
title |
Character; overall title. |
A combined ggplot (patchwork) of three panels: individual
gene expression and their co-expression product, all overlaid on the
dimensionality-reduction embedding.
PlotPairSmoothed for KNN-smoothed panels,
PlotPairScatter for gene-gene scatter,
PlotPairSpatial for spatial data.
Other Section_2_Visualization:
PlotBridgeNetwork(),
PlotPairCrossType(),
PlotPairHeatmap(),
PlotPairNetwork(),
PlotPairScatter(),
PlotPairSmoothed(),
PlotPairSpatial(),
PlotPairSummary(),
PlotPairSynergy(),
PlotPairViolin()
# scpairs_testdata has a real UMAP embedding; GENE3 & GENE4 are co-expressed. PlotPairDimplot(scpairs_testdata, gene1 = "GENE3", gene2 = "GENE4")# scpairs_testdata has a real UMAP embedding; GENE3 & GENE4 are co-expressed. PlotPairDimplot(scpairs_testdata, gene1 = "GENE3", gene2 = "GENE4")
Displays a symmetric heatmap of synergy scores among a set of genes. Useful for visualising the overall co-expression landscape of top synergistic genes or genes of interest.
PlotPairHeatmap( result, top_n = 30, genes = NULL, cluster_genes = TRUE, low_color = "#F7FBFF", high_color = "#08306B", title = "Gene pair synergy heatmap" )PlotPairHeatmap( result, top_n = 30, genes = NULL, cluster_genes = TRUE, low_color = "#F7FBFF", high_color = "#08306B", title = "Gene pair synergy heatmap" )
result |
An |
top_n |
Integer; include the top N genes by number of significant partnerships. Default 30. |
genes |
Character vector; specific genes to include. NULL = auto. |
cluster_genes |
Logical; cluster rows/columns by score similarity. Default TRUE. |
low_color |
Character; colour for low scores. |
high_color |
Character; colour for high scores. |
title |
Character; plot title. |
A ggplot object; rows and columns are genes, fill encodes synergy
score.
FindAllPairs, FindGenePairs,
PlotPairNetwork for an alternative network view.
Other Section_2_Visualization:
PlotBridgeNetwork(),
PlotPairCrossType(),
PlotPairDimplot(),
PlotPairNetwork(),
PlotPairScatter(),
PlotPairSmoothed(),
PlotPairSpatial(),
PlotPairSummary(),
PlotPairSynergy(),
PlotPairViolin()
result <- FindAllPairs(scpairs_testdata, n_top_genes = 20, top_n = 15, mode = "expression", verbose = FALSE) PlotPairHeatmap(result, top_n = 10)result <- FindAllPairs(scpairs_testdata, n_top_genes = 20, top_n = 15, mode = "expression", verbose = FALSE) PlotPairHeatmap(result, top_n = 10)
Draws a publication-ready gene interaction network from scPairs results. Nodes represent genes; edges represent synergistic relationships. Edge width encodes synergy score; edge colour encodes confidence. Node size optionally reflects the number of significant partners (degree centrality).
PlotPairNetwork( result, top_n = 50, min_score = 0, confidence = NULL, layout = "fr", node_color = "#2C3E50", edge_palette = c(High = "#E74C3C", Medium = "#F39C12", Low = "#95A5A6", NS = "#D5D8DC"), label_size = 3.5, title = NULL, show_legend = TRUE )PlotPairNetwork( result, top_n = 50, min_score = 0, confidence = NULL, layout = "fr", node_color = "#2C3E50", edge_palette = c(High = "#E74C3C", Medium = "#F39C12", Low = "#95A5A6", NS = "#D5D8DC"), label_size = 3.5, title = NULL, show_legend = TRUE )
result |
An object of class |
top_n |
Integer; show only the top N edges. Default 50. |
min_score |
Numeric; minimum synergy score to display an edge. |
confidence |
Character vector; filter to these confidence levels
(e.g., |
layout |
Character; ggraph layout algorithm. Default |
node_color |
Character; colour for nodes. Default |
edge_palette |
Character vector of 3 colours for confidence (High, Medium, Low). Default blue-orange-grey scheme. |
label_size |
Numeric; node label font size. |
title |
Character; plot title. |
show_legend |
Logical. |
A ggplot object; nodes are genes, edges are gene pairs coloured
and weighted by synergy score.
FindAllPairs, FindGenePairs,
PlotPairHeatmap for an alternative matrix view.
Other Section_2_Visualization:
PlotBridgeNetwork(),
PlotPairCrossType(),
PlotPairDimplot(),
PlotPairHeatmap(),
PlotPairScatter(),
PlotPairSmoothed(),
PlotPairSpatial(),
PlotPairSummary(),
PlotPairSynergy(),
PlotPairViolin()
result <- FindAllPairs(scpairs_testdata, n_top_genes = 20, top_n = 10, mode = "expression", verbose = FALSE) PlotPairNetwork(result, top_n = 8)result <- FindAllPairs(scpairs_testdata, n_top_genes = 20, top_n = 10, mode = "expression", verbose = FALSE) PlotPairNetwork(result, top_n = 8)
Plots cell-level expression of gene1 vs. gene2 as a scatter plot, coloured by cluster identity. Marginal density curves (optional) help reveal cluster-specific co-expression patterns.
PlotPairScatter( object, gene1, gene2, group_by = NULL, assay = NULL, slot = "data", pt_size = 0.5, alpha = 0.6, add_density = FALSE, title = NULL )PlotPairScatter( object, gene1, gene2, group_by = NULL, assay = NULL, slot = "data", pt_size = 0.5, alpha = 0.6, add_density = FALSE, title = NULL )
object |
Seurat object. |
gene1 |
Character; x-axis gene. |
gene2 |
Character; y-axis gene. |
group_by |
Character; colour cells by this meta.data column. |
assay |
Character; assay. |
slot |
Character; data slot. |
pt_size |
Numeric. |
alpha |
Numeric. |
add_density |
Logical; add marginal density. Requires |
title |
Character. |
A ggplot scatter plot; cells are coloured by cluster/group,
with optional marginal density panels when ggExtra is installed.
PlotPairViolin, PlotPairDimplot.
Other Section_2_Visualization:
PlotBridgeNetwork(),
PlotPairCrossType(),
PlotPairDimplot(),
PlotPairHeatmap(),
PlotPairNetwork(),
PlotPairSmoothed(),
PlotPairSpatial(),
PlotPairSummary(),
PlotPairSynergy(),
PlotPairViolin()
PlotPairScatter(scpairs_testdata, "GENE3", "GENE4", group_by = "seurat_clusters")PlotPairScatter(scpairs_testdata, "GENE3", "GENE4", group_by = "seurat_clusters")
A six-panel visualization that shows both raw and KNN-smoothed expression for a gene pair on the UMAP (or other reduction) embedding. The top row shows raw expression (gene1, gene2, product); the bottom row shows KNN-smoothed expression. This is particularly informative for gene pairs that are not co-expressed in the same cell but share neighbourhood-level co-expression patterns.
PlotPairSmoothed( object, gene1, gene2, reduction = "umap", smooth_reduction = "pca", k = 20, alpha = 0.3, assay = NULL, slot = "data", pt_size = 0.3, pt_alpha = 0.8, title = NULL )PlotPairSmoothed( object, gene1, gene2, reduction = "umap", smooth_reduction = "pca", k = 20, alpha = 0.3, assay = NULL, slot = "data", pt_size = 0.3, pt_alpha = 0.8, title = NULL )
object |
A Seurat object with a dimensionality reduction. |
gene1 |
Character; first gene. |
gene2 |
Character; second gene. |
reduction |
Character; reduction for plotting. Default |
smooth_reduction |
Character; reduction for KNN graph. Default |
k |
Integer; neighbourhood size for smoothing. Default 20. |
alpha |
Numeric in [0,1]; self-weight for smoothing. Default 0.3. |
assay |
Character; assay. |
slot |
Character; data slot. |
pt_size |
Numeric; point size. |
pt_alpha |
Numeric; point alpha. |
title |
Character; overall title. |
A combined ggplot (patchwork) with 6 panels: three showing
raw expression and three showing KNN-smoothed expression, for gene1,
gene2, and their co-expression product.
PlotPairDimplot for the raw-only 3-panel variant,
PlotPairSummary for a comprehensive multi-evidence summary.
Other Section_2_Visualization:
PlotBridgeNetwork(),
PlotPairCrossType(),
PlotPairDimplot(),
PlotPairHeatmap(),
PlotPairNetwork(),
PlotPairScatter(),
PlotPairSpatial(),
PlotPairSummary(),
PlotPairSynergy(),
PlotPairViolin()
# scpairs_testdata has PCA (smooth_reduction) and UMAP (reduction) ready. PlotPairSmoothed(scpairs_testdata, gene1 = "GENE3", gene2 = "GENE4")# scpairs_testdata has PCA (smooth_reduction) and UMAP (reduction) ready. PlotPairSmoothed(scpairs_testdata, gene1 = "GENE3", gene2 = "GENE4")
For spatial transcriptomics data, visualises the spatial distribution of two genes and their co-expression product on the tissue. Three panels are shown side by side:
Expression of gene 1.
Expression of gene 2.
Co-expression product (gene1 * gene2), highlighting spots where both genes are simultaneously active.
PlotPairSpatial( object, gene1, gene2, assay = NULL, slot = "data", pt_size = 1.2, alpha = 0.8, title = NULL )PlotPairSpatial( object, gene1, gene2, assay = NULL, slot = "data", pt_size = 1.2, alpha = 0.8, title = NULL )
object |
A Seurat object with spatial coordinates. |
gene1 |
Character; first gene. |
gene2 |
Character; second gene. |
assay |
Character; assay. |
slot |
Character; data slot. |
pt_size |
Numeric; point size. |
alpha |
Numeric; point alpha. |
title |
Character; overall title. |
A combined ggplot (patchwork) with three panels: spatial
expression of gene1, spatial expression of gene2, and their
co-expression product, overlaid on physical tissue coordinates.
PlotPairDimplot for UMAP-based display,
FindAllPairs which automatically computes spatial metrics
when a spatial modality is detected.
Other Section_2_Visualization:
PlotBridgeNetwork(),
PlotPairCrossType(),
PlotPairDimplot(),
PlotPairHeatmap(),
PlotPairNetwork(),
PlotPairScatter(),
PlotPairSmoothed(),
PlotPairSummary(),
PlotPairSynergy(),
PlotPairViolin()
## Not run: # Requires a Seurat object with spatial assay (e.g. Visium, MERFISH) PlotPairSpatial(spatial_obj, gene1 = "CD8A", gene2 = "CD8B") ## End(Not run)## Not run: # Requires a Seurat object with spatial assay (e.g. Visium, MERFISH) PlotPairSpatial(spatial_obj, gene1 = "CD8A", gene2 = "CD8B") ## End(Not run)
A multi-panel publication-ready figure combining:
Raw UMAP co-expression (3 panels)
KNN-smoothed UMAP (3 panels)
Per-cluster expression comparison
Metric radar/bar chart
PlotPairSummary( object, gene1, gene2, result = NULL, reduction = "umap", smooth_reduction = "pca", k = 20, alpha = 0.3, assay = NULL, slot = "data", pt_size = 0.3 )PlotPairSummary( object, gene1, gene2, result = NULL, reduction = "umap", smooth_reduction = "pca", k = 20, alpha = 0.3, assay = NULL, slot = "data", pt_size = 0.3 )
object |
A Seurat object. |
gene1 |
Character; first gene. |
gene2 |
Character; second gene. |
result |
Optional |
reduction |
Character; reduction for plotting. |
smooth_reduction |
Character; reduction for KNN graph. |
k |
Integer; KNN k for smoothing. |
alpha |
Numeric; smoothing alpha. |
assay |
Character; assay. |
slot |
Character; data slot. |
pt_size |
Numeric; point size. |
A combined ggplot (patchwork) with up to 10 panels:
raw UMAP co-expression (3 panels), KNN-smoothed UMAP (3 panels),
per-cluster expression bar chart, and metric evidence bar chart.
PlotPairSmoothed, AssessGenePair.
Other Section_2_Visualization:
PlotBridgeNetwork(),
PlotPairCrossType(),
PlotPairDimplot(),
PlotPairHeatmap(),
PlotPairNetwork(),
PlotPairScatter(),
PlotPairSmoothed(),
PlotPairSpatial(),
PlotPairSynergy(),
PlotPairViolin()
PlotPairSummary(scpairs_testdata, gene1 = "GENE3", gene2 = "GENE4")PlotPairSummary(scpairs_testdata, gene1 = "GENE3", gene2 = "GENE4")
Publication-ready multi-panel visualization that integrates prior knowledge, expression evidence, and neighbourhood context to show the synergistic relationship between two genes. This goes beyond co-expression to reveal why two genes may be functionally synergistic.
PlotPairSynergy( object, gene1, gene2, prior_net = NULL, organism = "mouse", reduction = "umap", smooth_reduction = "pca", k = 20, alpha = 0.3, cluster_col = NULL, assay = NULL, slot = "data", top_bridges = 10, pt_size = 0.3 )PlotPairSynergy( object, gene1, gene2, prior_net = NULL, organism = "mouse", reduction = "umap", smooth_reduction = "pca", k = 20, alpha = 0.3, cluster_col = NULL, assay = NULL, slot = "data", top_bridges = 10, pt_size = 0.3 )
object |
A Seurat object. |
gene1 |
Character; first gene. |
gene2 |
Character; second gene. |
prior_net |
Optional prior network from |
organism |
Character; "mouse" or "human". Used if prior_net is NULL. |
reduction |
Character; reduction for UMAP plotting. |
smooth_reduction |
Character; reduction for KNN. |
k |
Integer; KNN k. |
alpha |
Numeric; smoothing alpha. |
cluster_col |
Character; cluster column in meta.data. |
assay |
Character; assay. |
slot |
Character; data slot. |
top_bridges |
Integer; maximum bridge genes to show. |
pt_size |
Numeric; point size. |
A combined ggplot (patchwork) with up to 4 panels:
UMAP coloured by per-cell neighbourhood synergy score.
Bridge gene network showing shared GO/KEGG pathway intermediaries.
Per-cluster expression bar chart for both genes.
Multi-evidence metric comparison bar chart (expression + prior).
Falls back gracefully when prior knowledge is unavailable (panels 2 and 4 are omitted).
PlotBridgeNetwork for a standalone bridge gene
network, AssessGenePair for the underlying metrics.
Other Section_2_Visualization:
PlotBridgeNetwork(),
PlotPairCrossType(),
PlotPairDimplot(),
PlotPairHeatmap(),
PlotPairNetwork(),
PlotPairScatter(),
PlotPairSmoothed(),
PlotPairSpatial(),
PlotPairSummary(),
PlotPairViolin()
## Not run: # Requires Bioconductor annotation packages: org.Hs.eg.db or org.Mm.eg.db # and AnnotationDbi. PlotPairSynergy(scpairs_testdata, gene1 = "GENE3", gene2 = "GENE4", organism = "human") ## End(Not run)## Not run: # Requires Bioconductor annotation packages: org.Hs.eg.db or org.Mm.eg.db # and AnnotationDbi. PlotPairSynergy(scpairs_testdata, gene1 = "GENE3", gene2 = "GENE4", organism = "human") ## End(Not run)
Displays side-by-side violin plots of two genes across cell clusters or groups, enabling visual assessment of whether their expression patterns are coordinated across populations.
PlotPairViolin( object, gene1, gene2, group_by = NULL, assay = NULL, slot = "data", pt_size = 0, title = NULL )PlotPairViolin( object, gene1, gene2, group_by = NULL, assay = NULL, slot = "data", pt_size = 0, title = NULL )
object |
Seurat object. |
gene1 |
Character; first gene. |
gene2 |
Character; second gene. |
group_by |
Character; column in meta.data for grouping. NULL = Idents. |
assay |
Character; assay. |
slot |
Character; data slot. |
pt_size |
Point size for jitter (0 = no points). |
title |
Character. |
A ggplot with violin (and optional jitter) panels for
gene1, gene2, and their expression product, split by group.
PlotPairScatter, PlotPairDimplot.
Other Section_2_Visualization:
PlotBridgeNetwork(),
PlotPairCrossType(),
PlotPairDimplot(),
PlotPairHeatmap(),
PlotPairNetwork(),
PlotPairScatter(),
PlotPairSmoothed(),
PlotPairSpatial(),
PlotPairSummary(),
PlotPairSynergy()
PlotPairViolin(scpairs_testdata, "GENE3", "GENE4", group_by = "seurat_clusters")PlotPairViolin(scpairs_testdata, "GENE3", "GENE4", group_by = "seurat_clusters")
Print method for scPairs_gene_result
## S3 method for class 'scPairs_gene_result' print(x, ...)## S3 method for class 'scPairs_gene_result' print(x, ...)
x |
An scPairs_gene_result object. |
... |
Ignored. |
The input object x, returned invisibly.
Print method for scPairs_pair_result
## S3 method for class 'scPairs_pair_result' print(x, ...)## S3 method for class 'scPairs_pair_result' print(x, ...)
x |
An scPairs_pair_result object. |
... |
Ignored. |
The input object x, returned invisibly.
Print method for scPairs_result
## S3 method for class 'scPairs_result' print(x, ...)## S3 method for class 'scPairs_result' print(x, ...)
x |
An scPairs_result object. |
... |
Ignored. |
The input object x, returned invisibly.
A minimal synthetic Seurat object with deliberately injected co-expression patterns, intended for use in package examples and unit tests. The object ships with normalised expression, variable-feature selection, scaled data, a 5-component PCA, and a 2-D UMAP embedding, so it can be passed directly to every scPairs discovery and visualisation function without any additional setup.
data(scpairs_testdata)data(scpairs_testdata)
A Seurat object with:
counts: raw integer count matrix (20 genes x 100 cells).
data: log-normalised expression matrix.
scale.data: z-score-scaled matrix for all variable features.
pca: 5-component principal-component embedding.
umap: 2-D UMAP embedding derived from the top 5 PCs.
seurat_clusters: factor with three balanced cluster
labels ("1", "2", "3").
GENE1–GENE20 (synthetic gene identifiers).
CELL001–CELL100.
Two co-expression patterns are injected at data-generation time:
GENE3 & GENE4 – strongly correlated across all 100 cells (Pearson r approximately 0.89 in the normalised data). These are the recommended genes for discovery and assessment examples.
GENE1 & GENE2 – moderately correlated within cluster 1 only (cluster-specific pattern).
All remaining gene pairs are near-independent noise.
The data are generated with a fixed random seed (set.seed(7391))
so the object is fully reproducible. The generation script is provided
in data-raw/make_testdata.R.
Generated by data-raw/make_testdata.R with
set.seed(7391).
FindAllPairs, FindGenePairs,
AssessGenePair
# Load and inspect the object data(scpairs_testdata) scpairs_testdata # Verify the injected GENE3 / GENE4 co-expression norm <- SeuratObject::LayerData(scpairs_testdata, layer = "data") cor(as.numeric(norm["GENE3", ]), as.numeric(norm["GENE4", ]))# Load and inspect the object data(scpairs_testdata) scpairs_testdata # Verify the injected GENE3 / GENE4 co-expression norm <- SeuratObject::LayerData(scpairs_testdata, layer = "data") cor(as.numeric(norm["GENE3", ]), as.numeric(norm["GENE4", ]))