This repository analyzes cross-disorder differential expression in the context of brain gene regulatory networks (GRNs).
It combines:
- Tissue-specific GRN matrices (PANDA/GRAND-derived; bipartite TF -> target edges)
- Cross-study table showing psychiatric disorders
- Python graph filtering/scoring/visualization
- R-based enrichment, overlap, and meta-disorder analyses
src/run.py: main Python pipeline for GRN + DEG integration.src/graph_utils.py: data loading, Ensembl mapping, GRN filtering/merging helpers.src/graph_algos.py: regulatory scoring, summary stats, overlap metrics, CSV writers.src/graph_viz.py: PyVis/Matplotlib graph visualizations.src/degensembl.py: helper script to fill missing Ensembl IDs in DEG tables.src/thesisp1.R: primary R analysis pipeline (enrichment, GSEA, overlap tests, networks).src/p1thesis.R: older/alternate thesis pipeline version.src/p1permutationtest.R: standalone permutation overlap test script.src/p1deganalysis.R,src/p1geneontology.R,src/p1venndiagrams.R,src/wingodatasetanalysis.R: past exploratory/auxiliary analysis scripts.src/data/: input data files.src/results/: generated figures, tables, and HTML network visualizations.src/lib/: vendored JS/CSS assets used by HTML network outputs.src/run_merge.sbatch: SLURM wrapper to run random walks
Used by run.py with edge thresholding:
src/data/Brain_Other.csvsrc/data/Brain_Basal_Ganglia.csvsrc/data/Brain_Cerebellum.csv
Format: first column = TF, remaining columns = target genes, cells = edge weights.
Main Python default:
src/data/DEGDataStrictLFC.csv
Other variants included:
DEGData.csv,DEGDataStrictestLFC.csv,DEGDataSample.csv
Expected columns:
DISORDER, STUDY, YEAR, TISSUE, GENEID, LOG2FC, PVAL(some files also include-LOGPVAL)
Run from inside src/:
cd src
python run.pyWhat it does:
- Reads brain GRN matrices and filters edges by weight (
threshold = 1.7). - Merges tissue GRNs with averaged duplicate TF->gene edge weights.
- Converts IDs to Ensembl where needed (Ensembl REST API).
- Loads disorder DEG lists for:
AD, ADHD, ASD, BD, MDD, OCD, SZ
- Builds per-disorder network variants:
- DEG TF only (
tf_grn) - DEG targets only (
deg_grn) - DEG TF + DEG targets (
detf_deggrn, when distinct)
- DEG TF only (
- Computes regulator scores, edge/log2FC summaries, and pairwise Jaccard overlaps.
- Writes per-disorder and cross-disorder outputs to
src/results/.
Key Python outputs:
src/results/deggrn_disorder_summary.csvsrc/results/deggrn_overlap_summary.csvsrc/results/deggrn_jaccard_*.csvsrc/results/overlay_tf_grn_disorders.htmlsrc/results/pyviz_*_deggrn.htmlandsrc/results/deggrn_*.html
Run from inside src/:
cd src
Rscript thesisp1.RHigh-level steps:
- Load and clean DEG table (
DEGData.csv) - Collapse to per-gene/per-disorder meta effects
- Annotate with HGNC/Entrez (biomaRt)
- GO/KEGG enrichment and GSEA
- Pairwise overlap statistics (Fisher/permutation variants)
- Cross-disorder visualizations and network hub analyses
- Export tables/figures under
src/results/tables,src/results/figures,src/results/networks,src/results/enrichment
Minimum packages used by core pipeline:
requestsnumpymatplotlibnetworkxpyvisurllib3
Scripts use many packages, including:
- CRAN:
tidyverse,dplyr,data.table,ggplot2,igraph,ggraph,pheatmap,circlize,RColorBrewer,ggupset - Bioconductor:
biomaRt,clusterProfiler,org.Hs.eg.db,enrichplot,ComplexHeatmap,DOSE,GEOquery,limma
run.pyassumes execution fromsrc/(relative paths likedata/...andresults/...).- Ensembl ID conversion in Python requires internet access to Ensembl REST.
- R annotation/enrichment steps require internet access for some biomaRt/Bioc calls.
src/p1thesis.Rand otherp1*.Rscripts are older/experimental variants;thesisp1.Ris the most complete end-to-end R workflow in this repo.