SGCP
Workflows
Standard Workflow
Construct gene co-expression networks, perform clustering, and apply semi-supervised classification using Gene Ontology information.
library(SGCP)
library(SummarizedExperiment)
library(org.Hs.eg.db)
# Load example dataset
data(cheng)
expData <- assay(cheng)
geneID <- rowData(cheng)$ENTREZID
annotation_db <- "org.Hs.eg.db"
# Option 1: Automatic Run using ezSGCP
# (Precomputed data loaded here to avoid long execution times)
data(sgcp)
summary(sgcp, show.data=TRUE)
# Plot PCA and silhouette index
SGCP_ezPLOT(sgcp = sgcp, expreData = expData, silhouette_index = TRUE, keep = FALSE)
# Option 2: Step-by-Step Run
# 1. Network Construction
resAdja <- adjacencyMatrix(expData = expData, hm = NULL)
# 2. Network Clustering (using precomputed resClus for speed)
data(resClus)
summary(resClus)
# Plot PCA of expression data
pl <- SGCP_plot_pca(m = expData, clusLabs = NULL, tit = "PCA plot", ps = .5)
print(pl)
Note on inputs/outputs:
- Input: A gene expression matrix, a vector of gene Entrez IDs, and an organism-specific annotation database.
- Output: A list containing initial clusters, semi-labeled genes, semi-supervised classification results, and final biologically enriched gene modules.
When to Use
- Gene Co-expression Networks: Constructing gene co-expression networks and organizing genes into modules using
adjacencyMatrix() and clustering().
- GO Integration: Integrating Gene Ontology (GO) enrichment analysis into the clustering pipeline using
geneOntology().
- Semi-supervised Classification: Applying semi-supervised classification (e.g., KNN or logistic regression) to refine gene modules using
semiSupervised().
- Network Visualization: Visualizing gene expression PCA plots and network adjacency heatmaps using
SGCP_plot_pca() and SGCP_plot_heatMap().
When NOT to Use
- Raw Sequence Alignment: For raw sequence alignment or differential expression analysis, use packages like
DESeq2 or edgeR because SGCP requires preprocessed, normalized expression data with non-zero variance.
- Unsupervised Clustering Without GO: For purely unsupervised clustering without any biological annotation or GO integration, use standard R clustering functions (e.g.,
kmeans or hclust) because SGCP is specifically designed to leverage GO information.
Data Requirements
- Expression Data (
expData): A matrix or data frame of size $m \times n$ (genes by samples) of normalized DNA-microarray or RNA-seq data. Genes must have expression values across all samples (no missing values) and non-zero variance.
- Gene Identifiers (
geneID): A vector of size $m$ containing unique gene identifiers (e.g., Entrez IDs) compatible with the annotation database.
- Annotation Database (
annotation_db): A genome-wide annotation package name (e.g., "org.Hs.eg.db").
Key Parameters
- calibration (
FALSE): Boolean in adjacencyMatrix() to perform network calibration.
- norm (
TRUE): Boolean in adjacencyMatrix() to divide each gene vector by its L2 norm.
- tom (
TRUE): Boolean in adjacencyMatrix() to add Topological Overlap Matrix to the network.
- kopt (
NULL): Integer in clustering() specifying the user-defined optimal number of clusters.
- method (
NULL): Method for determining the number of clusters in clustering(); options include "relativeGap", "secondOrderGap", and "additiveGap".
- direction (
c("over", "under")): Test direction for GO enrichment in geneOntology().
- ontology (
c("BP", "CC", "MF")): GO ontologies to test in geneOntology().
- model ("knn"): Classification model in
semiSupervised(); options include "knn" and "lr".
Best Practices
- Ensure all preprocessing, normalization, and batch effect corrections are completed on the expression matrix before inputting to
SGCP.
- Filter out genes with zero variance or missing values across samples prior to running
adjacencyMatrix().
- Evaluate and compare the three cluster-number determination methods ("relativeGap", "secondOrderGap", "additiveGap") using GO validation.
- Enable the silhouette index calculation (
sil = TRUE) in clustering() to evaluate the quality of the initial clusters.
Common Pitfalls
- Mismatched Gene Identifiers: Mismatch between gene identifiers in
geneID and the standard expected by GOstats / annotation_db. Fix: Ensure geneID contains valid Entrez IDs (or TAIR IDs for Arabidopsis) that match the selected annotation_db.
- Long Computation Times: Long computation times during the GO validation or clustering steps. Fix: Use precomputed results where possible, or reduce the number of genes to those with the highest variance.
- Zero Variance Genes: Error due to genes with zero variance across samples. Fix: Filter the input expression matrix to remove zero-variance genes before running the pipeline.
Alternatives
- WGCNA for standard unsupervised gene co-expression network analysis.
- GOstats for standalone hypergeometric testing of Gene Ontology terms.
- SummarizedExperiment for general containerization of biological assays and genomic features.
Citations
- Cheng, J. et al. (Ischemic cardiomyopathy dataset reference).
References
1---2name: sgcp3description: SGCP4---56# SGCP78## Workflows910### Standard Workflow1112Construct gene co-expression networks, perform clustering, and apply semi-supervised classification using Gene Ontology information.1314```r15library(SGCP)16library(SummarizedExperiment)17library(org.Hs.eg.db)1819# Load example dataset20data(cheng)21expData <- assay(cheng)22geneID <- rowData(cheng)$ENTREZID23annotation_db <- "org.Hs.eg.db"2425# Option 1: Automatic Run using ezSGCP26# (Precomputed data loaded here to avoid long execution times)27data(sgcp)28summary(sgcp, show.data=TRUE)2930# Plot PCA and silhouette index31SGCP_ezPLOT(sgcp = sgcp, expreData = expData, silhouette_index = TRUE, keep = FALSE)3233# Option 2: Step-by-Step Run34# 1. Network Construction35resAdja <- adjacencyMatrix(expData = expData, hm = NULL)3637# 2. Network Clustering (using precomputed resClus for speed)38data(resClus)39summary(resClus)4041# Plot PCA of expression data42pl <- SGCP_plot_pca(m = expData, clusLabs = NULL, tit = "PCA plot", ps = .5)43print(pl)44```4546**Note on inputs/outputs:**47* **Input:** A gene expression matrix, a vector of gene Entrez IDs, and an organism-specific annotation database.48* **Output:** A list containing initial clusters, semi-labeled genes, semi-supervised classification results, and final biologically enriched gene modules.4950## When to Use51* **Gene Co-expression Networks:** Constructing gene co-expression networks and organizing genes into modules using `adjacencyMatrix()` and `clustering()`.52* **GO Integration:** Integrating Gene Ontology (GO) enrichment analysis into the clustering pipeline using `geneOntology()`.53* **Semi-supervised Classification:** Applying semi-supervised classification (e.g., KNN or logistic regression) to refine gene modules using `semiSupervised()`.54* **Network Visualization:** Visualizing gene expression PCA plots and network adjacency heatmaps using `SGCP_plot_pca()` and `SGCP_plot_heatMap()`.5556## When NOT to Use57* **Raw Sequence Alignment:** For raw sequence alignment or differential expression analysis, use packages like `DESeq2` or `edgeR` because `SGCP` requires preprocessed, normalized expression data with non-zero variance.58* **Unsupervised Clustering Without GO:** For purely unsupervised clustering without any biological annotation or GO integration, use standard R clustering functions (e.g., `kmeans` or `hclust`) because `SGCP` is specifically designed to leverage GO information.5960## Data Requirements61* **Expression Data (`expData`):** A matrix or data frame of size $m \times n$ (genes by samples) of normalized DNA-microarray or RNA-seq data. Genes must have expression values across all samples (no missing values) and non-zero variance.62* **Gene Identifiers (`geneID`):** A vector of size $m$ containing unique gene identifiers (e.g., Entrez IDs) compatible with the annotation database.63* **Annotation Database (`annotation_db`):** A genome-wide annotation package name (e.g., `"org.Hs.eg.db"`).6465## Key Parameters66* **calibration** (`FALSE`): Boolean in `adjacencyMatrix()` to perform network calibration.67* **norm** (`TRUE`): Boolean in `adjacencyMatrix()` to divide each gene vector by its L2 norm.68* **tom** (`TRUE`): Boolean in `adjacencyMatrix()` to add Topological Overlap Matrix to the network.69* **kopt** (`NULL`): Integer in `clustering()` specifying the user-defined optimal number of clusters.70* **method** (`NULL`): Method for determining the number of clusters in `clustering()`; options include "relativeGap", "secondOrderGap", and "additiveGap".71* **direction** (`c("over", "under")`): Test direction for GO enrichment in `geneOntology()`.72* **ontology** (`c("BP", "CC", "MF")`): GO ontologies to test in `geneOntology()`.73* **model** ("knn"): Classification model in `semiSupervised()`; options include "knn" and "lr".7475## Best Practices76* Ensure all preprocessing, normalization, and batch effect corrections are completed on the expression matrix before inputting to `SGCP`.77* Filter out genes with zero variance or missing values across samples prior to running `adjacencyMatrix()`.78* Evaluate and compare the three cluster-number determination methods ("relativeGap", "secondOrderGap", "additiveGap") using GO validation.79* Enable the silhouette index calculation (`sil = TRUE`) in `clustering()` to evaluate the quality of the initial clusters.8081## Common Pitfalls82* **Mismatched Gene Identifiers:** Mismatch between gene identifiers in `geneID` and the standard expected by `GOstats` / `annotation_db`. *Fix:* Ensure `geneID` contains valid Entrez IDs (or TAIR IDs for Arabidopsis) that match the selected `annotation_db`.83* **Long Computation Times:** Long computation times during the GO validation or clustering steps. *Fix:* Use precomputed results where possible, or reduce the number of genes to those with the highest variance.84* **Zero Variance Genes:** Error due to genes with zero variance across samples. *Fix:* Filter the input expression matrix to remove zero-variance genes before running the pipeline.8586## Alternatives87* **WGCNA** for standard unsupervised gene co-expression network analysis.88* **GOstats** for standalone hypergeometric testing of Gene Ontology terms.89* **SummarizedExperiment** for general containerization of biological assays and genomic features.9091## Citations92* Cheng, J. et al. (Ischemic cardiomyopathy dataset reference).9394## References95* Homepage: https://bioconductor.org/packages/sgcp96* Vignette: https://bioconductor.org/packages/release/bioc/vignettes/sgcp/inst/doc/SGCP.html