regressEdges: Regression analysis of edges across ordered conditions

View source: R/testEdges.R

regressEdgesR Documentation

Regression analysis of edges across ordered conditions

Description

Performs linear regression on network edges from runSCORPION output to identify edges that show significant trends across ordered conditions (e.g., disease progression: Normal -> Border -> Tumor).

Usage

regressEdges(networksDF, orderedGroups, padjustMethod = "BH", minMeanEdge = 0)

Arguments

networksDF

A data.frame output from runSCORPION containing TF-target pairs as rows and network identifiers as columns.

orderedGroups

A named list where each element is a character vector of column names in networksDF. Names represent ordered conditions (e.g., list(Normal = c("P31–N", "P32–N"), Border = c("P31–B", "P32–B"), Tumor = c("P31–T", "P32–T"))). The order of list elements defines the progression (first to last).

padjustMethod

Character specifying the p-value adjustment method for multiple testing correction. See p.adjust for options. Default "BH" (Benjamini-Hochberg FDR).

minMeanEdge

Numeric threshold for minimum mean absolute edge weight to include in testing. Edges with mean absolute weight below this threshold are excluded. Default 0 (no filtering).

Details

This function performs simple linear regression for each edge, modeling edge weight as a function of an ordered categorical variable (coded as 0, 1, 2, ... for each condition level).

The slope coefficient indicates the average change in edge weight per step along the ordered progression. Positive slopes indicate increasing edge weights, negative slopes indicate decreasing edge weights.

The function uses vectorized computations for efficiency with large datasets.

Value

A data.frame containing:

  • tf: Transcription factor

  • target: Target gene

  • slope: Regression slope (change in edge weight per condition step)

  • intercept: Regression intercept

  • rSquared: R-squared value (proportion of variance explained)

  • fStatistic: F-statistic for the regression

  • pValue: Raw p-value for the slope

  • pAdj: Adjusted p-value

  • meanEdge: Overall mean edge weight across all conditions

  • One column per condition showing mean edge weight in that condition

Examples

## Not run: 
# Load test data and build networks by donor and region
# Note: T = Tumor, N = Normal, B = Border regions
data(scorpionTest)
nets <- runSCORPION(
  gexMatrix = scorpionTest$gex,
  tfMotifs = scorpionTest$tf,
  ppiNet = scorpionTest$ppi,
  cellsMetadata = scorpionTest$metadata,
  groupBy = c("donor", "region")
)

# Define ordered progression: Normal -> Border -> Tumor
normal_nets <- grep("--N$", colnames(nets), value = TRUE)
border_nets <- grep("--B$", colnames(nets), value = TRUE)
tumor_nets <- grep("--T$", colnames(nets), value = TRUE)

ordered_conditions <- list(
  Normal = normal_nets,
  Border = border_nets,
  Tumor = tumor_nets
)

# Perform regression analysis
results_regression <- regressEdges(
  networksDF = nets,
  orderedGroups = ordered_conditions
)

# View top edges with strongest trends
head(results_regression[order(results_regression$pAdj), ])

# Edges with positive slopes (increasing from N to T)
increasing <- results_regression[results_regression$pAdj < 0.05 & 
                                  results_regression$slope > 0, ]
print(paste("Edges increasing along N->B->T:", nrow(increasing)))

# Edges with negative slopes (decreasing from N to T)
decreasing <- results_regression[results_regression$pAdj < 0.05 & 
                                  results_regression$slope < 0, ]
print(paste("Edges decreasing along N->B->T:", nrow(decreasing)))

# Filter by minimum edge weight and R-squared
strong_trends <- results_regression[results_regression$pAdj < 0.05 & 
                                     results_regression$rSquared > 0.7 &
                                     abs(results_regression$meanEdge) > 0.1, ]

## End(Not run)

SCORPION documentation built on Feb. 5, 2026, 1:06 a.m.