| regressEdges | R Documentation |
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).
regressEdges(networksDF, orderedGroups, padjustMethod = "BH", minMeanEdge = 0)
networksDF |
A data.frame output from |
orderedGroups |
A named list where each element is a character vector of
column names in |
padjustMethod |
Character specifying the p-value adjustment method for multiple
testing correction. See |
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). |
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.
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
## 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.