Genomics and Epigenomics Data Processing
Production-ready computational skill for processing and analyzing epigenomics data. Combines local Python computation (pandas, scipy, numpy, pysam, statsmodels) with ToolUniverse annotation tools for regulatory context. Designed to solve BixBench-style questions about methylation, ChIP-seq, ATAC-seq, and multi-omics integration.
When to Use This Skill
Triggers:
- User provides methylation data (beta-value matrices, Illumina arrays) and asks about CpG sites
- Questions about differential methylation analysis
- Age-related CpG detection or epigenetic clock questions
- Chromosome-level methylation density or statistics
- ChIP-seq peak files (BED format) with analysis questions
- ATAC-seq chromatin accessibility questions
- Multi-omics integration (expression + methylation, expression + ChIP-seq)
- Genome-wide epigenomic statistics
- Questions mentioning "methylation", "CpG", "ChIP-seq", "ATAC-seq", "histone", "chromatin", "epigenetic"
- Questions about missing data across clinical/genomic/epigenomic modalities
- Regulatory element annotation for processed epigenomic data
Example Questions:
- "How many patients have no missing data for vital status, gene expression, and methylation data?"
- "What is the ratio of filtered age-related CpG density between chromosomes?"
- "What is the genome-wide average chromosomal density of unique age-related CpGs per base pair?"
- "How many CpG sites show significant differential methylation (padj < 0.05)?"
- "What is the Pearson correlation between methylation and expression for gene X?"
- "How many ChIP-seq peaks overlap with promoter regions?"
- "What fraction of ATAC-seq peaks are in enhancer regions?"
- "Which chromosome has the highest density of hypermethylated CpGs?"
- "Filter CpG sites by variance > threshold and map to nearest genes"
- "What is the average beta value difference between tumor and normal for chromosome 17?"
NOT for (use other skills instead):
- Gene regulation lookup without data files -> Use existing epigenomics annotation pattern
- RNA-seq differential expression -> Use
tooluniverse-rnaseq-deseq2
- Variant calling/annotation from VCF -> Use
tooluniverse-variant-analysis
- Gene enrichment analysis -> Use
tooluniverse-gene-enrichment
- Protein structure analysis -> Use
tooluniverse-protein-structure-retrieval
Required Python Packages
# Core (MUST be available)
import pandas as pd
import numpy as np
from scipy import stats
import statsmodels.stats.multitest as mt
# Optional but useful
import pysam # BAM/CRAM file access
import gseapy # Enrichment of genes from methylation analysis
# ToolUniverse (for annotation)
from tooluniverse import ToolUniverse
Key Principles
- Data-first approach - Load and inspect data files BEFORE any analysis
- Question-driven - Parse what the user is actually asking and extract the specific numeric answer
- File format detection - Automatically detect methylation arrays, BED files, BigWig, clinical data
- Coordinate system awareness - Track genome build (hg19, hg38, mm10), handle chr prefix differences
- Statistical rigor - Proper multiple testing correction, effect size filtering, sample size awareness
- Missing data handling - Explicitly report and handle NaN/missing values
- Chromosome normalization - Always normalize chromosome names (chr1 vs 1, chrX vs X)
- CpG site identification - Parse Illumina probe IDs (cg/ch probes), genomic coordinates
- Report-first - Create output file first, populate progressively
- English-first queries - Use English in all tool calls
Workflow Overview
Phase 0: Question Parsing and Data Discovery
Before writing any code, parse the question to identify:
- What data files are available (methylation, ChIP-seq, ATAC-seq, clinical, expression, manifest)
- What specific statistic or answer is being asked for
- What thresholds apply (significance, effect size, variance, chromosome filters)
- What genome build to use
Categorize files by scanning for keywords: methyl/beta/cpg/illumina, chip/peak/narrowpeak, atac/accessibility, clinical/patient/sample, express/rnaseq/fpkm, manifest/annotation/probe.
See ANALYSIS_PROCEDURES.md for the full decision tree and parameter extraction table.
Phase 1: Methylation Data Processing
Core functions for methylation analysis:
- Load methylation data - Supports CSV, TSV, parquet, HDF5; auto-detects beta vs M-values
- Load probe manifest - Illumina 450K/EPIC manifest with chromosome, position, gene annotation
- CpG filtering - Filter by variance, missing rate, probe type (cg/ch), chromosome, CpG island relation, gene group
- Differential methylation - T-test/Wilcoxon/KS between groups with FDR correction; identify DMPs (hyper/hypo)
- Age-related CpG analysis - Pearson/Spearman correlation of probes with age, FDR correction
- Chromosome-level density - CpG count per chromosome divided by chromosome length; density ratios; genome-wide average
See CODE_REFERENCE.md Phase 1 for full function implementations.
Phase 2: ChIP-seq Peak Analysis
- Load BED/narrowPeak/broadPeak - Auto-detect format, normalize chromosomes
- Peak statistics - Count, length distribution, signal values, q-values
- Peak annotation - Map peaks to nearest gene, classify as promoter/gene_body/proximal/distal
- Peak overlap - Pure Python interval intersection between two BED files; Jaccard similarity
See CODE_REFERENCE.md Phase 2 for full function implementations.
Phase 3: ATAC-seq Analysis
- Load ATAC peaks - Wrapper around BED loader for narrowPeak format
- ATAC-specific stats - Nucleosome-free region (NFR) detection (<150bp peaks), region classification
- Chromatin accessibility by region - Distribution of open chromatin across promoter/enhancer/intergenic
See CODE_REFERENCE.md Phase 3 for full function implementations.
Phase 4: Multi-Omics Integration
- Methylation-expression correlation - Align samples, compute per-probe-gene Pearson/Spearman with FDR
- ChIP-seq + expression - Find genes with promoter peaks and compare expression levels
See CODE_REFERENCE.md Phase 4 for full function implementations.
Phase 5: Clinical Data Integration
- Missing data analysis - Count samples present across clinical, expression, and methylation modalities
- Complete case identification - Find intersection of samples with non-missing values for specified variables
See CODE_REFERENCE.md Phase 5 for full function implementations.
Phase 6: ToolUniverse Annotation
Use ToolUniverse tools to add biological context after computational analysis:
- Gene annotation - Ensembl lookup for coordinates, biotype, cross-references
- Regulatory elements - SCREEN cCREs (enhancers, promoters, insulators)
- ChIPAtlas - Query available ChIP-seq experiments by antigen/cell type
- Ensembl regulatory features - Annotate genomic regions with regulatory overlaps
ENCODE RNA-seq and ATAC-seq datasets
ENCODE_search_rnaseq_experiments: assay_type (string, default "total RNA-seq"), biosample (string/null, e.g. "liver"), limit (int).
Available assay_type values: "total RNA-seq", "polyA plus RNA-seq", "small RNA-seq", "microRNA-seq".
- NOTE: If
total RNA-seq returns 0 results for a biosample, fall back to polyA plus RNA-seq.
{"assay_type": "total RNA-seq", "biosample": "K562", "limit": 5}
// Fallback if 0 results:
{"assay_type": "polyA plus RNA-seq", "biosample": "K562", "limit": 5}
ENCODE_search_histone_experiments: target (string, histone mark name e.g. "H3K27ac"), cell_type (string/null), tissue (alias for cell_type), biosample (alias), limit (int).
Returns {status, data: {total, experiments: [{accession, histone_mark, biosample_summary, status, lab}]}}.
GEO RNA-seq and ATAC-seq datasets
GEO_search_rnaseq_datasets: query (string, free-text keyword), organism (string, default "Homo sapiens"), limit (int, also max_results accepted).
Returns GEO Series accessions (GSExxxxxx) with titles, summaries, sample counts.
GEO_search_atacseq_datasets: query (string), organism (string, default "Homo sapiens"), limit (int, also max_results accepted).
Returns GEO ATAC-seq datasets matching the query.
NOTE: Both limit and max_results are accepted as parameter names for GEO tools.
// GEO RNA-seq for breast cancer
{"query": "breast cancer", "limit": 5}
// GEO ATAC-seq for T cells
{"query": "T cells", "limit": 5}
GTEx expression and eQTL tools
GTEx_get_median_gene_expression: gene_symbol (string). Returns median TPM per tissue across all GTEx tissues.
GTEx_get_expression_summary: gene_symbol (string). Returns clustered median expression.
- NOTE: Use
gene_symbol (e.g. "PCSK9"), NOT a versioned Ensembl ID.
GTEx_query_eqtl: gene_symbol (string), tissue_id (string, exact tissueSiteDetailId), page (int, 1-indexed), size (int, default 10).
- CRITICAL:
tissue_id is case-sensitive and must be exact (e.g. "Whole_Blood", not "whole blood").
- Returns empty array if no significant eQTLs exist for that gene+tissue pair.
// eQTLs for PCSK9 in Whole Blood
{"gene_symbol": "PCSK9", "tissue_id": "Whole_Blood"}
// Median expression across all tissues
{"gene_symbol": "BRCA1"}
See CODE_REFERENCE.md Phase 6 and TOOLS_REFERENCE.md for parameters.
Phase 7: Genome-Wide Statistics
- Comprehensive methylation stats - Global mean/median beta, probe variance, chromosome density
- Differential methylation summary - Count significant, hyper/hypo split, effect sizes
See CODE_REFERENCE.md Phase 7 for full function implementations.
Common Analysis Patterns
| Pattern |
Input |
Key Steps |
Output |
| Differential methylation |
Beta matrix + clinical |
Filter probes -> define groups -> t-test -> FDR -> threshold |
Count of significant DMPs |
| Age-related CpG density |
Beta matrix + manifest + ages |
Correlate with age -> FDR -> map to chr -> density per chr |
Density ratio between chromosomes |
| Multi-omics missing data |
Clinical + expression + methylation |
Extract sample IDs -> intersect -> check NaN |
Complete case count |
| ChIP-seq peak annotation |
BED/narrowPeak + gene annotation |
Load peaks -> annotate to genes -> classify regions |
Fraction in promoters |
| Methylation-expression |
Beta matrix + expression + probe-gene map |
Align samples -> correlate -> FDR |
Significant anti-correlations |
See ANALYSIS_PROCEDURES.md for detailed step-by-step flows and edge case handling.
Key Functions Reference
| Function |
Purpose |
Input |
Output |
load_methylation_data() |
Load beta/M-value matrix |
file path |
DataFrame |
detect_methylation_type() |
Detect beta vs M-values |
DataFrame |
'beta' or 'mvalue' |
filter_cpg_probes() |
Filter probes by criteria |
DataFrame + filters |
filtered DataFrame |
differential_methylation() |
DM analysis between groups |
beta + samples |
DataFrame with padj |
identify_age_related_cpgs() |
Age-correlated CpGs |
beta + ages |
DataFrame with padj |
chromosome_cpg_density() |
CpG density per chromosome |
probes + manifest |
density DataFrame |
genome_wide_average_density() |
Overall genome density |
density DataFrame |
float |
chromosome_density_ratio() |
Ratio between chromosomes |
density + chr names |
float |
load_bed_file() |
Load BED/narrowPeak |
file path |
DataFrame |
peak_statistics() |
Basic peak stats |
BED DataFrame |
dict |
annotate_peaks_to_genes() |
Annotate peaks to genes |
peaks + genes |
annotated DataFrame |
find_overlaps() |
Peak overlap analysis |
two BED DataFrames |
overlap DataFrame |
missing_data_analysis() |
Cross-modality completeness |
multiple DataFrames |
dict |
correlate_methylation_expression() |
Meth-expression correlation |
beta + expression |
correlation DataFrame |
ToolUniverse Tools Used
Regulatory Annotation Tools
ensembl_lookup_gene - Gene coordinates, biotype (REQUIRES species='homo_sapiens')
ensembl_get_regulatory_features - Regulatory features by region (NO "chr" prefix in region)
ensembl_get_overlap_features - Gene/transcript overlap data
SCREEN_get_regulatory_elements - cCREs: enhancers, promoters, insulators
ReMap_get_transcription_factor_binding - TF binding sites
RegulomeDB_query_variant - Variant regulatory score
jaspar_search_matrices - TF binding matrices
ENCODE_search_experiments - Experiment metadata (assay_title must be "TF ChIP-seq" not "ChIP-seq")
ENCODE_search_rnaseq_experiments - RNA-seq experiments (assay_type: "total RNA-seq" or "polyA plus RNA-seq")
ENCODE_search_histone_experiments - Histone ChIP-seq experiments by mark and cell type
GEO_search_rnaseq_datasets - GEO RNA-seq datasets (limit or max_results accepted)
GEO_search_atacseq_datasets - GEO ATAC-seq datasets (limit or max_results accepted)
GTEx_get_median_gene_expression - Median TPM across GTEx tissues
GTEx_get_expression_summary - Clustered expression summary
GTEx_query_eqtl - eQTL associations (tissue_id must be exact, e.g. 'Whole_Blood')
ChIPAtlas_get_experiments - ChIP-seq experiments (REQUIRES operation param)
ChIPAtlas_search_datasets - Dataset search (REQUIRES operation param)
ChIPAtlas_enrichment_analysis - Enrichment from BED/motifs/genes
ChIPAtlas_get_peak_data - Peak data download (REQUIRES operation param)
FourDN_search_data - Chromatin conformation data (REQUIRES operation param)
Gene Annotation Tools
MyGene_query_genes - Gene query
MyGene_batch_query - Batch gene query
HGNC_fetch_gene_by_symbol - Gene symbol, aliases, IDs
GO_get_annotations_for_gene - GO annotations
Sequencing Data Retrieval Tools (SRA)
SRA_search_experiments - Search NCBI SRA for raw sequencing experiments by keyword, organism, library strategy, or platform
SRA_get_experiment - Get detailed metadata for a specific SRA experiment by accession
Use SRA tools to find raw epigenomics sequencing data (ChIP-seq, Bisulfite-Seq, ATAC-seq) for cross-study comparison or to identify available datasets for a tissue/condition.
| Tool |
Key Parameters |
Returns |
SRA_search_experiments |
query (free text), organism (e.g. "Homo sapiens"), library_strategy ("ChIP-Seq", "Bisulfite-Seq", "ATAC-seq"), platform ("ILLUMINA"), limit |
{data: {total, returned, experiments: [{uid, title, organism, library_strategy, experiment_accession, study_accession, bioproject}]}} |
SRA_get_experiment |
accession (SRX/ERX/DRX/SRP/ERP/DRP) |
Full experiment metadata with runs |
# Example: Find ATAC-seq experiments for human liver
result = tu.tools.SRA_search_experiments(
query="liver", organism="Homo sapiens",
library_strategy="ATAC-seq", limit=5
)
# Example: Find Bisulfite-Seq for breast cancer
result = tu.tools.SRA_search_experiments(
query="breast cancer", library_strategy="Bisulfite-Seq", limit=5
)
See TOOLS_REFERENCE.md for full parameter details and return schemas.
Data Format Notes
- Methylation data: Probes (rows) x samples (columns), beta values 0-1
- BED files: Tab-separated, 0-based half-open coordinates
- narrowPeak: 10-column BED extension with signalValue, pValue, qValue, peak
- Illumina manifests: Probe ID, chromosome, position, gene annotation
- Clinical data: Patient/sample-centric with clinical variables as columns
Genome Builds Supported
| Build |
Species |
Autosomes |
Sex Chromosomes |
| hg38 (GRCh38) |
Human |
chr1-chr22 |
chrX, chrY |
| hg19 (GRCh37) |
Human |
chr1-chr22 |
chrX, chrY |
| mm10 (GRCm38) |
Mouse |
chr1-chr19 |
chrX, chrY |
GTEx Tissue Site Detail IDs (common)
| Tissue |
tissueSiteDetailId |
| Whole Blood |
Whole_Blood |
| Liver |
Liver |
| Lung |
Lung |
| Breast |
Breast_Mammary_Tissue |
| Brain Cortex |
Brain_Cortex |
| Heart Left Ventricle |
Heart_Left_Ventricle |
| Kidney Cortex |
Kidney_Cortex |
| Thyroid |
Thyroid |
| Adipose Subcutaneous |
Adipose_Subcutaneous |
| Muscle Skeletal |
Muscle_Skeletal |
Reasoning Framework for Result Interpretation
Evidence Grading
| Grade |
Criteria |
Example |
| Strong |
padj < 0.01 AND abs(delta-beta) >= 0.2, replicated across cohorts |
DMP with padj = 1e-8, delta-beta = 0.35 in two independent datasets |
| Moderate |
padj < 0.05 AND abs(delta-beta) >= 0.1 |
DMP with padj = 0.02, delta-beta = 0.15 |
| Weak |
padj < 0.05 but abs(delta-beta) < 0.1 |
Statistically significant but biologically marginal change |
| Insufficient |
padj >= 0.05 or no biological replication |
Sub-threshold after FDR correction |
Interpretation Guidance
- Methylation delta-beta cutoffs: A delta-beta (mean beta difference between groups) of 0.1 (10%) is a common minimum threshold for biological relevance on 450K/EPIC arrays. Delta-beta >= 0.2 is considered a strong effect. Statistical significance alone (small p-value) without meaningful delta-beta often reflects technical noise in large-sample studies.
- ChIP-seq peak quality: Assess peaks by q-value (< 0.01 for high confidence), signal-to-noise ratio, and IDR (irreproducible discovery rate < 0.05 across replicates). Peaks with FE (fold enrichment) < 2 should be treated cautiously. Broad marks (H3K27me3, H3K36me3) have wider peaks than sharp marks (H3K4me3, CTCF).
- ATAC-seq accessibility interpretation: Nucleosome-free regions (NFR, < 150 bp fragments) indicate active regulatory elements. Peaks at promoters (TSS +/- 2kb) suggest active transcription. Distal peaks often mark enhancers. Peak width and fragment size distribution are quality indicators -- a clear NFR peak with nucleosomal periodicity indicates good library quality.
- Multiple testing: Always apply FDR correction (Benjamini-Hochberg) when testing thousands of CpG sites or peaks. Report both nominal and adjusted p-values.
- Genome build consistency: Verify all data uses the same build (hg19 vs hg38) before overlapping methylation sites with ChIP-seq peaks or regulatory annotations.
Synthesis Questions
- Do differentially methylated positions (DMPs) meeting both statistical and effect-size thresholds cluster in regulatory regions (promoters, enhancers), or are they scattered across the genome?
- For ChIP-seq data, do peaks replicate across biological replicates (IDR analysis), and do they overlap with expected genomic features for the histone mark (e.g., H3K4me3 at promoters)?
- When integrating methylation and accessibility data, do hypomethylated regions correspond to ATAC-seq open chromatin peaks, supporting a consistent regulatory model?
- Are age-related or condition-related CpG changes enriched in known epigenetic clock CpGs, or do they represent novel associations?
- Does the observed methylation change at a locus correlate with expression change of the nearest gene, or is the CpG in a region with no clear regulatory function?
Limitations
- No native pybedtools: uses pure Python interval operations
- No native pyBigWig: cannot read BigWig files directly without package
- No R bridge: does not use methylKit, ChIPseeker, or DiffBind
- Illumina-centric: methylation functions designed for 450K/EPIC arrays
- Uses t-test/Wilcoxon for differential methylation (not limma/bumphunter)
- No peak calling: assumes peaks are pre-called
- API rate limits: ToolUniverse annotation limited to ~20 genes per batch
Reference Files
CODE_REFERENCE.md - Full Python function implementations for all phases
TOOLS_REFERENCE.md - ToolUniverse tool parameter details and return schemas
ANALYSIS_PROCEDURES.md - Decision trees, step-by-step analysis patterns, edge cases, fallback strategies
QUICK_START.md - Quick start examples for common analysis types
Source: wiederse/mindscience — distributed by TomeVault.
1---2name: tooluniverse-epigenomics3description: Production-ready genomics and epigenomics data processing for BixBench questions. Handles methylation array analysis (CpG filtering, differential methylation, age-related CpG detection, chromosome-level density), ChIP-seq peak analysis (peak calling, motif enrichment, coverage stats), ATAC-seq chromatin accessibility, multi-omics integration (expression + methylation correlation), and genome-wide statistics. Pure Python computation (pandas, scipy, numpy, pysam, statsmodels) plus ToolUniverse annotation tools (Ensembl, ENCODE, SCREEN, JASPAR, ReMap, RegulomeDB, ChIPAtlas). Supports BED, BigWig, methylation beta-value matrices, Illumina manifest files, and multi-sample clinical data. Use when processing methylation data, ChIP-seq peaks, ATAC-seq signals, or answering questions about CpG sites, differential methylation, chromatin accessibility, histone marks, or epigenomic statistics. Use when this capability is needed.4---56# Genomics and Epigenomics Data Processing78Production-ready computational skill for processing and analyzing epigenomics data. Combines local Python computation (pandas, scipy, numpy, pysam, statsmodels) with ToolUniverse annotation tools for regulatory context. Designed to solve BixBench-style questions about methylation, ChIP-seq, ATAC-seq, and multi-omics integration.910## When to Use This Skill1112**Triggers**:13- User provides methylation data (beta-value matrices, Illumina arrays) and asks about CpG sites14- Questions about differential methylation analysis15- Age-related CpG detection or epigenetic clock questions16- Chromosome-level methylation density or statistics17- ChIP-seq peak files (BED format) with analysis questions18- ATAC-seq chromatin accessibility questions19- Multi-omics integration (expression + methylation, expression + ChIP-seq)20- Genome-wide epigenomic statistics21- Questions mentioning "methylation", "CpG", "ChIP-seq", "ATAC-seq", "histone", "chromatin", "epigenetic"22- Questions about missing data across clinical/genomic/epigenomic modalities23- Regulatory element annotation for processed epigenomic data2425**Example Questions**:261. "How many patients have no missing data for vital status, gene expression, and methylation data?"272. "What is the ratio of filtered age-related CpG density between chromosomes?"283. "What is the genome-wide average chromosomal density of unique age-related CpGs per base pair?"294. "How many CpG sites show significant differential methylation (padj < 0.05)?"305. "What is the Pearson correlation between methylation and expression for gene X?"316. "How many ChIP-seq peaks overlap with promoter regions?"327. "What fraction of ATAC-seq peaks are in enhancer regions?"338. "Which chromosome has the highest density of hypermethylated CpGs?"349. "Filter CpG sites by variance > threshold and map to nearest genes"3510. "What is the average beta value difference between tumor and normal for chromosome 17?"3637**NOT for** (use other skills instead):38- Gene regulation lookup without data files -> Use existing epigenomics annotation pattern39- RNA-seq differential expression -> Use `tooluniverse-rnaseq-deseq2`40- Variant calling/annotation from VCF -> Use `tooluniverse-variant-analysis`41- Gene enrichment analysis -> Use `tooluniverse-gene-enrichment`42- Protein structure analysis -> Use `tooluniverse-protein-structure-retrieval`4344---4546## Required Python Packages4748```python49# Core (MUST be available)50import pandas as pd51import numpy as np52from scipy import stats53import statsmodels.stats.multitest as mt5455# Optional but useful56import pysam # BAM/CRAM file access57import gseapy # Enrichment of genes from methylation analysis5859# ToolUniverse (for annotation)60from tooluniverse import ToolUniverse61```6263---6465## Key Principles66671. **Data-first approach** - Load and inspect data files BEFORE any analysis682. **Question-driven** - Parse what the user is actually asking and extract the specific numeric answer693. **File format detection** - Automatically detect methylation arrays, BED files, BigWig, clinical data704. **Coordinate system awareness** - Track genome build (hg19, hg38, mm10), handle chr prefix differences715. **Statistical rigor** - Proper multiple testing correction, effect size filtering, sample size awareness726. **Missing data handling** - Explicitly report and handle NaN/missing values737. **Chromosome normalization** - Always normalize chromosome names (chr1 vs 1, chrX vs X)748. **CpG site identification** - Parse Illumina probe IDs (cg/ch probes), genomic coordinates759. **Report-first** - Create output file first, populate progressively7610. **English-first queries** - Use English in all tool calls7778---7980## Workflow Overview8182### Phase 0: Question Parsing and Data Discovery8384Before writing any code, parse the question to identify:85- What data files are available (methylation, ChIP-seq, ATAC-seq, clinical, expression, manifest)86- What specific statistic or answer is being asked for87- What thresholds apply (significance, effect size, variance, chromosome filters)88- What genome build to use8990Categorize files by scanning for keywords: methyl/beta/cpg/illumina, chip/peak/narrowpeak, atac/accessibility, clinical/patient/sample, express/rnaseq/fpkm, manifest/annotation/probe.9192See `ANALYSIS_PROCEDURES.md` for the full decision tree and parameter extraction table.9394### Phase 1: Methylation Data Processing9596Core functions for methylation analysis:97- **Load methylation data** - Supports CSV, TSV, parquet, HDF5; auto-detects beta vs M-values98- **Load probe manifest** - Illumina 450K/EPIC manifest with chromosome, position, gene annotation99- **CpG filtering** - Filter by variance, missing rate, probe type (cg/ch), chromosome, CpG island relation, gene group100- **Differential methylation** - T-test/Wilcoxon/KS between groups with FDR correction; identify DMPs (hyper/hypo)101- **Age-related CpG analysis** - Pearson/Spearman correlation of probes with age, FDR correction102- **Chromosome-level density** - CpG count per chromosome divided by chromosome length; density ratios; genome-wide average103104See `CODE_REFERENCE.md` Phase 1 for full function implementations.105106### Phase 2: ChIP-seq Peak Analysis107108- **Load BED/narrowPeak/broadPeak** - Auto-detect format, normalize chromosomes109- **Peak statistics** - Count, length distribution, signal values, q-values110- **Peak annotation** - Map peaks to nearest gene, classify as promoter/gene_body/proximal/distal111- **Peak overlap** - Pure Python interval intersection between two BED files; Jaccard similarity112113See `CODE_REFERENCE.md` Phase 2 for full function implementations.114115### Phase 3: ATAC-seq Analysis116117- **Load ATAC peaks** - Wrapper around BED loader for narrowPeak format118- **ATAC-specific stats** - Nucleosome-free region (NFR) detection (<150bp peaks), region classification119- **Chromatin accessibility by region** - Distribution of open chromatin across promoter/enhancer/intergenic120121See `CODE_REFERENCE.md` Phase 3 for full function implementations.122123### Phase 4: Multi-Omics Integration124125- **Methylation-expression correlation** - Align samples, compute per-probe-gene Pearson/Spearman with FDR126- **ChIP-seq + expression** - Find genes with promoter peaks and compare expression levels127128See `CODE_REFERENCE.md` Phase 4 for full function implementations.129130### Phase 5: Clinical Data Integration131132- **Missing data analysis** - Count samples present across clinical, expression, and methylation modalities133- **Complete case identification** - Find intersection of samples with non-missing values for specified variables134135See `CODE_REFERENCE.md` Phase 5 for full function implementations.136137### Phase 6: ToolUniverse Annotation138139Use ToolUniverse tools to add biological context after computational analysis:140- **Gene annotation** - Ensembl lookup for coordinates, biotype, cross-references141- **Regulatory elements** - SCREEN cCREs (enhancers, promoters, insulators)142- **ChIPAtlas** - Query available ChIP-seq experiments by antigen/cell type143- **Ensembl regulatory features** - Annotate genomic regions with regulatory overlaps144145#### ENCODE RNA-seq and ATAC-seq datasets146147**ENCODE_search_rnaseq_experiments**: `assay_type` (string, default "total RNA-seq"), `biosample` (string/null, e.g. "liver"), `limit` (int).148Available assay_type values: `"total RNA-seq"`, `"polyA plus RNA-seq"`, `"small RNA-seq"`, `"microRNA-seq"`.149- NOTE: If `total RNA-seq` returns 0 results for a biosample, fall back to `polyA plus RNA-seq`.150151```json152{"assay_type": "total RNA-seq", "biosample": "K562", "limit": 5}153// Fallback if 0 results:154{"assay_type": "polyA plus RNA-seq", "biosample": "K562", "limit": 5}155```156157**ENCODE_search_histone_experiments**: `target` (string, histone mark name e.g. "H3K27ac"), `cell_type` (string/null), `tissue` (alias for cell_type), `biosample` (alias), `limit` (int).158Returns `{status, data: {total, experiments: [{accession, histone_mark, biosample_summary, status, lab}]}}`.159160#### GEO RNA-seq and ATAC-seq datasets161162**GEO_search_rnaseq_datasets**: `query` (string, free-text keyword), `organism` (string, default "Homo sapiens"), `limit` (int, also `max_results` accepted).163Returns GEO Series accessions (GSExxxxxx) with titles, summaries, sample counts.164165**GEO_search_atacseq_datasets**: `query` (string), `organism` (string, default "Homo sapiens"), `limit` (int, also `max_results` accepted).166Returns GEO ATAC-seq datasets matching the query.167168NOTE: Both `limit` and `max_results` are accepted as parameter names for GEO tools.169170```json171// GEO RNA-seq for breast cancer172{"query": "breast cancer", "limit": 5}173174// GEO ATAC-seq for T cells175{"query": "T cells", "limit": 5}176```177178#### GTEx expression and eQTL tools179180**GTEx_get_median_gene_expression**: `gene_symbol` (string). Returns median TPM per tissue across all GTEx tissues.181182**GTEx_get_expression_summary**: `gene_symbol` (string). Returns clustered median expression.183- NOTE: Use `gene_symbol` (e.g. "PCSK9"), NOT a versioned Ensembl ID.184185**GTEx_query_eqtl**: `gene_symbol` (string), `tissue_id` (string, exact tissueSiteDetailId), `page` (int, 1-indexed), `size` (int, default 10).186- CRITICAL: `tissue_id` is case-sensitive and must be exact (e.g. `"Whole_Blood"`, not `"whole blood"`).187- Returns empty array if no significant eQTLs exist for that gene+tissue pair.188189```json190// eQTLs for PCSK9 in Whole Blood191{"gene_symbol": "PCSK9", "tissue_id": "Whole_Blood"}192193// Median expression across all tissues194{"gene_symbol": "BRCA1"}195```196197See `CODE_REFERENCE.md` Phase 6 and `TOOLS_REFERENCE.md` for parameters.198199### Phase 7: Genome-Wide Statistics200201- **Comprehensive methylation stats** - Global mean/median beta, probe variance, chromosome density202- **Differential methylation summary** - Count significant, hyper/hypo split, effect sizes203204See `CODE_REFERENCE.md` Phase 7 for full function implementations.205206---207208## Common Analysis Patterns209210| Pattern | Input | Key Steps | Output |211|---------|-------|-----------|--------|212| Differential methylation | Beta matrix + clinical | Filter probes -> define groups -> t-test -> FDR -> threshold | Count of significant DMPs |213| Age-related CpG density | Beta matrix + manifest + ages | Correlate with age -> FDR -> map to chr -> density per chr | Density ratio between chromosomes |214| Multi-omics missing data | Clinical + expression + methylation | Extract sample IDs -> intersect -> check NaN | Complete case count |215| ChIP-seq peak annotation | BED/narrowPeak + gene annotation | Load peaks -> annotate to genes -> classify regions | Fraction in promoters |216| Methylation-expression | Beta matrix + expression + probe-gene map | Align samples -> correlate -> FDR | Significant anti-correlations |217218See `ANALYSIS_PROCEDURES.md` for detailed step-by-step flows and edge case handling.219220---221222## Key Functions Reference223224| Function | Purpose | Input | Output |225|----------|---------|-------|--------|226| `load_methylation_data()` | Load beta/M-value matrix | file path | DataFrame |227| `detect_methylation_type()` | Detect beta vs M-values | DataFrame | 'beta' or 'mvalue' |228| `filter_cpg_probes()` | Filter probes by criteria | DataFrame + filters | filtered DataFrame |229| `differential_methylation()` | DM analysis between groups | beta + samples | DataFrame with padj |230| `identify_age_related_cpgs()` | Age-correlated CpGs | beta + ages | DataFrame with padj |231| `chromosome_cpg_density()` | CpG density per chromosome | probes + manifest | density DataFrame |232| `genome_wide_average_density()` | Overall genome density | density DataFrame | float |233| `chromosome_density_ratio()` | Ratio between chromosomes | density + chr names | float |234| `load_bed_file()` | Load BED/narrowPeak | file path | DataFrame |235| `peak_statistics()` | Basic peak stats | BED DataFrame | dict |236| `annotate_peaks_to_genes()` | Annotate peaks to genes | peaks + genes | annotated DataFrame |237| `find_overlaps()` | Peak overlap analysis | two BED DataFrames | overlap DataFrame |238| `missing_data_analysis()` | Cross-modality completeness | multiple DataFrames | dict |239| `correlate_methylation_expression()` | Meth-expression correlation | beta + expression | correlation DataFrame |240241---242243## ToolUniverse Tools Used244245### Regulatory Annotation Tools246- `ensembl_lookup_gene` - Gene coordinates, biotype (REQUIRES `species='homo_sapiens'`)247- `ensembl_get_regulatory_features` - Regulatory features by region (NO "chr" prefix in region)248- `ensembl_get_overlap_features` - Gene/transcript overlap data249- `SCREEN_get_regulatory_elements` - cCREs: enhancers, promoters, insulators250- `ReMap_get_transcription_factor_binding` - TF binding sites251- `RegulomeDB_query_variant` - Variant regulatory score252- `jaspar_search_matrices` - TF binding matrices253- `ENCODE_search_experiments` - Experiment metadata (assay_title must be "TF ChIP-seq" not "ChIP-seq")254- `ENCODE_search_rnaseq_experiments` - RNA-seq experiments (assay_type: "total RNA-seq" or "polyA plus RNA-seq")255- `ENCODE_search_histone_experiments` - Histone ChIP-seq experiments by mark and cell type256- `GEO_search_rnaseq_datasets` - GEO RNA-seq datasets (limit or max_results accepted)257- `GEO_search_atacseq_datasets` - GEO ATAC-seq datasets (limit or max_results accepted)258- `GTEx_get_median_gene_expression` - Median TPM across GTEx tissues259- `GTEx_get_expression_summary` - Clustered expression summary260- `GTEx_query_eqtl` - eQTL associations (tissue_id must be exact, e.g. 'Whole_Blood')261- `ChIPAtlas_get_experiments` - ChIP-seq experiments (REQUIRES `operation` param)262- `ChIPAtlas_search_datasets` - Dataset search (REQUIRES `operation` param)263- `ChIPAtlas_enrichment_analysis` - Enrichment from BED/motifs/genes264- `ChIPAtlas_get_peak_data` - Peak data download (REQUIRES `operation` param)265- `FourDN_search_data` - Chromatin conformation data (REQUIRES `operation` param)266267### Gene Annotation Tools268- `MyGene_query_genes` - Gene query269- `MyGene_batch_query` - Batch gene query270- `HGNC_fetch_gene_by_symbol` - Gene symbol, aliases, IDs271- `GO_get_annotations_for_gene` - GO annotations272273### Sequencing Data Retrieval Tools (SRA)274- `SRA_search_experiments` - Search NCBI SRA for raw sequencing experiments by keyword, organism, library strategy, or platform275- `SRA_get_experiment` - Get detailed metadata for a specific SRA experiment by accession276277Use SRA tools to find raw epigenomics sequencing data (ChIP-seq, Bisulfite-Seq, ATAC-seq) for cross-study comparison or to identify available datasets for a tissue/condition.278279| Tool | Key Parameters | Returns |280|------|----------------|---------|281| `SRA_search_experiments` | `query` (free text), `organism` (e.g. "Homo sapiens"), `library_strategy` ("ChIP-Seq", "Bisulfite-Seq", "ATAC-seq"), `platform` ("ILLUMINA"), `limit` | `{data: {total, returned, experiments: [{uid, title, organism, library_strategy, experiment_accession, study_accession, bioproject}]}}` |282| `SRA_get_experiment` | `accession` (SRX/ERX/DRX/SRP/ERP/DRP) | Full experiment metadata with runs |283284```python285# Example: Find ATAC-seq experiments for human liver286result = tu.tools.SRA_search_experiments(287 query="liver", organism="Homo sapiens",288 library_strategy="ATAC-seq", limit=5289)290291# Example: Find Bisulfite-Seq for breast cancer292result = tu.tools.SRA_search_experiments(293 query="breast cancer", library_strategy="Bisulfite-Seq", limit=5294)295```296297See `TOOLS_REFERENCE.md` for full parameter details and return schemas.298299---300301## Data Format Notes302303- **Methylation data**: Probes (rows) x samples (columns), beta values 0-1304- **BED files**: Tab-separated, 0-based half-open coordinates305- **narrowPeak**: 10-column BED extension with signalValue, pValue, qValue, peak306- **Illumina manifests**: Probe ID, chromosome, position, gene annotation307- **Clinical data**: Patient/sample-centric with clinical variables as columns308309## Genome Builds Supported310311| Build | Species | Autosomes | Sex Chromosomes |312|-------|---------|-----------|-----------------|313| hg38 (GRCh38) | Human | chr1-chr22 | chrX, chrY |314| hg19 (GRCh37) | Human | chr1-chr22 | chrX, chrY |315| mm10 (GRCm38) | Mouse | chr1-chr19 | chrX, chrY |316317## GTEx Tissue Site Detail IDs (common)318319| Tissue | tissueSiteDetailId |320|--------|-------------------|321| Whole Blood | Whole_Blood |322| Liver | Liver |323| Lung | Lung |324| Breast | Breast_Mammary_Tissue |325| Brain Cortex | Brain_Cortex |326| Heart Left Ventricle | Heart_Left_Ventricle |327| Kidney Cortex | Kidney_Cortex |328| Thyroid | Thyroid |329| Adipose Subcutaneous | Adipose_Subcutaneous |330| Muscle Skeletal | Muscle_Skeletal |331332## Reasoning Framework for Result Interpretation333334### Evidence Grading335336| Grade | Criteria | Example |337|-------|----------|---------|338| **Strong** | padj < 0.01 AND abs(delta-beta) >= 0.2, replicated across cohorts | DMP with padj = 1e-8, delta-beta = 0.35 in two independent datasets |339| **Moderate** | padj < 0.05 AND abs(delta-beta) >= 0.1 | DMP with padj = 0.02, delta-beta = 0.15 |340| **Weak** | padj < 0.05 but abs(delta-beta) < 0.1 | Statistically significant but biologically marginal change |341| **Insufficient** | padj >= 0.05 or no biological replication | Sub-threshold after FDR correction |342343### Interpretation Guidance344345- **Methylation delta-beta cutoffs**: A delta-beta (mean beta difference between groups) of 0.1 (10%) is a common minimum threshold for biological relevance on 450K/EPIC arrays. Delta-beta >= 0.2 is considered a strong effect. Statistical significance alone (small p-value) without meaningful delta-beta often reflects technical noise in large-sample studies.346- **ChIP-seq peak quality**: Assess peaks by q-value (< 0.01 for high confidence), signal-to-noise ratio, and IDR (irreproducible discovery rate < 0.05 across replicates). Peaks with FE (fold enrichment) < 2 should be treated cautiously. Broad marks (H3K27me3, H3K36me3) have wider peaks than sharp marks (H3K4me3, CTCF).347- **ATAC-seq accessibility interpretation**: Nucleosome-free regions (NFR, < 150 bp fragments) indicate active regulatory elements. Peaks at promoters (TSS +/- 2kb) suggest active transcription. Distal peaks often mark enhancers. Peak width and fragment size distribution are quality indicators -- a clear NFR peak with nucleosomal periodicity indicates good library quality.348- **Multiple testing**: Always apply FDR correction (Benjamini-Hochberg) when testing thousands of CpG sites or peaks. Report both nominal and adjusted p-values.349- **Genome build consistency**: Verify all data uses the same build (hg19 vs hg38) before overlapping methylation sites with ChIP-seq peaks or regulatory annotations.350351### Synthesis Questions3523531. Do differentially methylated positions (DMPs) meeting both statistical and effect-size thresholds cluster in regulatory regions (promoters, enhancers), or are they scattered across the genome?3542. For ChIP-seq data, do peaks replicate across biological replicates (IDR analysis), and do they overlap with expected genomic features for the histone mark (e.g., H3K4me3 at promoters)?3553. When integrating methylation and accessibility data, do hypomethylated regions correspond to ATAC-seq open chromatin peaks, supporting a consistent regulatory model?3564. Are age-related or condition-related CpG changes enriched in known epigenetic clock CpGs, or do they represent novel associations?3575. Does the observed methylation change at a locus correlate with expression change of the nearest gene, or is the CpG in a region with no clear regulatory function?358359---360361## Limitations362363- No native pybedtools: uses pure Python interval operations364- No native pyBigWig: cannot read BigWig files directly without package365- No R bridge: does not use methylKit, ChIPseeker, or DiffBind366- Illumina-centric: methylation functions designed for 450K/EPIC arrays367- Uses t-test/Wilcoxon for differential methylation (not limma/bumphunter)368- No peak calling: assumes peaks are pre-called369- API rate limits: ToolUniverse annotation limited to ~20 genes per batch370371---372373## Reference Files374375- `CODE_REFERENCE.md` - Full Python function implementations for all phases376- `TOOLS_REFERENCE.md` - ToolUniverse tool parameter details and return schemas377- `ANALYSIS_PROCEDURES.md` - Decision trees, step-by-step analysis patterns, edge cases, fallback strategies378- `QUICK_START.md` - Quick start examples for common analysis types379380---381> Source: [wiederse/mindscience](https://github.com/wiederse/mindscience) — distributed by [TomeVault](https://tomevault.io).382<!-- tomevault:4.0:skill_md:2026-06-15 -->