Package 'Connectome'

Title: Single Cell Connectomics
Description: A toolkit for exploring cell-cell connectivity patterns based on ligand and receptor expression in heterogeneous single-cell datasets. Implements methods for constructing, filtering, and visualizing connectomic networks from single-cell RNA sequencing data. Supports multiple species via the FANTOM5 ligand-receptor database. Methods described in Raredon et al (2022) <doi:10.1038/s41598-022-07959-x>.
Authors: Zaoqu Liu [aut, cre] (ORCID: <https://orcid.org/0000-0002-0452-742X>), Micha Sam Brickman Raredon [aut] (Original author)
Maintainer: Zaoqu Liu <[email protected]>
License: GPL-3 + file LICENSE
Version: 1.0.2
Built: 2026-05-23 08:38:14 UTC
Source: https://github.com/Zaoqu-Liu/Connectome

Help Index


CellCellScatter

Description

Scatter plot of a single cell-cell vector, involving features of interest. Returns a ggplot object, colored by mechanism. Points are labeled if above label.threshold on both x- and y-axes.

Usage

CellCellScatter(
  connectome,
  sources.include,
  targets.include,
  label.threshold = 1,
  weight.attribute = "weight_sc",
  ...
)

Arguments

connectome

A connectomic edgelist

sources.include

Source nodes of interest. Output will be limited to edges coming from these sources.

targets.include

Target nodes of interest. Output will be limited to edges landing on these targets.

label.threshold

Threshold for labeling of plot, applied to both x- and y- axes. Defaults to 1.

weight.attribute

Column to use to define edgeweights for network analysis. 'weight_sc or weight_norm'. Defaults to 'weight_sc'

...

Arguments passed to FilterConnectome


Centrality

Description

This function takes a connectomic edgelist and creates a source and a sink mode- and cell- organized dot plot. The y-axis is the discrete variable 'mode', and the x-axis is the sum of the weights of all edges for each mode made by each cell. Points are organized by cell type, with the size of the point correlating to the Kleinberg hub score (for source graph) and Kleinberg authority score (for sink graph). Network filtration is performed prior to network centrality calculations.

Usage

Centrality(
  connectome,
  cols.use = NULL,
  weight.attribute = "weight_sc",
  min.z = NULL,
  normalize = TRUE,
  group.by = "mode",
  ...
)

Arguments

connectome

A connectomic edgelist

cols.use

Desired colors for cell types, alphabetized. Defaults to standard ggplot colors.

weight.attribute

Column to use to define edgeweights for network analysis. 'weight_sc' or 'weight_norm'. Defaults to 'weight_sc'

min.z

Minimum z-score for ligand and receptor.

normalize

Default TRUE. Scales each mode to have equivalent x-axes.

group.by

Default 'mode'. Determines how to subdivide network for centrality analysis. Accepts 'mode','ligand','receptor', 'gene', or 'mechanism'.

...

Arguments passed to FilterConnectome

Value

A ggplot object showing centrality analysis


CircosDiff

Description

Currently in beta testing. A Circos Plot for a differential edgelist made using DifferentialConnectome. Note that negative log fold changes cannot be plotted; therefore, this plot uses the 'score' for the differential comparison, which is always positive in proportion to perturbation.

Usage

CircosDiff(
  differential.connectome,
  features = NULL,
  sources.include = NULL,
  targets.include = NULL,
  min.score = NULL,
  min.pct = NULL,
  verbose = TRUE,
  infinity.to.max = TRUE,
  edge.color.by.source = TRUE,
  cols.use = NULL,
  lab.cex = 1,
  title = NULL,
  small.gap = 1,
  big.gap = 10
)

Arguments

differential.connectome

A differential connectome, made with DifferentialConnectome. May be filtered as desired prior to plotting.

features

Gene of interest. Output will be limited to edges including these specific genes.

sources.include

Source nodes of interest. Output will be limited to edges coming from these sources.

targets.include

Target nodes of interest. Output will be limited to edges landing on these targets.

min.score

Default NULL. Will limit output to edges with a differential score greater than this value.

min.pct

Default NULL. Threshold to return clusterwise observations for both ligand and receptor. Only needs to be satisfied in connect.1 OR in connect.2.

verbose

Whether to output feedback to user

infinity.to.max

Default TRUE. If TRUE, will create a pseudo value to replace values of "Inf"

edge.color.by.source

Default TRUE - edges will be colored by their source cell type. If false, edges will be colored by receiving cell instead.

cols.use

Optional. Colors for plotting nodes.

lab.cex

Text size for gene names

title

Character string for title of plot.

small.gap

Default 1. Amount of distance between sectors. If the number of edges is very large, this will have to be reduced in size.

big.gap

Default 10. Amount of distance between the source cells and the target cells (top and bottom arc of graph). If the number of edges is very large, this can be reduced in size in addition to 'small.gap'


CircosPlot

Description

Plotting function to make Circos plots using the circlize package, following the vignette by the Saeys Lab at: https://github.com/saeyslab/nichenetr/blob/master/vignettes/circos.md Note that this plotting type is incompatible with edges where the ligand and the receptor are the exact same gene.

Usage

CircosPlot(
  connectome,
  weight.attribute = "weight_sc",
  cols.use = NULL,
  min.z = NULL,
  lab.cex = 1,
  balanced.edges = TRUE,
  edge.color.by.source = TRUE,
  small.gap = 1,
  big.gap = 10,
  title = NULL,
  ...
)

Arguments

connectome

A connectomic object, ideally filtered to only edges of interest.

weight.attribute

Column to use to define edgeweights for network analysis. 'weight_sc' or 'weight_norm'. Defaults to 'weight_sc'. If 'weight_sc', function will automatically filter at min.z = 0 to remove negative source/sink values.

cols.use

Optional. Colors for plotting nodes.

min.z

Minimum z-score for ligand and receptor.

lab.cex

Text size for gene names

balanced.edges

Edges in this plot can change thickness along their length. This parameter decides whether to scale edges by a single edgeweight (chosen in weight.attribute) or by the separate cell-specific ligand and receptor values. Default balanced (TRUE). If FALSE, the edges will expand or contract to join ligand weight to receptor weight.

edge.color.by.source

Default TRUE - edges will be colored by their source cell type. If false, edges will be colored by receiving cell instead.

small.gap

Default 1. Amount of distance between sectors. If the number of edges is very large, this will have to be reduced in size.

big.gap

Default 10. Amount of distance between the source cells and the target cells (top and bottom arc of graph). If the number of edges is very large, this can be reduced in size in addition to 'small.gap'

title

Character string for title of plot.

...

Arguments passed to FilterConnectome


CompareCentrality

Description

Takes a list of connectomes and will compare sending- and receiving- centrality, side-by-side, for the given networks, or requested network subsets.

Usage

CompareCentrality(
  connectome.list,
  weight.attribute = "weight_norm",
  min.z = NULL,
  cols.use = NULL,
  normalize = TRUE,
  ...
)

Arguments

connectome.list

A named list of connectomic edgelists. The output plot will be split by the names of the list.

weight.attribute

Column to use to define edgeweights for network analysis. 'weight_sc' or 'weight_norm'. Defaults to 'weight_norm'

min.z

Minimum z-score for ligand and receptor.

cols.use

Desired colors for cell types, alphabetized. Defaults to standard ggplot colors.

normalize

Default TRUE. Scales each mode to have equivalent x-axes.

...

Arguments passed to FilterConnectome. Will be applied to each connectome within the list.

Value

A ggplot object comparing centrality across connectomes


CreateConnectome

Description

Creates a connectomic edgelist from a Seurat object. The connectome represents all possible ligand-receptor interactions between cell populations, weighted by expression levels and statistical significance.

Usage

CreateConnectome(
  object,
  LR.database = "fantom5",
  species = NULL,
  include.putative = TRUE,
  include.rejected = FALSE,
  p.values = TRUE,
  max.cells.per.ident = NULL,
  min.cells.per.ident = NULL,
  weight.definition.norm = "product",
  weight.definition.scale = "mean",
  custom.list = NULL,
  calculate.DOR = FALSE,
  assay = "RNA",
  parallel = FALSE,
  n.cores = NULL,
  ...
)

Arguments

object

A Seurat object with normalized and scaled data

LR.database

Ligand-receptor database to use. Either 'fantom5' (default) or 'custom'. If 'custom', provide a dataframe via custom.list parameter.

species

Species for FANTOM5 database. Required if LR.database = 'fantom5'. Options: 'human', 'mouse', 'rat', or 'pig'

include.putative

Include putative ligand-receptor pairs from FANTOM5. Default TRUE.

include.rejected

Include pairs labeled "EXCLUDED" in FANTOM5. Default FALSE.

p.values

Calculate Wilcoxon Rank Sum test p-values. Default TRUE. Set to FALSE for faster computation when statistical testing is not needed.

max.cells.per.ident

Maximum cells per identity for downsampling. Default NULL (no downsampling). Useful for large datasets.

min.cells.per.ident

Minimum cells required per identity. Default NULL. Clusters below this threshold are excluded from analysis.

weight.definition.norm

Method for edge weight from normalized data. Options: 'sum', 'mean', or 'product' (default).

weight.definition.scale

Method for edge weight from scaled data. Options: 'sum', 'mean' (default), or 'product'.

custom.list

Dataframe with custom ligand-receptor pairs. Required columns: ligand (col 1), receptor (col 2), mode/category (col 3).

calculate.DOR

Calculate log-normalized Diagnostic Odds Ratio. Default FALSE.

assay

Seurat assay to use. Default 'RNA'. Also accepts 'SCT'.

parallel

Use parallel processing for p-value calculations. Default FALSE.

n.cores

Number of cores for parallel processing. Default: detectCores() - 1

...

Additional arguments passed to internal functions

Details

The function calculates edge weights using the formula specified by weight.definition.norm and weight.definition.scale parameters:

  • 'product': ligand * receptor (captures co-expression)

  • 'sum': ligand + receptor (additive contribution)

  • 'mean': (ligand + receptor) / 2 (average contribution)

Value

A data.frame containing the connectomic edgelist with columns: source, target, ligand, receptor, pair, mode, expression values, z-scores, percent expressing, edge weights, and optionally p-values and DOR.

Examples

## Not run: 
# Basic usage
connectome <- CreateConnectome(seurat_obj, species = "human")

# Without p-value calculation (faster)
connectome <- CreateConnectome(seurat_obj, species = "human", p.values = FALSE)

# With custom ligand-receptor list
my_lr <- data.frame(ligand = c("IL6", "TNF"), receptor = c("IL6R", "TNFRSF1A"),
                    mode = c("cytokine", "cytokine"))
connectome <- CreateConnectome(seurat_obj, LR.database = "custom", custom.list = my_lr)

## End(Not run)

DiffEdgeDotPlot

Description

Plotting function to make a DotPlot of differential edges for a network comparison. This function first finds all edges meeting the desired thresholding criteria, and then plots complete information regarding all mechanisms and celltype vectors implicated.

Usage

DiffEdgeDotPlot(
  differential.connectome,
  features = NULL,
  sources.include = NULL,
  targets.include = NULL,
  min.score = NULL,
  min.pct = NULL,
  verbose = TRUE,
  infinity.to.max = TRUE,
  ...
)

Arguments

differential.connectome

A differential connectome object

features

Gene of interest. Output will be limited to edges including these specific genes.

sources.include

Source nodes of interest. Output will be limited to edges coming from these sources.

targets.include

Target nodes of interest. Output will be limited to edges landing on these targets.

min.score

Default NULL. Will limit output to edges with a differential score greater than this value.

min.pct

Default NULL. Threshold to return clusterwise observations for both ligand and receptor. Only needs to be satisfied in connect.1 OR in connect.2.

verbose

Whether to output feedback to user

infinity.to.max

Default TRUE. If TRUE, will create a pseudo value to replace values of "Inf"

...

Additional arguments (not currently used)

Value

A ggplot object


DifferentialConnectome

Description

Currently in beta testing. Creates a fold-change connectome from two input connectomes, generally unfiltered. Must be node-aligned, from the same reference mapping, and unfiltered. ('edge' columns must contain identical entries, though not necessarily in the same order.)

Usage

DifferentialConnectome(connect.ref, connect.test, min.pct = NULL)

Arguments

connect.ref

A connectome from a system

connect.test

A connectome from a different system, to be compared to connect.ref

min.pct

Default NULL. Threshold to return clusterwise observations for both ligand and receptor. Only needs to be satisfied in connect.ref OR in connect.test.


DifferentialScoringPlot

Description

Currently in beta testing. Creates x3 aligned heatmaps allowing visualization of ligand, receptor, and perturbation scores for a given cell-system of interest.

Usage

DifferentialScoringPlot(
  differential.connectome,
  features = NULL,
  sources.include = NULL,
  targets.include = NULL,
  min.score = NULL,
  min.pct = NULL,
  verbose = TRUE,
  infinity.to.max = TRUE,
  aligned = FALSE
)

Arguments

differential.connectome

A differential connectome, made with DifferentialConnectome. May be filtered as desired prior to plotting.

features

Gene of interest. Output will be limited to edges including these specific genes.

sources.include

Source nodes of interest. Output will be limited to edges coming from these sources.

targets.include

Target nodes of interest. Output will be limited to edges landing on these targets.

min.score

Default NULL. Will limit output to edges with a differential score greater than this value.

min.pct

Default NULL. Threshold to return clusterwise observations for both ligand and receptor. Only needs to be satisfied in connect.1 OR in connect.2.

verbose

Whether to output feedback to user

infinity.to.max

Default TRUE. If TRUE, will create a pseudo value to replace values of "Inf"

aligned

Default FALSE. If TRUE, will create edge-aligned heatmaps (duplicate rows and columns in first two plots, to dimension map all three plots)


EdgeDotPlot

Description

Plotting function to make a DotPlot of edges within a specified network. This function first finds all edges meeting the desired thresholding criteria, and then plots complete information regarding all mechanisms and celltype vectors implicated.

Usage

EdgeDotPlot(connectome, ...)

Arguments

connectome

A connectomic object

...

Arguments passed to FilterConnectome


EvenSplit

Description

Splits a Seurat object using SplitObject, but makes sure that for each identity, an even number of cells are sampled.

Usage

EvenSplit(object, split.by)

Arguments

object

A Seurat object

split.by

Parameter by which to split the object (e.g., a metadata column name)

Value

A named list of Seurat objects, one for each level of split.by


FilterConnectome

Description

Filters a connectomic edgelist output from CreateConnectome according to user inputs. Defaults are set to reasonable initial parameters for data clean-up and exploration.

Usage

FilterConnectome(
  connectome,
  min.pct = NULL,
  max.p = NULL,
  min.DOR = NULL,
  min.exp = NULL,
  min.z = NULL,
  modes.include = NULL,
  sources.include = NULL,
  targets.include = NULL,
  mechanisms.include = NULL,
  features = NULL,
  verbose = TRUE,
  remove.na = FALSE
)

Arguments

connectome

A connectomic edgelist output from CreateConnectome

min.pct

Minimum fraction of cells within a given cluster expressing the ligand or receptor.

max.p

Maximum p-value for ligand and receptor. Filtration on this column requires prior p-value calculation.

min.DOR

Minimum log-normalized Diagnostic Odds Ratio for the ligand or receptor for its cell type within an edge.

min.exp

Minimum normalized expression level of ligand and receptor.

min.z

Minimum z-score for ligand and receptor.

modes.include

String or vector signifying mode(s) of interest in include.

sources.include

Source nodes of interest. Output will be limited to edges coming from these sources.

targets.include

Target nodes of interest. Output will be limited to edges landing on these targets.

mechanisms.include

Ligand - Receptor pairs of interest. The character string should match entries in the 'pair' column of the connectome.

features

Genes of interest. Output will be limited to edges including these specific genes (as ligand or receptor).

verbose

Whether to output feedback to user

remove.na

Whether to remove edges containing 'NA' (no mapping to original object - only useful if investigating orphan ligands and receptors)

Value

A filtered connectome data.frame


ModalDotPlot

Description

This function takes a connectomic edgelist and creates a source and a sink mode- and cell- organized dot plot. The y-axis is the discrete variable 'mode', and the x-axis is the sum of the weights of all edges for each mode made by each cell. Points are organized by cell type, with the size of the point correlating to the Kleinberg hub score (for source graph) and Kleinberg authority score (for sink graph). Network filtration is performed prior to network centrality calculations.

Usage

ModalDotPlot(
  connectome,
  cols.use = NULL,
  weight.attribute = "weight_sc",
  min.z = NULL,
  normalize = TRUE,
  ...
)

Arguments

connectome

A connectomic edgelist

cols.use

Desired colors for cell types, alphabetized. Defaults to standard ggplot colors.

weight.attribute

Column to use to define edgeweights for network analysis. 'weight_sc' or 'weight_norm'. Defaults to 'weight_sc'

min.z

Minimum z-score for ligand and receptor.

normalize

Default TRUE. Scales each mode to have equivalent x-axes.

...

Arguments passed to FilterConnectome

Value

A ggplot object showing modal centrality analysis


FANTOM5 Ligand-Receptor Database (Original)

Description

The original FANTOM5 ligand-receptor database before species conversion.

Usage

ncomms8866

Format

A data frame with the original ligand-receptor pairs from FANTOM5.

Source

Ramilowski, J.A. et al. Nat Commun 6, 7866 (2015). doi:10.1038/ncomms8866


FANTOM5 Ligand-Receptor Database (Human)

Description

A dataset containing ligand-receptor pairs curated from the FANTOM5 project, converted to human gene symbols.

Usage

ncomms8866_human

Format

A data frame with 2557 rows and 17 columns:

Pair.Name

Unique identifier for the ligand-receptor pair

Ligand.ApprovedSymbol

HGNC approved symbol for the ligand

Ligand.Name

Full name of the ligand

Receptor.ApprovedSymbol

HGNC approved symbol for the receptor

Receptor.Name

Full name of the receptor

DLRP

DLRP database reference

HPMR

HPMR database reference

IUPHAR

IUPHAR database reference

HPRD

HPRD database reference

STRING.binding

STRING binding evidence

STRING.experiment

STRING experimental evidence

HPMR.Ligand

HPMR ligand identifier

HPMR.Receptor

HPMR receptor identifier

PMID.Manual

PubMed ID for manual curation

Pair.Source

Source classification: "known" or "novel"

Pair.Evidence

Evidence level: "literature supported" or "putative"

mode

Signaling mode/category of the interaction

Source

Ramilowski, J.A. et al. A draft network of ligand-receptor-mediated multicellular signalling in human. Nat Commun 6, 7866 (2015). doi:10.1038/ncomms8866

See Also

ncomms8866_mouse, ncomms8866_rat, ncomms8866_pig


FANTOM5 Ligand-Receptor Database (Mouse)

Description

A dataset containing ligand-receptor pairs from the FANTOM5 project, converted to mouse gene symbols using ortholog mapping.

Usage

ncomms8866_mouse

Format

A data frame with ligand-receptor pairs. See ncomms8866_human for column descriptions.

Source

Ramilowski, J.A. et al. Nat Commun 6, 7866 (2015). doi:10.1038/ncomms8866

See Also

ncomms8866_human


FANTOM5 Ligand-Receptor Database (Pig)

Description

A dataset containing ligand-receptor pairs from the FANTOM5 project, converted to pig gene symbols using ortholog mapping.

Usage

ncomms8866_pig

Format

A data frame with ligand-receptor pairs. See ncomms8866_human for column descriptions.

Source

Ramilowski, J.A. et al. Nat Commun 6, 7866 (2015). doi:10.1038/ncomms8866

See Also

ncomms8866_human


FANTOM5 Ligand-Receptor Database (Rat)

Description

A dataset containing ligand-receptor pairs from the FANTOM5 project, converted to rat gene symbols using ortholog mapping.

Usage

ncomms8866_rat

Format

A data frame with ligand-receptor pairs. See ncomms8866_human for column descriptions.

Source

Ramilowski, J.A. et al. Nat Commun 6, 7866 (2015). doi:10.1038/ncomms8866

See Also

ncomms8866_human


NetworkPlot

Description

Creates a network plot of a connectomic object. Wrapper for igraph functionality.

Usage

NetworkPlot(
  connectome,
  weight.attribute = "weight_sc",
  title = NULL,
  cols.use = NULL,
  include.all.nodes = FALSE,
  min.z = NULL,
  mar = 1.5,
  layout = "circle",
  edge.label.cex = 0.4,
  ...
)

Arguments

connectome

A connectomic object, ideally filtered to only edges of interest.

weight.attribute

Column to use to define edgeweights for network analysis. 'weight_sc' or 'weight_norm'. Defaults to 'weight_sc'

title

Description of the network being plotted

cols.use

Optional. Colors for plotting nodes.

include.all.nodes

If TRUE, include all nodes from original connectome even after filtering. Default FALSE.

min.z

Minimum z-score for ligand and receptor.

mar

Default 1.5. Symmetric margin around plot.

layout

Layout algorithm. Either "circle" (default) or "force.directed".

edge.label.cex

Text size for edge labels. Default 0.4.

...

Arguments passed to FilterConnectome

Value

A recorded plot object


SignalScatter

Description

Scatter plot of signaling vectors involving features of interest. Returns a ggplot object, colored by mechanism, labeled by cell-cell vector.

Usage

SignalScatter(
  connectome,
  features,
  label.threshold = 1,
  weight.attribute = "weight_sc",
  ...
)

Arguments

connectome

A connectomic edgelist

features

Features of interest

label.threshold

Threshold for labeling of plot. Sum of receptor score and ligand score must be greater than this number.

weight.attribute

Column to use to define edgeweights for network analysis. 'weight_sc or weight_norm'. Defaults to 'weight_sc'

...

Arguments passed to FilterConnectome


SingleCellConnectome

Description

Takes a Seurat object and creates a single-cell connectome (rows are ligand-receptor mechanisms and columns are cell-cell vectors)

Usage

SingleCellConnectome(
  object,
  LR.database = "fantom5",
  species = NULL,
  include.putative = TRUE,
  include.rejected = FALSE,
  max.cells.per.ident = NULL,
  min.cells.per.ident = NULL,
  slot.use = "data",
  weight.definition = "product",
  custom.list = NULL,
  assay = "RNA",
  ...
)

Arguments

object

A Seurat object

LR.database

Accepts either 'fantom5' or 'custom'. If custom, a dataframe must be provided to argument custom.list with the first column equal to ligands, second column equal to associated receptors, and third column equal to desired modal categorizations.

species

The species of the object that is being processed. Only required if LR.database = 'fantom5', and allows 'human','mouse','rat', or 'pig'

include.putative

Default TRUE. Includes ligand-receptor pairs deemed putative in FANTOM5 database.

include.rejected

Default FALSE. If TRUE, includes gene pairs labeled "EXCLUDED" in FANTOM5 database.

max.cells.per.ident

Default NULL. If a value is input, input object will be downsampled to requested number of cells per identity.

min.cells.per.ident

Default NULL. If a value is input, only cell populations meeting this threshold will be included in network analysis.

slot.use

Which data slot to use. Default "data".

weight.definition

Method for combining ligand and receptor values. Options: "product" (default), "sum", "mean".

custom.list

Optional. A dataframe for custom mapping, with the first column equal to ligands, second column equal to associated receptors, and third column equal to desired modal categorizations.

assay

Assay to use. Default "RNA".

...

Additional arguments (not currently used)

Value

A sparse matrix with ligand-receptor pairs as rows and cell-cell combinations as columns