| Title: | Spatial Projection of Network Signals along Geodesic Paths |
|---|---|
| Description: | For a given graph containing vertices, edges, and a signal associated with the vertices, the 'PathwaySpace' package performs a convolution operation, which involves a weighted combination of neighboring vertices and their associated signals. The package uses a decay function to project these signals, creating geodesic paths on a 2D-image space. 'PathwaySpace' has various applications, such as visualizing network data in a graphical format that highlights the relationships and signal strengths between vertices. By combining graph theory, signal processing, and visualization, 'PathwaySpace' provides a way of representing graph data on a continuous projection space. Based on methods introduced in Tercan et al. (2025) <doi:10.1016/j.xpro.2025.103681> and Ellrott et al. (2025) <doi:10.1016/j.ccell.2024.12.002>. |
| Authors: | Sysbiolab Team [aut], Victor Apolonio [ctb], Jonathan Back [ctb], Lana Querne [ctb], Vinicius Chagas [ctb], Bahar Tercan [ctb], Mauro Castro [cre] (ORCID: <https://orcid.org/0000-0003-4942-8131>) |
| Maintainer: | Mauro Castro <[email protected]> |
| License: | Artistic-2.0 |
| Version: | 1.3.0 |
| Built: | 2026-05-24 16:06:49 UTC |
| Source: | https://github.com/sysbiolab/pathwayspace |
buildPathwaySpace is a constructor of
PathwaySpace-class objects.
buildPathwaySpace(gs, nrc = 500, verbose = TRUE, g = deprecated())buildPathwaySpace(gs, nrc = 500, verbose = TRUE, g = deprecated())
gs |
A |
nrc |
A single positive integer indicating the number of rows and columns (in pixels) for a square image matrix. This argument will affect the resulting image size and resolution. |
verbose |
A logical value specifying to display detailed
messages (when |
g |
Deprecated from PathwaySpace 1.0.1; use 'gs' instead. |
A pre-processed PathwaySpace class object.
Sysbiolab Team
# Load a demo igraph data('gtoy1', package = 'RGraphSpace') # Check graph validity gs <- GraphSpace(gtoy1) gs <- normalizeGraphSpace(gs) # Create a new PathwaySpace object ps <- buildPathwaySpace(gs, nrc = 100) # note: adjust 'nrc' to increase image resolution# Load a demo igraph data('gtoy1', package = 'RGraphSpace') # Check graph validity gs <- GraphSpace(gtoy1) gs <- normalizeGraphSpace(gs) # Create a new PathwaySpace object ps <- buildPathwaySpace(gs, nrc = 100) # note: adjust 'nrc' to increase image resolution
A data frame listing 'GeneSymbol' and 'Entrez' IDs from the COSMIC-CGC database (Sondka et al., 2020). These genes are used to demonstrate the PathwaySpace's summit mapping pipeline, which assigns summits to an image space.
data(CGC_20211118)data(CGC_20211118)
data.frame
A data.frame object.
COSMIC-CGC database (release v95, tier 1 collection).
Sondka et al. The COSMIC Cancer Gene Census: describing genetic dysfunction across all human cancers. Nat Rev Cancer 18, 696-705, 2018. Doi: 10.1038/s41568-018-0060-1.
data(CGC_20211118)data(CGC_20211118)
circularProjection implements a convolution
algorithm to project signals onto a 2D-coordinate system.
## S4 method for signature 'PathwaySpace' circularProjection( ps, k = 8, decay.fun = weibullDecay(), aggregate.fun = signalAggregation(), rescale = TRUE, verbose = TRUE, pdist = deprecated() )## S4 method for signature 'PathwaySpace' circularProjection( ps, k = 8, decay.fun = weibullDecay(), aggregate.fun = signalAggregation(), rescale = TRUE, verbose = TRUE, pdist = deprecated() )
ps |
A PathwaySpace class object. |
k |
A single positive integer determining the k-top signals for the convolution operation. |
decay.fun |
A signal decay function. Available options include
'Weibull', 'exponential', and 'linear' (see |
aggregate.fun |
A function used to aggregate the projected signals.
It must be provided as a unary function, e.g., |
rescale |
A logical value indicating whether to rescale
the signal. If the signal |
verbose |
A logical value specifying to display detailed
messages (when |
pdist |
Deprecated as of PathwaySpace 1.0.2; this parameter is now
passed internally through |
A preprocessed PathwaySpace class object.
Sysbiolab Team
buildPathwaySpace, weibullDecay,
expDecay, linearDecay
# Load a demo igraph data('gtoy1', package = 'RGraphSpace') # Create a new PathwaySpace object ps <- buildPathwaySpace(gtoy1, nrc = 100) # note: adjust 'nrc' to increase image resolution # Set '1s' as vertex signal vertexSignal(ps) <- 1 # Create a 2D-landscape image ps <- circularProjection(ps)# Load a demo igraph data('gtoy1', package = 'RGraphSpace') # Create a new PathwaySpace object ps <- buildPathwaySpace(gtoy1, nrc = 100) # note: adjust 'nrc' to increase image resolution # Set '1s' as vertex signal vertexSignal(ps) <- 1 # Create a 2D-landscape image ps <- circularProjection(ps)
The expDecay() constructor either creates a decay function or
returns a ggplot object for visualizing the decay model. It is a utility
function used internally by circularProjection and
polarProjection.
expDecay(decay = 0.001, pdist = 0.15, plot = FALSE, demo.signal = 1)expDecay(decay = 0.001, pdist = 0.15, plot = FALSE, demo.signal = 1)
decay |
A decay factor (in |
pdist |
A distance normalization term (in (0, 1]) at which the signal
reaches |
plot |
A logical value indicating whether to return a |
demo.signal |
A numeric value in |
The expDecay() constructor creates an exponential decay model. It describes
how a signal decreases as a function of distance, controlled by a decay
rate parameter.
The decay function is defined as:
where represents the initial intensity, controls
the rate of attenuation, and is a vector of normalized distances.
The parameter anchors the model such that:
when
when
Returns either a function of the form
function(x, signal) { ... } or, if plot = TRUE, a ggplot
object illustrating the decay model.
Sysbiolab Team
# Return a decay function decay_fun <- expDecay(decay = 0.25, pdist = 0.5) # Plot decay model parameters # expDecay(decay = 0.25, pdist = 0.5, plot = TRUE)# Return a decay function decay_fun <- expDecay(decay = 0.25, pdist = 0.5) # Plot decay model parameters # expDecay(decay = 0.25, pdist = 0.5, plot = TRUE)
Retrieves the nearest neighbor for each node from a PathwaySpace object using Euclidean distance.
getNearestNode(ps)getNearestNode(ps)
ps |
Either a PathwaySpace or GraphSpace object. |
# See examples in the PathwaySpace's tutorials: # https://sysbiolab.github.io/PathwaySpace/# See examples in the PathwaySpace's tutorials: # https://sysbiolab.github.io/PathwaySpace/
getPathwaySpace retrives information from
individual slots available in a PathwaySpace object.
## S4 method for signature 'PathwaySpace' getPathwaySpace(ps, what = "status")## S4 method for signature 'PathwaySpace' getPathwaySpace(ps, what = "status")
ps |
A preprocessed PathwaySpace class object |
what |
A character value specifying which information should be retrieved from the slots. Options: "nodes", "edges", "graph", "image", "pars", "misc", "signal","projections", "status", "silhouette", "summits", "summit_mask", "summit_contour" |
Content from slots in the PathwaySpace object.
# Load a demo igraph data('gtoy1', package = 'RGraphSpace') # Create a new PathwaySpace object ps <- buildPathwaySpace(gtoy1, nrc = 100) # note: adjust 'nrc' to increase image resolution # Get the 'status' slot in ps status <- getPathwaySpace(ps, what = 'status')# Load a demo igraph data('gtoy1', package = 'RGraphSpace') # Create a new PathwaySpace object ps <- buildPathwaySpace(gtoy1, nrc = 100) # note: adjust 'nrc' to increase image resolution # Get the 'status' slot in ps status <- getPathwaySpace(ps, what = 'status')
An image matrix used for workflow demonstrations.
data(gimage)data(gimage)
matrix
An image matrix.
This package.
data(gimage)data(gimage)
Get or set edge and vertex attributes in PathwaySpace class object.
## S4 replacement method for signature 'PathwaySpace' gs_vertex_attr(x, name, ...) <- value ## S4 replacement method for signature 'PathwaySpace' gs_edge_attr(x, name, ...) <- value## S4 replacement method for signature 'PathwaySpace' gs_vertex_attr(x, name, ...) <- value ## S4 replacement method for signature 'PathwaySpace' gs_edge_attr(x, name, ...) <- value
x |
A PathwaySpace class object. |
name |
Name of the attribute. |
... |
Additional arguments passed to igraph methods. |
value |
The new value of the attribute. |
Updated PathwaySpace object.
data('gtoy1', package = 'RGraphSpace') ps <- buildPathwaySpace(gtoy1, nrc = 100) # Get vertex count gs_vcount(ps) # Get edge count gs_ecount(ps) # Access a specific vertex attribute gs_vertex_attr(ps, "signal") # Replace an entire vertex attribute gs_vertex_attr(ps, "signal") <- 1 # Modify a single value within a vertex attribute gs_vertex_attr(ps, "signal")["n1"] <- 1 # Access a specific edge attribute gs_edge_attr(ps, "weight") # Replace an entire edge attribute gs_edge_attr(ps, "weight") <- 1data('gtoy1', package = 'RGraphSpace') ps <- buildPathwaySpace(gtoy1, nrc = 100) # Get vertex count gs_vcount(ps) # Get edge count gs_ecount(ps) # Access a specific vertex attribute gs_vertex_attr(ps, "signal") # Replace an entire vertex attribute gs_vertex_attr(ps, "signal") <- 1 # Modify a single value within a vertex attribute gs_vertex_attr(ps, "signal")["n1"] <- 1 # Access a specific edge attribute gs_edge_attr(ps, "weight") # Replace an entire edge attribute gs_edge_attr(ps, "weight") <- 1
A list with Human gene symbols from the MSigDB's Hallmark gene set collection (Liberzon et al., 2015). These gene sets are used to demonstrate the PathwaySpace's summit mapping pipeline, which assigns summits to an image space.
data(Hallmarks_v2023_1_Hs_symbols)data(Hallmarks_v2023_1_Hs_symbols)
list
A list object.
MSigDB database (v2023.1).
Liberzon et al. The Molecular Signatures Database (MSigDB) hallmark gene set collection. Cell Systems 1(5):417-425, 2015 Doi: 10.1016/j.cels.2015.12.004
data(Hallmarks_v2023_1_Hs_symbols)data(Hallmarks_v2023_1_Hs_symbols)
The linearDecay() constructor either creates a decay function or
returns a ggplot object for visualizing the decay model. It is a utility
function used internally by circularProjection and
polarProjection.
linearDecay(decay = 0.001, pdist = 0.15, plot = FALSE, demo.signal = 1)linearDecay(decay = 0.001, pdist = 0.15, plot = FALSE, demo.signal = 1)
decay |
A decay factor (in |
pdist |
A distance normalization term (in (0, 1]) at which the signal
reaches |
plot |
A logical value indicating whether to return a |
demo.signal |
A numeric value in |
The linearDecay() constructor creates a simple linear decay model. It
describes how a signal decreases proportionally with distance.
The decay function is defined as:
where represents the initial intensity, defines
the relative signal level at , and is a vector of
normalized distances. The signal decreases uniformly from its initial
value to , which is a reference distance that anchors
the model such that:
when
when
This makes the linear form consistent with the exponential and Weibull decay
functions, both of which also reach at the
reference distance.
Returns either a function of the form
function(x, signal) { ... } or, if plot = TRUE, a ggplot
object illustrating the decay model.
Sysbiolab Team
# Return a decay function decay_fun <- linearDecay(decay = 0.5, pdist = 0.25) # Plot decay model parameters # linearDecay(decay = 0.5, pdist = 0.25, plot = TRUE)# Return a decay function decay_fun <- linearDecay(decay = 0.5, pdist = 0.25) # Plot decay model parameters # linearDecay(decay = 0.5, pdist = 0.25, plot = TRUE)
Calculate a pathway space distance between two vectors
pathDistances(gdist, from, to, nperm = 1000, verbose = TRUE)pathDistances(gdist, from, to, nperm = 1000, verbose = TRUE)
gdist |
A distance matrix computed by the igraph's |
from |
A vector with valid vertex names. |
to |
A vector with valid vertex names. |
nperm |
Number of permutations. |
verbose |
A single logical value specifying to display detailed
messages (when |
A list with pathway space distances and a 'ggplot' object.
# Load a vertex-wise distance matrix (distance between nodes in a graph) data("gdist.toy", package = "PathwaySpace") # Get two vertex lists from <- sample(colnames(gdist.toy), 50) to <- sample(colnames(gdist.toy), 50) # Calculate distances between lists, and between random lists res <- pathDistances(gdist.toy, from, to) names(res) # "p_dist" "z_score"# Load a vertex-wise distance matrix (distance between nodes in a graph) data("gdist.toy", package = "PathwaySpace") # Get two vertex lists from <- sample(colnames(gdist.toy), 50) to <- sample(colnames(gdist.toy), 50) # Calculate distances between lists, and between random lists res <- pathDistances(gdist.toy, from, to) names(res) # "p_dist" "z_score"
PathwaySpace: An S4 class for signal propagation on image spaces
An S4 class object.
nodesA data frame with xy-vertex coordinates.
edgesA data frame with edges.
graphAn igraph object.
imageA raster background image matrix.
parsA list with parameters.
miscA list with intermediate objects for downstream methods.
projectionsA list with processed objects for downstream methods.
statusA vector containing the processing status of the PathwaySpace object.
see buildPathwaySpace constructor.
Sysbiolab Team, Mauro Castro ([email protected])
This igraph object was created from a 'sif' file available from the Pathway Commons V12 (Rodchenkov et al., 2020), which was filtered to keep interactions from the following sources: CTD, Recon, HumanCyc, DrugBank, MSigDB, DIP, BioGRID, IntAct, BIND, and PhosphoSite. The igraph was additionally pruned and laid out by a force-directed algorithm aiming signal projection on PathwaySpace's images. Edges with the smallest betweenness centrality were pruned using 'backward elimination' and 'forward selection' strategies. The resulting graph represents the main connected component with the minimum number of edges.
data(PCv12_pruned_igraph)data(PCv12_pruned_igraph)
igraph
An igraph object.
Chris Wong, Mauro Castro, and TCGA Network.
Pathway Commons V12.
Rodchenkov et al. Pathway Commons 2019 Update: integration, analysis and exploration of pathway data. Nucleic Acids Research 48(D1):D489–D497, 2020. doi:10.1093/nar/gkz946
data(PCv12_pruned_igraph) ## Suggestion to vizualize this igraph in R: library(RGraphSpace) plotGraphSpace(PCv12_pruned_igraph)data(PCv12_pruned_igraph) ## Suggestion to vizualize this igraph in R: library(RGraphSpace) plotGraphSpace(PCv12_pruned_igraph)
Accessory function to plot pathway space distances
plotPathDistances(pdist, z.transform = FALSE)plotPathDistances(pdist, z.transform = FALSE)
pdist |
A list generated by the |
z.transform |
A single logical value specifying to convert pathway distances into z-score values. |
A 'ggplot' object.
# Load a vertex-wise distance matrix (distance between nodes in a graph) data("gdist.toy", package = "PathwaySpace") # Get two gene lists from <- sample(colnames(gdist.toy), 50) to <- sample(colnames(gdist.toy), 50) # Calculate distances between lists, and between random lists res <- pathDistances(gdist.toy, from, to) # Plot observed and null distances plotPathDistances(res)# Load a vertex-wise distance matrix (distance between nodes in a graph) data("gdist.toy", package = "PathwaySpace") # Get two gene lists from <- sample(colnames(gdist.toy), 50) to <- sample(colnames(gdist.toy), 50) # Calculate distances between lists, and between random lists res <- pathDistances(gdist.toy, from, to) # Plot observed and null distances plotPathDistances(res)
plotPathwaySpace is a wrapper function to
create dedicated ggplot graphics for PathwaySpace-class objects.
## S4 method for signature 'PathwaySpace' plotPathwaySpace( ps, colors = pspace.cols(), bg.color = "grey95", si.color = "grey85", si.alpha = 1, theme = c("th0", "th1", "th2", "th3"), title = "PathwaySpace", xlab = "Pathway coordinates 1", ylab = "Pathway coordinates 2", zlab = "Density", font.size = 1, font.color = "white", zlim = NULL, slices = 25, add.grid = TRUE, grid.color = "white", add.summits = TRUE, label.summits = TRUE, summit.color = "white", add.marks = FALSE, marks = NULL, mark.size = 3, mark.color = "white", mark.padding = 0.5, mark.line.width = 0.5, use.dotmark = FALSE, add.image = FALSE )## S4 method for signature 'PathwaySpace' plotPathwaySpace( ps, colors = pspace.cols(), bg.color = "grey95", si.color = "grey85", si.alpha = 1, theme = c("th0", "th1", "th2", "th3"), title = "PathwaySpace", xlab = "Pathway coordinates 1", ylab = "Pathway coordinates 2", zlab = "Density", font.size = 1, font.color = "white", zlim = NULL, slices = 25, add.grid = TRUE, grid.color = "white", add.summits = TRUE, label.summits = TRUE, summit.color = "white", add.marks = FALSE, marks = NULL, mark.size = 3, mark.color = "white", mark.padding = 0.5, mark.line.width = 0.5, use.dotmark = FALSE, add.image = FALSE )
ps |
A PathwaySpace class object. |
colors |
A vector of colors. |
bg.color |
A single color for background. |
si.color |
A single color for silhouette.
(see |
si.alpha |
A transparency level in |
theme |
Name of a custom PathwaySpace theme. These themes
(from 'th0' to 'th3') consist mainly of preconfigured ggplot settings,
which the user can subsequently refine using |
title |
A string for the title. |
xlab |
The title for the 'x' axis of a 2D-image space. |
ylab |
The title for the 'y' axis of a 2D-image space. |
zlab |
The title for the 'z' axis of the image signal. |
font.size |
A single numeric value passed to plot annotations. |
font.color |
A single color passed to plot annotations. |
zlim |
The 'z' limits of the plot (a numeric vector with two numbers). If NULL, limits are determined from the range of the input values. |
slices |
A single positive integer value used to split the image signal into equally-spaced intervals. |
add.grid |
A logical value indicating whether to add gridlines to
the image space. However, gridlines will only appear when the image
is decorated with graph silhouettes (see |
grid.color |
A color passed to |
add.summits |
A logical value indicating whether to add contour
lines to 'summits' (when summits are available;
see |
label.summits |
A logical value indicating whether to label summits. |
summit.color |
A color passed to 'summits'. |
add.marks |
A logical value indicating whether to plot vertex labels. |
marks |
A vector of vertex names to be highlighted in the image space. This argument overrides 'add.labels'. |
mark.size |
A size argument passed to |
mark.color |
A color passed to |
mark.padding |
A box padding argument passed to
|
mark.line.width |
A line width argument passed to
|
use.dotmark |
A logical value indicating whether "marks" should be represented as dots. |
add.image |
A logical value indicating whether to add a background
image, when one is available (see |
A ggplot-class object.
Sysbiolab Team, Mauro Castro.
# Load a demo igraph data('gtoy1', package = 'RGraphSpace') # # Check graph validity gs <- GraphSpace(gtoy1) gs <- normalizeGraphSpace(gs) # Create a PathwaySpace object ps <- buildPathwaySpace(gs, nrc = 300) # note: adjust 'nrc' to increase image resolution # Set '1s' as vertex signal vertexSignal(ps) <- 1 # Create a 2D-landscape image ps <- circularProjection(ps, k = 2, decay.fun = weibullDecay(pdist = 0.4)) # Plot a 2D-landscape image plotPathwaySpace(ps)# Load a demo igraph data('gtoy1', package = 'RGraphSpace') # # Check graph validity gs <- GraphSpace(gtoy1) gs <- normalizeGraphSpace(gs) # Create a PathwaySpace object ps <- buildPathwaySpace(gs, nrc = 300) # note: adjust 'nrc' to increase image resolution # Set '1s' as vertex signal vertexSignal(ps) <- 1 # Create a 2D-landscape image ps <- circularProjection(ps, k = 2, decay.fun = weibullDecay(pdist = 0.4)) # Plot a 2D-landscape image plotPathwaySpace(ps)
Creates polar transformation functions for
polarProjection internal calls. These functions are used to
adjusts signal decay according to point-to-edge angular distances,
with options to attenuate angular shapes.
polarDecay( method = c("power", "gaussian", "logistic"), s = 0.5, k = 10, m = 0.5 )polarDecay( method = c("power", "gaussian", "logistic"), s = 0.5, k = 10, m = 0.5 )
method |
String indicating the transformation to apply. Must be one of: "power", "gaussian", or "logistic". |
s |
Single numeric value in |
k |
Single numeric value |
m |
Single numeric value in |
The polar transformation controls how much the projected signal decays as
a function of the angular distance between a point in pathway space and
a reference edge axis. The function returned by polarDecay() expects
two arguments, with the following signature:
function(x, beta) { ... }.
Power:
where is a vector of normalized angular distances (in [0, 1])
and is a non-negative exponent that controls the rate of signal
decay. Increasing results in a steeper decay rate, modulating
the angular span of the projection.
Gaussian:
where controls the spread around the mean, creating
fuzzier effect on projections.
Logistic:
where is the steepness and is the function's midpoint,
making more gradual transitions.
These transformations are intended to be plugged into the higher-level
polarProjection function, allowing user control over the
polar projection profiles.
Returns a function of the form: function(x, beta) { ... },
that applies the specified shape-based transformation.
Sysbiolab Team
polar.fun <- polarDecay("power")polar.fun <- polarDecay("power")
polarProjection implements a convolution algorithm
to project signals across a 2D-coordinate system.
## S4 method for signature 'PathwaySpace' polarProjection( ps, k = 2, beta = 10, decay.fun = weibullDecay(pdist = 1), aggregate.fun = signalAggregation(), polar.fun = polarDecay(), directional = FALSE, edge.norm = TRUE, rescale = TRUE, verbose = TRUE, theta = deprecated(), pdist = deprecated() )## S4 method for signature 'PathwaySpace' polarProjection( ps, k = 2, beta = 10, decay.fun = weibullDecay(pdist = 1), aggregate.fun = signalAggregation(), polar.fun = polarDecay(), directional = FALSE, edge.norm = TRUE, rescale = TRUE, verbose = TRUE, theta = deprecated(), pdist = deprecated() )
ps |
A PathwaySpace class object. |
k |
A single positive integer determining the k-top signals for the convolution operation. |
beta |
An exponent (in |
decay.fun |
A signal decay function. Available options include
'Weibull', 'exponential', and 'linear' (see |
aggregate.fun |
A function used to aggregate the projected signals.
It must be provided as a unary function, e.g., |
polar.fun |
A polar decay function (see |
directional |
If directional edges are available, this argument can be used to orientate the signal projection on directed graphs. |
edge.norm |
Scale distances based on edge lengths
(when |
rescale |
A logical value indicating whether to rescale
the signal. If the signal |
verbose |
A logical value specifying to display detailed
messages (when |
theta |
Deprecated as of PathwaySpace 1.0.2; use 'beta' instead. |
pdist |
Deprecated as of PathwaySpace 1.0.2; this parameter is now
passed internally through |
A preprocessed PathwaySpace class object.
Sysbiolab Team
# Load a demo igraph data('gtoy2', package = 'RGraphSpace') # Create a new PathwaySpace object ps <- buildPathwaySpace(gtoy2, nrc = 100) # note: adjust 'nrc' to increase image resolution # Set '1s' as vertex signal vertexSignal(ps) <- 1 # Set edge weight # gs_edge_attr(ps, "weight") <- c(-1, 1, 1, 1, 1, 1) # Create a 2D-landscape image ps <- polarProjection(ps, pdist=1)# Load a demo igraph data('gtoy2', package = 'RGraphSpace') # Create a new PathwaySpace object ps <- buildPathwaySpace(gtoy2, nrc = 100) # note: adjust 'nrc' to increase image resolution # Set '1s' as vertex signal vertexSignal(ps) <- 1 # Set edge weight # gs_edge_attr(ps, "weight") <- c(-1, 1, 1, 1, 1, 1) # Create a 2D-landscape image ps <- polarProjection(ps, pdist=1)
A simple vector of colors for PathwaySpace images
pspace.cols(n = 25, ...)pspace.cols(n = 25, ...)
n |
The number of colors to generate in the output palette. |
... |
Additional arguments (not used). |
A vector with hexadecimal color codes.
pspace.cols()pspace.cols()
Creates mixed color palettes by interpolating and offsetting hues, useful for generating transitions between hues.
pspace.pals( colors = c("#303f9d", "#578edb", "#63b946", "#f3930c", "#a60d0d"), trim.colors = c(3, 2, 1, 2, 3), offset = 0.5, n = 25 )pspace.pals( colors = c("#303f9d", "#578edb", "#63b946", "#f3930c", "#a60d0d"), trim.colors = c(3, 2, 1, 2, 3), offset = 0.5, n = 25 )
colors |
A vector of five base colors used to construct the custom
diverging palette. These colors are interpolated according to the
|
trim.colors |
A vector of five positive integers that control the relative weight of each hue in the five-color diverging palette. |
offset |
Adjusts brightness by shifting hues toward the center,
either brighter ( |
n |
The number of colors to generate in the output palette. |
A vector with hexadecimal color codes.
pspace.pals()pspace.pals()
Signal aggregation functions for circularProjection
and polarProjection internal calls. The aggregation should be
symmetric with respect to signal polarity, ensuring that opposite signals
produce corresponding outputs.
signalAggregation(method = c("mean", "wmean", "log.wmean", "exp.wmean"))signalAggregation(method = c("mean", "wmean", "log.wmean", "exp.wmean"))
method |
A character string specifying the method for
signal aggregation, returning either a customized |
Returns a function of the form: function(x) { ... }
Sysbiolab Team
circularProjection, polarProjection,
weighted.mean
aggregate.fun <- signalAggregation()aggregate.fun <- signalAggregation()
Use weibullDecay, expDecay,
and linearDecay.
signalDecay(...)signalDecay(...)
... |
Deprecated arguments |
Stop unconditionally
Sysbiolab Team
decay.fun <- weibullDecay()decay.fun <- weibullDecay()
silhouetteMapping constructs an image baseline used
to outline the graph layout in a PathwaySpace image.
## S4 method for signature 'PathwaySpace' silhouetteMapping( ps, pdist = 0.05, baseline = 0.01, fill.cavity = TRUE, verbose = TRUE )## S4 method for signature 'PathwaySpace' silhouetteMapping( ps, pdist = 0.05, baseline = 0.01, fill.cavity = TRUE, verbose = TRUE )
ps |
A PathwaySpace class object. |
pdist |
A term (in |
baseline |
A fraction (in |
fill.cavity |
A logical value specifying to fill cavities
in the silhouette mask (when |
verbose |
A logical value specifying to display detailed
messages (when |
A preprocessed PathwaySpace class object.
Sysbiolab Team
# Load a demo igraph data('gtoy1', package = 'RGraphSpace') # Create a new PathwaySpace object ps <- buildPathwaySpace(gtoy1, nrc = 100) # note: adjust 'nrc' to increase image resolution # Set '1s' as vertex signal vertexSignal(ps) <- 1 # Map graph silhouette ps <- silhouetteMapping(ps, pdist = 0.1)# Load a demo igraph data('gtoy1', package = 'RGraphSpace') # Create a new PathwaySpace object ps <- buildPathwaySpace(gtoy1, nrc = 100) # note: adjust 'nrc' to increase image resolution # Set '1s' as vertex signal vertexSignal(ps) <- 1 # Map graph silhouette ps <- silhouetteMapping(ps, pdist = 0.1)
The summitMapping method implements a segmentation
strategy to identify summits on a 2D-landscape image
(see summitWatershed).
## S4 method for signature 'PathwaySpace' summitMapping( ps, maxset = 30, minsize = 30, threshold = 0.5, verbose = TRUE, segm_fun = summitWatershed, ... )## S4 method for signature 'PathwaySpace' summitMapping( ps, maxset = 30, minsize = 30, threshold = 0.5, verbose = TRUE, segm_fun = summitWatershed, ... )
ps |
A PathwaySpace class object. |
maxset |
A single positive integer indicating the maximum number of summits to be returned by the segmentation function. |
minsize |
A single positive integer indicating the minimum size of the summits. |
threshold |
A threshold provided as a fraction (in |
verbose |
A logical value specifying to display detailed
messages (when |
segm_fun |
A segmentation function used to detect summits
(see |
... |
Additional arguments passed to the segmentation function. |
A preprocessed PathwaySpace class object.
Sysbiolab Team
# Load a large igraph data("PCv12_pruned_igraph", package = "PathwaySpace") # Continue this example from the PathwaySpace vignette, # in the 'PathwaySpace decoration' section# Load a large igraph data("PCv12_pruned_igraph", package = "PathwaySpace") # Continue this example from the PathwaySpace vignette, # in the 'PathwaySpace decoration' section
The summitWatershed function implements a segmentation
strategy to identify summits within a landscape image generated by the
PathwaySpace package. This function is entirely coded in R, which helps
alleviating users from the task of loading an excessive number of
dependencies. Nonetheless, while this novel implementation prevents
the burden a 'dependency heaviness', it still requires optimization
as it currently exhibits slower performance compared to well-established
implementations such as the watershed function from the EBImage package.
The summitWatershed maintain a certain level of compatibility
with the EBImage's watershed function, and both can be used in the
PathwaySpace package.
summitWatershed(x, tolerance = 0.1, ext = 1)summitWatershed(x, tolerance = 0.1, ext = 1)
x |
A 2D-numeric array in which each point represents the coordinates of a signal in a landscape image. |
tolerance |
The minimum signal intensity of a summit (in |
ext |
Radius (in pixels) for detecting neighboring objects. |
A matrix with labeled summits.
Sysbiolab Team, Mauro Castro.
# Load a demo landscape image data('gimage', package = 'PathwaySpace') # Scale down the image for a quicker demonstration gimage <- gimage[200:300, 200:300] # Check signal range range(gimage, na.rm = TRUE) # [1] 0 1 # Check image image(gimage) # Threshold the signal intensity, for example: gimage[gimage < 0.5] <- 0 # Run summit segmentation gmask <- summitWatershed(x = gimage) # Check resulting image mask image(gimage)# Load a demo landscape image data('gimage', package = 'PathwaySpace') # Scale down the image for a quicker demonstration gimage <- gimage[200:300, 200:300] # Check signal range range(gimage, na.rm = TRUE) # [1] 0 1 # Check image image(gimage) # Threshold the signal intensity, for example: gimage[gimage < 0.5] <- 0 # Run summit segmentation gmask <- summitWatershed(x = gimage) # Check resulting image mask image(gimage)
Get or set 'signal' and 'decay' functions in a PathwaySpace class object.
## S4 method for signature 'PathwaySpace' vertexSignal(x) ## S4 replacement method for signature 'PathwaySpace' vertexSignal(x) <- value ## S4 method for signature 'PathwaySpace' vertexDecay(x) ## S4 replacement method for signature 'PathwaySpace' vertexDecay(x) <- value## S4 method for signature 'PathwaySpace' vertexSignal(x) ## S4 replacement method for signature 'PathwaySpace' vertexSignal(x) <- value ## S4 method for signature 'PathwaySpace' vertexDecay(x) ## S4 replacement method for signature 'PathwaySpace' vertexDecay(x) <- value
x |
A PathwaySpace class object. |
value |
The new value of the attribute. |
Updated PathwaySpace object.
data('gtoy1', package = 'RGraphSpace') ps <- buildPathwaySpace(gtoy1, nrc = 100) # Check vertex names names(ps) # Access signal values from all vertices vertexSignal(ps) # Modify signal value of a specific vertex vertexSignal(ps)[1] <- 1 # Modify signal value of specific vertices vertexSignal(ps)[c("n2","n3")] <- 1 # Set '1s' to all vertices vertexSignal(ps) <- 1 #---- # Access decay function of a specific vertex vertexDecay(ps)[["n3"]] # Modify decay function of a specific vertex vertexDecay(ps)[["n3"]] <- linearDecay() # Modify decay functions of two vertices vertexDecay(ps)[c("n1","n3")] <- list( weibullDecay() ) # Modify decay functions of all vertices vertexDecay(ps) <- weibullDecay(shape = 2)data('gtoy1', package = 'RGraphSpace') ps <- buildPathwaySpace(gtoy1, nrc = 100) # Check vertex names names(ps) # Access signal values from all vertices vertexSignal(ps) # Modify signal value of a specific vertex vertexSignal(ps)[1] <- 1 # Modify signal value of specific vertices vertexSignal(ps)[c("n2","n3")] <- 1 # Set '1s' to all vertices vertexSignal(ps) <- 1 #---- # Access decay function of a specific vertex vertexDecay(ps)[["n3"]] # Modify decay function of a specific vertex vertexDecay(ps)[["n3"]] <- linearDecay() # Modify decay functions of two vertices vertexDecay(ps)[c("n1","n3")] <- list( weibullDecay() ) # Modify decay functions of all vertices vertexDecay(ps) <- weibullDecay(shape = 2)
The weibullDecay() constructor either creates a decay function or
returns a ggplot object for visualizing the decay model. It is a utility
function used internally by circularProjection and
polarProjection.
weibullDecay( decay = 0.001, pdist = 0.15, shape = 1.05, plot = FALSE, demo.signal = 1 )weibullDecay( decay = 0.001, pdist = 0.15, shape = 1.05, plot = FALSE, demo.signal = 1 )
decay |
A decay factor (in |
pdist |
A distance normalization term (in (0, 1]) at which the signal
reaches |
shape |
A parameter (>=1) of a Weibull function. When |
plot |
A logical value indicating whether to return a |
demo.signal |
A numeric value in |
The weibullDecay() constructor creates a decay model based on the Weibull
distribution. It describes how a signal decreases as a function of distance,
controlled by both a decay rate and a shape parameter.
The decay function is defined as:
where represents the initial intensity, controls
the rate of attenuation, is a vector of normalized distances,
and adjusts the curvature of the decay. When ,
the function follows an exponential decay. For , the curve
transitions from convex to concave, exhibiting an inflection point. The
parameter anchors the model such that:
when
when
Returns either a function of the form
function(x, signal) { ... } or, if plot = TRUE, a ggplot
object illustrating the decay model.
Sysbiolab Team
# Return a decay function decay_fun <- weibullDecay(decay = 0.5, pdist = 0.4, shape = 2) # Plot decay model parameters # weibullDecay(decay = 0.5, pdist = 0.4, shape = 2, plot = TRUE)# Return a decay function decay_fun <- weibullDecay(decay = 0.5, pdist = 0.4, shape = 2) # Plot decay model parameters # weibullDecay(decay = 0.5, pdist = 0.4, shape = 2, plot = TRUE)