This repository contains the R scripts and saved analysis outputs used for the manuscript Identifying Context-Specific Transcription Factor Targets from Prior Knowledge and Gene Expression Data. It is an analysis built around CoGAPS matrix factorization and a transcription-factor-to-target probability statistic (rather than a standalone R package).
The code is organized around two end-to-end analysis scripts:
R/SimTFDataAllTFs.Rreproduces the simulated transcription factor (TF) workflow used to validate the method and test it under noisy or error-prone priors.R/GISTAnalysis5e7.Rreproduces the gastrointestinal stromal tumor (GIST) analysis from the paper.
The paper's workflow is the same in both the simulated and GIST analyses:
- Start with an expression matrix and a prior TF-to-gene mapping.
- Run CoGAPS to factor the data into amplitude and pattern matrices.
- Convert the CoGAPS output into TF set statistics and gene-level probabilities.
- Compare those probabilities to the prior TF annotations.
- Plot the inferred patterns, gene set summaries, and overlap structure.
- Save the derived objects and figures for downstream reporting.
The key idea in the manuscript is that CoGAPS provides a pattern space in which the prior TF target sets can be rescored, allowing for selection of genes whose expression looks contextually consistent.
R/SimTFDataAllTFs.Rruns the paper's simulated data analysis. It:- Constructs a synthetic dataset with four TFs, simulated patterns, overlap among TF targets, and controlled noise.
- Runs CoGAPS and computes fit statistics.
- Runs robustness experiments where error is intenionally introduced to the TF sets.
R/GISTAnalysis5e7.Rruns the paper's real data analysis on the GIST dataset. It:- Loads
GIST_TS_20084andTFGSListdata (originally via CoGAPS packagedatacalls; repository-local copies are provided in theinputsdirectory). - Rebuilds a TF regulation matrix from TRANSFAC-derived annotations.
- Runs CoGAPS with 5 patterns and computes fit statistics.
- Derives the TF-specific gene statistics used for the manuscript figures and tables.
- Loads
R/calcPermGS.Rimplements the gene-level statistic used to turn CoGAPS gene set evidence into per gene TF probabilities.R/ReadCoGAPSResults.Rreads CoGAPS output files from disk and reconstructs theA,P,M, and uncertainty matrices.R/PlotGSPatterns.Rgroups genes by p-values and plots genes' normalized expression patterns across samples, overlaying an inferred pattern summary or mean gene expression if desired.R/TFTargetHeatmaps.Rvisualizes how inferred gene probabilities compare to TF priors and, when present, simulation results.R/MatError.Radds errorbar plotting used in the simulation robustness analysis.
outputs/SimData.RDatais the saved synthetic dataset.outputs/SimDataResults.Rdais the saved simulation analysis workspace.inputs/GIST_TS_20084.Rdatais the data used in the GIST workflow.inputs/TFGSList.RDataare the TF gene set annotations used by the GIST workflow.outputs/GISTResults.Rdais the saved GIST analysis workspace.
The scripts also write their own results into analysis specific folders created at runtime, such as GIST5e7/ and SimDataOverlapAllTFs/.
The scripts load R packages CoGAPS, ClassDiscovery, gplots, AnnotationDbi, xtable, gtools, vioplot, and Hmisc to be available. The full session information is included in outputs/SimDataResults.Rda as session.
Important
The code in this repository has been preserved as it was executed for the associated manuscript. If you intend to run the analysis, please note:
- This analysis uses CoGAPS v0.99.1. Because the package has undergone significant changes since then, modern versions are lacking functions required for this analysis.
- To bypass installing the legacy version, the included workspace data can be loaded and code chunks calling the outdated functions can be skipped (these functions include
GAPS,calcCoGAPSStat, and functions that depend on them). - The
GIST_TS_20084andTFGSListdata are no longer bundled with the CoGAPS package, so they have been provided here in theinputsdirectory. To run the analysis script, you will need to replace the originaldatacalls withloadcalls that point to the correct file paths.
Run the scripts from the repository root so their getwd()-based path construction resolves correctly:
source("R/GISTAnalysis5e7.R")
source("R/SimTFDataAllTFs.R")The scripts are a self-contained workflow, but full reruns depend on legacy CoGAPS behavior. The scripts will:
- Create the needed output directories.
- Run CoGAPS with the hard-coded iteration settings (if the appropriate version of CoGAPS is available).
- Read the generated CoGAPS result files back in (if they were created).
- Generate the figures and summary tables.
- Save the final
.Rdaworkspace snapshots.
If you use this method in your work, please cite the associated manuscript:
Fertig, E. J., Favorov, A. V. & Ochs, M. F. Identifying Context-Specific Transcription Factor Targets from Prior Knowledge and Gene Expression Data. IEEE Trans Nanobioscience 12, 142–149 (2013).