Claude Cursor Skill

motif-analysis

Guide for de novo and known motif enrichment analysis of ENCODE ChIP-seq and ATAC-seq peaks using HOMER and MEME Suite. Use when users need to discover TF binding motifs in peaks, validate ChIP-seq targets, or find co-binding partners. Trigger on: motif analysis, HOMER, MEME, de

LLM Mart · 0 points · 0 views 0 listing impressions 0 install-command copies
Virus-scanned Reviewed automatically before listing.

Full trust report

Download ammawla-encode-toolkit-plugin_skills_motif-analysis-36836c8.zip · 14 KB
Part of ammawla/encode-toolkit — 90 skills

Install

skills CLI npx skills add https://github.com/ammawla/encode-toolkit/tree/main/plugin/skills/motif-analysis
Claude Code claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install ammawla-encode-toolkit@llmmart
Git git clone https://github.com/ammawla/encode-toolkit.git

The skills CLI installs just this skill, for any of its supported agents. Claude Code installs the whole ammawla/encode-toolkit collection as a plugin from our marketplace. Git is the plain clone.

Skill manifest

Motif Analysis of ENCODE Peak Data

When to Use

  • User wants to discover transcription factor binding motifs in ChIP-seq or ATAC-seq peaks
  • User asks about "motif enrichment", "HOMER", "MEME", or "de novo motif discovery"
  • User needs to validate ChIP-seq targets by checking if the expected motif is enriched
  • User wants to find co-binding partners or co-factor motifs in peak regions
  • Example queries: "find motifs in my CTCF peaks", "run HOMER on ATAC-seq peaks", "what TFs co-bind with p300 in liver?"

Help the user perform de novo and known motif enrichment analysis on ENCODE ChIP-seq and ATAC-seq peaks. Motif analysis serves two critical purposes: (1) validating that ChIP-seq experiments pulled down the expected transcription factor, and (2) discovering co-regulatory partners that co-bind with the target factor. This skill covers the two major tool suites -- HOMER and MEME Suite -- from input preparation through result interpretation.

Literature Foundation

Reference Journal Key Contribution DOI Citations
Heinz et al. (2010) Molecular Cell HOMER: Simple combinations of lineage-determining TFs prime cis-regulatory elements; introduced findMotifsGenome.pl for ChIP-seq motif analysis 10.1016/j.molcel.2010.05.004 ~6,000
Bailey et al. (2009) Nucleic Acids Research MEME Suite: comprehensive tools for motif discovery (MEME), enrichment (AME), scanning (FIMO), and spacing (SpaMo) 10.1093/nar/gkp335 ~2,500
Bailey & Elkan (1994) ISMB Foundational MEME algorithm: expectation maximization for discovering ungapped motifs in biopolymers PMID: 7584402 ~4,000
Machanick & Bailey (2011) Bioinformatics MEME-ChIP: all-in-one motif analysis pipeline optimized for large ChIP-seq datasets 10.1093/bioinformatics/btr189 ~1,800
Fornes et al. (2020) Nucleic Acids Research JASPAR 2020: curated, non-redundant TF binding profile database; standard reference for known motifs 10.1093/nar/gkz1001 ~2,200
Amemiya et al. (2019) Scientific Reports ENCODE Blacklist: regions producing artifact signal that can generate spurious motif hits 10.1038/s41598-019-45839-z ~1,372

Prerequisites: Input Preparation

Obtaining ENCODE Peaks

Search for and download ChIP-seq or ATAC-seq peaks:

encode_search_experiments(
    assay_title="TF ChIP-seq",
    target="CTCF",
    organ="pancreas",
    biosample_type="tissue"
)

encode_list_files(
    experiment_accession="ENCSR...",
    file_format="bed",
    output_type="IDR thresholded peaks",
    assembly="GRCh38",
    preferred_default=True
)

encode_download_files(
    file_accessions=["ENCFF..."],
    download_dir="/data/motif_analysis/"
)

Preparing Sequences from Peaks

Motif analysis requires DNA sequences, not just genomic coordinates. Extract sequences centered on peak summits:

# For TF ChIP-seq: extract summit +/- 100bp (200bp window)
awk 'BEGIN{OFS="\t"} {summit=$2+$10; print $1, summit-100, summit+100, $4, $5}' \
    peaks.narrowPeak > summits_200bp.bed

# Remove blacklisted regions (Amemiya et al. 2019)
bedtools intersect -a summits_200bp.bed \
    -b hg38-blacklist.v2.bed -v > summits_clean.bed

# Extract FASTA sequences (requires genome FASTA)
bedtools getfasta -fi hg38.fa -bed summits_clean.bed -fo summits.fa

# For ATAC-seq: use full peak regions (typically 200-500bp)
bedtools getfasta -fi hg38.fa -bed atac_peaks_clean.bed -fo atac_peaks.fa

Critical: For TF ChIP-seq, always center on the summit (column 10 in narrowPeak format) and use a narrow window (150-250bp). Using the full peak region dilutes the motif signal because TF binding sites are concentrated at the summit. For histone ChIP-seq, use the full peak or a broader window because histone marks cover larger domains.

Subsampling Large Peak Sets

For peak sets larger than 50,000, subsample the top peaks by signal strength:

# Sort by signalValue (column 7) descending, take top 10,000
sort -k7,7nr summits_clean.bed | head -10000 > top10k_summits.bed
bedtools getfasta -fi hg38.fa -bed top10k_summits.bed -fo top10k_summits.fa

This improves speed without sacrificing sensitivity, as the strongest peaks contain the most consistent motif instances.

Part 1: HOMER findMotifsGenome

HOMER (Heinz et al. 2010) performs both de novo motif discovery and known motif enrichment in a single command. It is the most widely used tool for ChIP-seq motif analysis.

1a. Basic Usage

findMotifsGenome.pl peaks.bed hg38 homer_output/ \
    -size 200 \
    -mask \
    -p 8 \
    -preparsedDir /data/homer_preparsed/

Key parameters:

Parameter Value Rationale
-size 200 (TF ChIP-seq) Window around peak center; 200bp captures typical TF binding site + flanking context
-size given (histone ChIP-seq) Use actual peak boundaries for broad marks
-mask always include Mask repeat sequences to avoid spurious repeat-derived motifs
-p 8 (or available cores) Parallel threads for speed
-preparsedDir reusable directory Cache parsed genome for repeated runs
-bg background.bed (optional) Custom background regions; default uses matched GC regions from genome
-mknown motifs.motif (optional) Test specific known motifs in addition to default database
-len 8,10,12 (default) Motif lengths to search; default covers most TF motifs

1b. Output Structure

HOMER produces a structured output directory:

homer_output/
    homerResults.html         # De novo motif results (interactive HTML)
    knownResults.html         # Known motif enrichment results
    homerResults/
        motif1.motif          # Position weight matrix for each de novo motif
        motif2.motif
        ...
    knownResults/
        known1.motif          # Matched known motif PWMs
        ...
    homerMotifs.all.motifs    # All de novo motifs in one file
    seq.autonorm.tsv          # Normalization statistics

1c. HOMER for ATAC-seq Peaks

ATAC-seq peaks represent accessible chromatin, not specific TF binding. Motif analysis on ATAC peaks reveals which TFs occupy accessible regions:

findMotifsGenome.pl atac_peaks.bed hg38 homer_atac_output/ \
    -size given \
    -mask \
    -p 8

Use -size given for ATAC-seq to analyze the full accessible region rather than a fixed window.

Part 2: MEME-ChIP Suite

The MEME Suite (Bailey et al. 2009) provides a complementary approach with different algorithms and additional capabilities for motif spacing analysis and scanning.

2a. MEME-ChIP: All-in-One Pipeline

MEME-ChIP runs five tools sequentially: MEME (de novo discovery), DREME (short motif discovery), CentriMo (motif centrality), AME (known motif enrichment), and SpaMo (motif spacing).

meme-chip \
    -meme-maxw 30 \
    -meme-nmotifs 10 \
    -meme-minw 6 \
    -db JASPAR2024_CORE_vertebrates.meme \
    -o memechip_output/ \
    summits.fa

Required input: FASTA file of peak sequences (not BED coordinates -- MEME Suite works on sequences, not genomic intervals).

Key parameters:

Parameter Value Purpose
-meme-maxw 30 Maximum motif width; 30 covers most TF motifs
-meme-minw 6 Minimum motif width
-meme-nmotifs 10 Number of de novo motifs to find
-db JASPAR file Known motif database for enrichment testing
-o output directory Results directory
-meme-mod zoops (default) Zero or one occurrence per sequence; appropriate for ChIP-seq

2b. Individual MEME Suite Tools

AME (Analysis of Motif Enrichment): Known motif enrichment testing, analogous to HOMER's known motif analysis:

ame --control --shuffle-- \
    --oc ame_output/ \
    summits.fa \
    JASPAR2024_CORE_vertebrates.meme

FIMO (Find Individual Motif Occurrences): Scan sequences for individual instances of a specific motif:

fimo --oc fimo_output/ \
    --thresh 1e-4 \
    target_motif.meme \
    hg38.fa

CentriMo (Central Motif Enrichment): Tests whether a motif is enriched at the center of peak sequences, which confirms direct binding (as opposed to indirect/co-factor binding):

centrimo --oc centrimo_output/ \
    summits.fa \
    JASPAR2024_CORE_vertebrates.meme

2c. Obtaining the JASPAR Database

The JASPAR database (Fornes et al. 2020) is the standard reference for known TF binding profiles:

# Download JASPAR 2024 core vertebrate motifs in MEME format
wget https://jaspar.elixir.no/download/data/2024/CORE/JASPAR2024_CORE_vertebrates_non-redundant_pfms_meme.txt \
    -O JASPAR2024_CORE_vertebrates.meme

For HOMER, the built-in motif database is used by default. To update:

perl /path/to/homer/configureHomer.pl -install hg38

Part 3: Interpreting Results

3a. Validating ChIP-seq Target

The primary motif in a TF ChIP-seq experiment should match the antibody target. For example:

ChIP Target Expected Primary Motif Consensus Sequence
CTCF CTCF CCGCGNGGNGGCAG
FOXA2 Forkhead TRTTTAC
PDX1 Homeodomain TAAT
NKX6.1 NK-homeodomain TTAATTG
TP53 p53 RRRCWWGYYY

If the expected motif is NOT the top hit: This could indicate (a) antibody cross-reactivity, (b) indirect binding through a co-factor, (c) poor ChIP enrichment, or (d) a secondary binding mode. Check the experiment's ENCODE audit status and FRiP score before concluding the biology is unexpected.

3b. Discovering Co-Regulatory Partners

Secondary motifs reveal TFs that co-bind near the primary target. These co-factors are biologically significant:

  • Same-family members: If FOXA2 ChIP shows FOXA1 and FOXA3 motifs, the antibody may recognize multiple family members, or family members bind adjacent sites
  • Lineage TFs: Co-enrichment of lineage-determining TFs (e.g., GATA motifs in blood, HNF motifs in liver/pancreas) confirms tissue-specific binding
  • Architectural factors: CTCF motifs in non-CTCF ChIP experiments often indicate binding near insulator elements
  • AP-1 motifs: Frequently appear as secondary hits because AP-1 family members occupy many enhancers broadly

3c. CentriMo: Motif Centrality

CentriMo tests whether a motif is enriched at the center of peak sequences. This is a powerful validation:

Centrality Pattern Interpretation
Strong central enrichment Direct binding: the TF physically contacts this motif
Uniform distribution Indirect binding: motif is nearby but not at the binding site
Depleted at center, enriched in flanks Co-factor: binds adjacent to the primary factor

3d. p-Value Interpretation

Both HOMER and MEME report p-values, but they are calculated differently:

  • HOMER: Uses hypergeometric test comparing motif frequency in target peaks vs background sequences. Reports both p-value and percentage of target/background sequences containing the motif.
  • MEME: Uses E-value (expected number of motifs with equal or better score found by chance). E-value < 0.05 is significant.
  • AME: Uses Fisher's exact test by default. Adjusts for multiple testing.

Multiple testing caveat: When testing hundreds of known motifs, many will show nominal significance by chance. Focus on motifs with (a) low p-value AND (b) high enrichment fold change AND (c) biological plausibility.

Complete Workflow

Step 1: Obtain ENCODE ChIP-seq/ATAC-seq peaks
    encode_search_experiments(assay_title="TF ChIP-seq", target="CTCF")
    encode_list_files(..., output_type="IDR thresholded peaks")
    encode_download_files(...)

Step 2: Prepare input sequences
    Extract summit +/- 100bp for TF ChIP-seq
    Remove blacklisted regions (Amemiya et al. 2019)
    Subsample to top 10,000 if needed
    Extract FASTA with bedtools getfasta

Step 3: Run HOMER
    findMotifsGenome.pl peaks.bed hg38 output/ -size 200 -mask -p 8

Step 4: Run MEME-ChIP
    meme-chip -meme-maxw 30 -db JASPAR2024.meme -o output/ summits.fa

Step 5: Interpret results
    Primary motif should match ChIP target (validation)
    Secondary motifs reveal co-factors
    CentriMo confirms direct vs indirect binding
    Compare HOMER and MEME results for concordance

Step 6: Document and track
    encode_log_derived_file(
        file_path="/data/motif_results/homerResults.html",
        source_accessions=["ENCSR..."],
        description="HOMER de novo + known motif analysis of CTCF peaks",
        tool_used="HOMER v4.11 findMotifsGenome.pl",
        parameters="-size 200 -mask -p 8"
    )

Code Examples

Complete HOMER Workflow

#!/bin/bash
# Full HOMER motif analysis for ENCODE TF ChIP-seq peaks

PEAKS="CTCF_idr_peaks.narrowPeak"
GENOME="hg38"
BLACKLIST="hg38-blacklist.v2.bed.gz"
OUTDIR="homer_CTCF"
THREADS=8

# Step 1: Filter blacklisted regions
bedtools intersect -a $PEAKS -b $BLACKLIST -v > peaks_clean.narrowPeak

# Step 2: Run HOMER (handles summit extraction internally with -size)
findMotifsGenome.pl peaks_clean.narrowPeak $GENOME $OUTDIR/ \
    -size 200 \
    -mask \
    -p $THREADS \
    -preparsedDir homer_preparsed/

echo "De novo results: $OUTDIR/homerResults.html"
echo "Known motif results: $OUTDIR/knownResults.html"

Complete MEME-ChIP Workflow

#!/bin/bash
# Full MEME-ChIP motif analysis for ENCODE TF ChIP-seq peaks

PEAKS="CTCF_idr_peaks.narrowPeak"
GENOME_FA="hg38.fa"
BLACKLIST="hg38-blacklist.v2.bed.gz"
JASPAR="JASPAR2024_CORE_vertebrates.meme"
OUTDIR="memechip_CTCF"

# Step 1: Extract summit +/- 100bp
awk 'BEGIN{OFS="\t"} {s=$2+$10; if(s-100>=0) print $1,s-100,s+100,$4,$7}' \
    $PEAKS > summits_200bp.bed

# Step 2: Remove blacklisted regions
bedtools intersect -a summits_200bp.bed -b $BLACKLIST -v > summits_clean.bed

# Step 3: Subsample top 5000 by signal
sort -k5,5nr summits_clean.bed | head -5000 > top5k_summits.bed

# Step 4: Extract FASTA
bedtools getfasta -fi $GENOME_FA -bed top5k_summits.bed -fo top5k_summits.fa

# Step 5: Run MEME-ChIP
meme-chip \
    -meme-maxw 30 \
    -meme-nmotifs 10 \
    -meme-minw 6 \
    -db $JASPAR \
    -o $OUTDIR/ \
    top5k_summits.fa

echo "Results: $OUTDIR/index.html"

Common Pitfalls

  1. Peak summit vs full peak region: For TF ChIP-seq, always use summit-centered windows (150-250bp). Using the full peak region (often 300-1000bp) dilutes the motif signal because TF binding sites occupy only 6-20bp at the summit. For histone ChIP-seq or ATAC-seq, use the full peak region with -size given because the relevant sequence features are distributed across the region, not concentrated at a single point.

  2. Background model: Both HOMER and MEME use background sequence models to calculate enrichment. HOMER generates GC-matched background from the genome by default, which is usually appropriate. For MEME-ChIP, the default shuffle-based background works well. However, if your peaks are strongly biased toward specific genomic features (e.g., all in CpG islands), consider providing a custom background set matched for genomic context to avoid false enrichment from GC bias.

  3. Repeat masking: Always use repeat masking (-mask in HOMER, which uses the soft-masked genome). Without masking, repetitive elements dominate the de novo motif results. Alu elements, LINE elements, and simple repeats contain internal sequence patterns that HOMER and MEME will report as significant "motifs" that have no biological relevance to TF binding.

  4. Too many peaks overwhelm the analysis: HOMER and MEME become slow and less specific with more than 50,000 sequences. More importantly, including weak peaks adds noise. Subsample to the top 5,000-10,000 peaks ranked by signal value or enrichment score. The strongest peaks have the most consistent motif instances and produce the clearest results. Quality over quantity.

  5. Missing JASPAR or outdated motif database: MEME-ChIP requires an external motif database file for known motif enrichment. Without it, only de novo discovery runs. Download the current JASPAR core vertebrate set in MEME format from jaspar.elixir.no. HOMER ships with its own motif database, but it should be updated periodically with configureHomer.pl. Outdated databases may miss recently characterized TF motifs.

Presenting Results

When reporting motif enrichment analysis results:

  • Enrichment table: Present a table with columns: motif_name, p-value, % of target sequences with motif, % of background sequences with motif, fold_enrichment, and best_known_match (for de novo motifs)
  • Always report: Tool and version (HOMER v4.x or MEME Suite v5.x), motif database used (JASPAR 2024 / HOMER default), number of input peaks, peak size used, and whether repeat masking was applied
  • De novo motifs: For each de novo motif, report the E-value, number of sites, information content (bits), and the top match from the known motif database with its match p-value
  • Background model: Specify the background used (HOMER: GC-matched genomic, MEME: shuffled sequences, or custom), as this directly affects enrichment significance
  • Context to provide: Note the peak subsetting strategy (e.g., top 5,000 by signal) and whether results were consistent between HOMER and MEME when both were run
  • Next steps: Suggest jaspar-motifs for targeted scanning of specific TF motifs at base-pair resolution, or peak-annotation to annotate motif-containing peaks with genomic features

Walkthrough: Discovering Co-Binding TFs at Liver CTCF Sites

Goal: Find enriched motifs in CTCF ChIP-seq peaks from liver to identify co-binding partners. Context: CTCF organizes chromatin loops; co-bound TFs may regulate liver-specific gene expression.

Step 1: Find CTCF ChIP-seq peaks in liver

encode_search_files(
  assay_title="TF ChIP-seq",
  organ="liver",
  target="CTCF",
  file_format="bed",
  output_type="IDR thresholded peaks",
  assembly="GRCh38"
)

Expected output (fields abridged):

{
  "results": [
    {"accession": "ENCFF345CTF", "file_format": "bed", "file_type": "bed narrowPeak", "output_type": "IDR thresholded peaks", "assembly": "GRCh38", "file_size": 2202009, "file_size_human": "2.1 MB", "experiment_accession": "ENCSR000DKB"}
  ],
  "total": 3,
  "limit": 25,
  "offset": 0,
  "has_more": false,
  "next_offset": null
}

Step 2: Download peaks for motif analysis

encode_download_files(
  file_accessions=["ENCFF345CTF"],
  download_dir="/data/motifs/liver_ctcf"
)

Step 3: Run HOMER findMotifsGenome.pl

findMotifsGenome.pl ENCFF345CTF.bed hg38 output_dir/ -size 200 -mask

Interpretation: Expect CTCF motif as top hit (validation). Liver-specific co-binders (HNF4A, FOXA2) appearing in the known motif results suggest regulatory cooperation.

Code Examples

1. Find ChIP-seq peaks for motif discovery

encode_search_files(
  assay_title="TF ChIP-seq",
  organ="pancreas",
  target="NKX2-2",
  file_format="bed",
  output_type="IDR thresholded peaks",
  assembly="GRCh38"
)

Expected output (fields abridged):

{
  "results": [
    {"accession": "ENCFF789NKX", "file_format": "bed", "file_type": "bed narrowPeak", "output_type": "IDR thresholded peaks", "assembly": "GRCh38", "file_size": 1468006, "file_size_human": "1.4 MB", "experiment_accession": "ENCSR447NKX"}
  ],
  "total": 1,
  "limit": 25,
  "offset": 0,
  "has_more": false,
  "next_offset": null
}

Integration

This skill produces... Feed into... Using tool/skill
Enriched motif lists (HOMER/MEME output) TF identification cross-reference -> Open Targets
De novo motifs (position weight matrices) JASPAR comparison jaspar-motifs skill
Co-binding TF predictions Regulatory network integrative-analysis skill
Motif locations (BED format) Variant overlap variant-annotation skill
Background-corrected enrichment scores Publication tables scientific-writing skill

Related Skills

  • regulatory-elements -- Identify cis-regulatory elements that can be further characterized by motif content
  • epigenome-profiling -- Comprehensive epigenomic profiles provide context for interpreting which TFs are active
  • histone-aggregation -- Union peak sets from multiple histone experiments provide genomic context for motif results
  • accessibility-aggregation -- Union ATAC/DNase peak sets define the accessible genome where TF binding occurs
  • peak-annotation -- Annotate motif-containing peaks with genomic features and gene associations
  • visualization-workflow -- Visualize motif enrichment at peaks using deepTools heatmaps centered on motif instances
  • publication-trust -- Verify literature claims backing analytical decisions

For the request: "$ARGUMENTS"

Files (encode-toolkit)
  • references
    • literature.md 15.2 KB
      # Motif Analysis — Literature References
      
      **Last updated:** 2026-03-07
      **Purpose:** Reference catalog for the motif-analysis skill — key papers informing
      transcription factor motif discovery, enrichment testing, and database resources for
      regulatory sequence analysis.
      
      ---
      
      ## Core Discovery Tools
      
      ---
      
      ### Heinz et al. 2010 — HOMER: de novo motif discovery and next-gen sequencing analysis
      
      - **Citation:** Heinz S, Benner C, Spann N, Bertolino E, Shaughnessy J, Murre C,
        Singh H, Glass CK, Natoli G. Simple combinations of lineage-determining transcription
        factors prime cis-regulatory elements required for macrophage and B cell identities.
        Molecular Cell, 38(4):576-589, 2010.
      - **DOI:** [10.1016/j.molcel.2010.05.004](https://doi.org/10.1016/j.molcel.2010.05.004)
      - **PMID:** 20513432 | **PMC:** PMC2898526
      - **Citations:** ~6,000
      - **Key findings:** Introduced HOMER (Hypergeometric Optimization of Motif EnRichment),
        which performs de novo motif discovery by comparing motif frequencies in target sequences
        against a matched genomic background using a cumulative hypergeometric distribution.
        The algorithm iteratively optimizes position weight matrices through greedy refinement,
        processing 50,000 peaks in minutes with built-in genomic annotation and comprehensive
        output including both de novo discovered motifs and known motif enrichment from curated
        databases. HOMER's findMotifsGenome.pl became the de facto standard for ChIP-seq motif
        analysis because it automates background selection (matched GC content and repeat masking),
        reports both enrichment p-values and motif prevalence, and provides annotation of peaks
        to genomic features alongside motif discovery. The biological study demonstrated that
        simple combinations of lineage-determining TFs (PU.1 in macrophages, E2A/EBF in B cells)
        prime cis-regulatory elements by binding collaboratively at enhancers, establishing that
        motif co-occurrence patterns in ChIP-seq peaks reveal cooperative TF binding logic.
      
      ---
      
      ### Bailey et al. 2009 — MEME Suite: integrated motif analysis tools
      
      - **Citation:** Bailey TL, Boden M, Buske FA, Frith M, Grant CE, Clementi L, Ren J,
        Li WW, Noble WS. MEME SUITE: tools for motif discovery and searching. Nucleic Acids
        Research, 37(Web Server issue):W202-W208, 2009.
      - **DOI:** [10.1093/nar/gkp335](https://doi.org/10.1093/nar/gkp335)
      - **PMID:** 19458158 | **PMC:** PMC2703892
      - **Citations:** ~2,500
      - **Key findings:** Described the MEME Suite as an integrated collection of tools for
        motif-based sequence analysis: MEME (discovery via expectation maximization), TOMTOM
        (motif-to-database comparison using Pearson correlation, Euclidean distance, or
        Sandelin-Wasserman metrics), FIMO (genome-wide occurrence scanning with calibrated
        p-values), MAST (motif-based sequence search), and MCAST (cis-regulatory module
        detection from clustered motif occurrences). MEME discovers ungapped motifs from
        unaligned sequences using three statistical models: OOPS (one occurrence per sequence),
        ZOOPS (zero or one per sequence), and TCM (two-component mixture for any number).
        The suite established the canonical motif analysis workflow still used in 2026:
        discover enriched motifs de novo, compare them against JASPAR/HOCOMOCO/CIS-BP to
        identify matching TFs, scan genomes for all predicted binding sites, and assess
        significance with E-values that report expected number of equally good motifs in
        random sequence of the same size and composition.
      
      ---
      
      ### Grant et al. 2011 — FIMO: scanning for individual motif occurrences
      
      - **Citation:** Grant CE, Bailey TL, Noble WS. FIMO: scanning for occurrences of a
        given motif. Bioinformatics, 27(7):1017-1018, 2011.
      - **DOI:** [10.1093/bioinformatics/btr064](https://doi.org/10.1093/bioinformatics/btr064)
      - **PMID:** 21330290 | **PMC:** PMC3065696
      - **Citations:** ~2,000
      - **Key findings:** Introduced FIMO (Find Individual Motif Occurrences), a dedicated tool
        for genome-wide scanning of position weight matrix matches against DNA sequences with
        rigorous statistical calibration. FIMO converts raw PWM log-likelihood ratio scores
        to p-values using a dynamic programming algorithm that computes the exact score
        distribution under a zero-order background model, then applies Benjamini-Hochberg
        correction for multiple testing across all genomic positions scanned. Unlike simpler
        threshold-based approaches that use arbitrary score cutoffs (e.g., 80% of maximum
        score), FIMO provides calibrated statistical significance enabling direct comparison
        of match quality across motifs with different information content and lengths. The
        tool is essential for linking ChIP-seq peaks to specific motif instances — given a
        peak set and candidate TF motif, FIMO identifies which peaks contain the motif, where
        within each peak the motif falls (enabling centrality analysis for distinguishing
        direct from indirect binding), and the match quality for downstream filtering.
      
      ---
      
      ## Motif Databases
      
      ---
      
      ### Castro-Mondragon et al. 2022 — JASPAR 2022: expanded open-access TF profiles
      
      - **Citation:** Castro-Mondragon JA, Riudavets-Puig R, Rauluseviciute I, Lemma RB,
        Turber L, Blanc-Mathieu R, Lucas J, Boddie P, Khan A, Manosalva Perez N, et al.
        JASPAR 2022: the 9th release of the open-access database of transcription factor
        binding profiles. Nucleic Acids Research, 50(D1):D165-D173, 2022.
      - **DOI:** [10.1093/nar/gkab1113](https://doi.org/10.1093/nar/gkab1113)
      - **PMID:** 34850907 | **PMC:** PMC8728201
      - **Citations:** ~1,400
      - **Key findings:** JASPAR 2022 expanded to 1,956 curated TF binding profiles across
        7 taxonomic groups, with a 20% increase over JASPAR 2020 and 879 vertebrate profiles.
        New profiles were curated from ChIP-seq, DAP-seq, SELEX, and protein binding microarray
        experiments with strict quality criteria requiring independent experimental validation.
        The release introduced JASPAR collections for computationally predicted but unvalidated
        profiles (kept separate from the curated core), a TF flexible model (TFFM) repository
        capturing positional interdependencies that standard PWMs miss, and improved RESTful
        API endpoints (jaspar.elixir.no/api/v1/) for programmatic retrieval of PFMs, PWMs,
        and metadata. JASPAR remains the gold-standard open-access motif database because
        every profile is manually curated by domain experts, experimentally validated, and
        assigned quality scores — distinguishing it from automated databases like HOCOMOCO
        that trade per-profile validation for broader TF coverage.
      
      ---
      
      ### Kulakovskiy et al. 2018 — HOCOMOCO v11: comprehensive TF binding models
      
      - **Citation:** Kulakovskiy IV, Vorontsov IE, Yevshin IS, Sharipov RN, Fedorova AD,
        Rumyantcev EI, Medvedeva YA, Magana-Mora A, Bajic VB, Papatsenko DA, et al.
        HOCOMOCO: towards a complete collection of transcription factor binding models for
        human and mouse via large-scale ChIP-Seq analysis. Nucleic Acids Research,
        46(D1):D252-D259, 2018.
      - **DOI:** [10.1093/nar/gkx1106](https://doi.org/10.1093/nar/gkx1106)
      - **PMID:** 29140464 | **PMC:** PMC5753240
      - **Citations:** ~1,200
      - **Key findings:** HOCOMOCO v11 provides 1,302 human and 1,168 mouse TF binding models
        derived primarily from ChIP-seq data using the ChIPMunk motif discovery algorithm.
        Each motif receives a quality rating (A/B/C/D) based on three independent criteria:
        enrichment in ChIP-seq peaks from ENCODE and other sources, evolutionary sequence
        conservation at predicted binding sites, and similarity to known motifs from
        independent experimental databases. Unlike JASPAR's manual curation approach,
        HOCOMOCO uses a semi-automated pipeline processing thousands of ChIP-seq experiments,
        providing broader coverage (769 human TFs vs. JASPAR's ~550) at the cost of less
        stringent per-motif validation. HOCOMOCO is particularly valuable for comprehensive
        genome-wide scans where sensitivity is prioritized over specificity, and its quality
        ratings allow users to filter for high-confidence motifs (A/B) when precision matters.
      
      ---
      
      ### Mathelier et al. 2014 — JASPAR 2014: expanded vertebrate TF binding profiles
      
      - **Citation:** Mathelier A, Zhao X, Zhang AW, Parcy F, Worsley-Hunt R, Arenillas DJ,
        Buchman S, Chen CY, et al. JASPAR 2014: an extensively expanded and updated
        open-access database of transcription factor binding profiles. Nucleic Acids
        Research, 42(D1):D142-D147, 2014.
      - **DOI:** [10.1093/nar/gkt997](https://doi.org/10.1093/nar/gkt997)
      - **PMID:** 24194598 | **PMC:** PMC3965078
      - **Citations:** ~1,500
      - **Key findings:** JASPAR 2014 introduced 205 new curated TF binding profiles, expanding
        the vertebrate collection by 135% over JASPAR 2010 to reach 205 vertebrate profiles.
        This was a transformative release because it incorporated profiles from ChIP-seq and
        protein-binding microarray (PBM) experiments for the first time, moving beyond the
        original SELEX-only approach that had limited database growth for a decade. Introduced
        a novel clustering algorithm to group TFs with similar binding patterns, revealing
        structural family relationships in binding specificity, and provided pre-computed
        genome-wide binding predictions for model organisms. Also added interactive
        visualizations for motif comparison and similarity networks. This release marked
        JASPAR's transition from a small curated collection to a comprehensive database
        suitable for genome-scale regulatory analysis.
      
      ---
      
      ## Binding Specificity Studies
      
      ---
      
      ### Weirauch et al. 2014 — Comprehensive catalog of TF binding specificities
      
      - **Citation:** Weirauch MT, Yang A, Albu M, Cote AG, Montenegro-Montero A, Drewe P,
        Najafabadi HS, Lambert SA, Mann I, Cook K, et al. Determination and inference of
        eukaryotic transcription factor sequence specificity. Cell, 158(6):1431-1443, 2014.
      - **DOI:** [10.1016/j.cell.2014.08.009](https://doi.org/10.1016/j.cell.2014.08.009)
      - **PMID:** 25215497 | **PMC:** PMC4163041
      - **Citations:** ~1,800
      - **Key findings:** Created the CIS-BP (Catalog of Inferred Sequence Binding Preferences)
        database covering >1,000 TFs by combining direct experimental data (protein binding
        microarrays, SELEX, ChIP-seq) with inference from DNA-binding domain (DBD) sequence
        similarity. Demonstrated that TFs sharing >80% amino acid identity in their DBDs have
        interchangeable binding specificities with ~90% accuracy, enabling motif prediction for
        thousands of uncharacterized TFs across >1,000 species. This "homology-based motif
        inference" principle filled critical gaps in motif databases — especially for non-model
        organisms — and revealed that the ~1,400 human TFs converge on far fewer distinct
        binding specificities than expected. CIS-BP complements JASPAR by prioritizing breadth
        through computational inference while JASPAR prioritizes depth through experimental
        validation, and the two databases together provide the most complete motif landscape
        for human TF binding specificity analysis.
      
      ---
      
      ### Jolma et al. 2013 — DNA-binding specificities of human TFs by HT-SELEX
      
      - **Citation:** Jolma A, Yan J, Whitington T, Toivonen J, Nitta KR, Rastas P,
        Morgunova E, Enge M, Taipale M, Wei G, et al. DNA-binding specificities of human
        transcription factors. Cell, 152(1-2):327-339, 2013.
      - **DOI:** [10.1016/j.cell.2012.12.009](https://doi.org/10.1016/j.cell.2012.12.009)
      - **PMID:** 23332764
      - **Citations:** ~2,500
      - **Key findings:** Determined binding specificities for 830 human TF DNA-binding domains
        spanning 239 structural classes using high-throughput SELEX (HT-SELEX) with 5 rounds
        of selection and deep sequencing to capture both high-affinity core motifs and
        lower-affinity flanking preferences. Revealed that most TFs recognize substantially
        longer sequences than traditional 6-10bp motif models suggest, with secondary binding
        modes and flanking nucleotide preferences that quantitatively modulate affinity by
        2-10 fold. Many TF family members previously assumed to share identical binding
        preferences were shown to have distinct specificities driven by subtle amino acid
        differences at DNA-contact positions — for example, different bHLH heterodimers prefer
        distinct E-box variants despite recognizing the same CANNTG core. This dataset became
        a primary data source for JASPAR profiles and demonstrated that in vitro binding
        specificities correlate well with in vivo ChIP-seq occupancy when chromatin
        accessibility and TF cooperativity are taken into account.
      
      ---
      
      ## Analytical Frameworks
      
      ---
      
      ### Kheradpour & Kellis 2014 — Systematic motif annotation of ENCODE TF binding
      
      - **Citation:** Kheradpour P, Kellis M. Systematic discovery and characterization of
        regulatory motifs in ENCODE TF binding experiments. Nucleic Acids Research,
        42(5):2976-2987, 2014.
      - **DOI:** [10.1093/nar/gkt1249](https://doi.org/10.1093/nar/gkt1249)
      - **PMID:** 24335146 | **PMC:** PMC3950668
      - **Citations:** ~800
      - **Key findings:** Applied systematic motif discovery across 427 ENCODE ChIP-seq datasets
        for 119 TFs, revealing that most peaks contain the expected canonical motif but also
        harbor co-enriched partner motifs reflecting cooperative binding and chromatin context.
        Developed a principled framework for evaluating motif quality using three independent
        validation criteria: evolutionary conservation of predicted binding sites, centrality
        of motif instances within ChIP-seq peaks (direct binding produces centrally located
        motifs while indirect binding shows random position), and overlap with DNase I
        footprints indicating physical protein-DNA contact. Found that 60-80% of ChIP-seq
        peaks contain a recognizable motif instance for the ChIPped factor, with the remainder
        representing indirect binding through protein-protein interactions, antibody
        cross-reactivity, or chromatin looping that brings distal sites into spatial proximity.
        This work established best practices for distinguishing direct from indirect TF binding
        in ENCODE ChIP-seq datasets using motif centrality analysis.
      
      ---
      
      ### Stormo 2013 — Modeling the specificity of protein-DNA interactions
      
      - **Citation:** Stormo GD. Modeling the specificity of protein-DNA interactions.
        Quantitative Biology, 1(2):115-130, 2013.
      - **DOI:** [10.1007/s40484-013-0012-4](https://doi.org/10.1007/s40484-013-0012-4)
      - **PMID:** 25093161 | **PMC:** PMC4119722
      - **Citations:** ~400
      - **Key findings:** Comprehensive theoretical review of computational approaches to model
        TF-DNA binding specificity, ranging from simple consensus sequences through position
        weight matrices (PWMs) to higher-order models capturing positional dependencies
        (dinucleotide models, TFFMs, deep learning approaches). Demonstrated mathematically
        that PWMs assume statistical independence between nucleotide positions — an assumption
        violated for TFs with complex binding sites involving base stacking or protein-mediated
        inter-position contacts. Showed that the information content of a motif (measured in
        bits per position) determines the expected frequency of binding sites in random
        sequence: a 12-bit motif is expected once per 4,096 bp of random DNA, establishing
        the theoretical framework for interpreting motif enrichment statistics and setting
        appropriate scanning thresholds. This work underpins all motif analysis tools used in
        the motif-analysis skill and helps practitioners correctly interpret motif logos,
        p-values, false discovery rates, and the relationship between motif specificity
        and genomic binding site density.
      
      ---
      
  • SKILL.md 21.1 KB
    ---
    name: motif-analysis
    description: "Guide for de novo and known motif enrichment analysis of ENCODE ChIP-seq and ATAC-seq peaks using HOMER and MEME Suite. Use when users need to discover TF binding motifs in peaks, validate ChIP-seq targets, or find co-binding partners. Trigger on: motif analysis, HOMER, MEME, de novo motif, motif enrichment, findMotifsGenome, AME, MEME-ChIP, known motif, TF binding motif, co-factor, motif discovery."
    ---
    
    # Motif Analysis of ENCODE Peak Data
    
    ## When to Use
    
    - User wants to discover transcription factor binding motifs in ChIP-seq or ATAC-seq peaks
    - User asks about "motif enrichment", "HOMER", "MEME", or "de novo motif discovery"
    - User needs to validate ChIP-seq targets by checking if the expected motif is enriched
    - User wants to find co-binding partners or co-factor motifs in peak regions
    - Example queries: "find motifs in my CTCF peaks", "run HOMER on ATAC-seq peaks", "what TFs co-bind with p300 in liver?"
    
    Help the user perform de novo and known motif enrichment analysis on ENCODE ChIP-seq and ATAC-seq peaks. Motif analysis serves two critical purposes: (1) validating that ChIP-seq experiments pulled down the expected transcription factor, and (2) discovering co-regulatory partners that co-bind with the target factor. This skill covers the two major tool suites -- HOMER and MEME Suite -- from input preparation through result interpretation.
    
    ## Literature Foundation
    
    | Reference | Journal | Key Contribution | DOI | Citations |
    |-----------|---------|-----------------|-----|-----------|
    | Heinz et al. (2010) | Molecular Cell | HOMER: Simple combinations of lineage-determining TFs prime cis-regulatory elements; introduced findMotifsGenome.pl for ChIP-seq motif analysis | [10.1016/j.molcel.2010.05.004](https://doi.org/10.1016/j.molcel.2010.05.004) | ~6,000 |
    | Bailey et al. (2009) | Nucleic Acids Research | MEME Suite: comprehensive tools for motif discovery (MEME), enrichment (AME), scanning (FIMO), and spacing (SpaMo) | [10.1093/nar/gkp335](https://doi.org/10.1093/nar/gkp335) | ~2,500 |
    | Bailey & Elkan (1994) | ISMB | Foundational MEME algorithm: expectation maximization for discovering ungapped motifs in biopolymers | PMID: 7584402 | ~4,000 |
    | Machanick & Bailey (2011) | Bioinformatics | MEME-ChIP: all-in-one motif analysis pipeline optimized for large ChIP-seq datasets | [10.1093/bioinformatics/btr189](https://doi.org/10.1093/bioinformatics/btr189) | ~1,800 |
    | Fornes et al. (2020) | Nucleic Acids Research | JASPAR 2020: curated, non-redundant TF binding profile database; standard reference for known motifs | [10.1093/nar/gkz1001](https://doi.org/10.1093/nar/gkz1001) | ~2,200 |
    | Amemiya et al. (2019) | Scientific Reports | ENCODE Blacklist: regions producing artifact signal that can generate spurious motif hits | [10.1038/s41598-019-45839-z](https://doi.org/10.1038/s41598-019-45839-z) | ~1,372 |
    
    ## Prerequisites: Input Preparation
    
    ### Obtaining ENCODE Peaks
    
    Search for and download ChIP-seq or ATAC-seq peaks:
    
    ```
    encode_search_experiments(
        assay_title="TF ChIP-seq",
        target="CTCF",
        organ="pancreas",
        biosample_type="tissue"
    )
    
    encode_list_files(
        experiment_accession="ENCSR...",
        file_format="bed",
        output_type="IDR thresholded peaks",
        assembly="GRCh38",
        preferred_default=True
    )
    
    encode_download_files(
        file_accessions=["ENCFF..."],
        download_dir="/data/motif_analysis/"
    )
    ```
    
    ### Preparing Sequences from Peaks
    
    Motif analysis requires DNA sequences, not just genomic coordinates. Extract sequences centered on peak summits:
    
    ```bash
    # For TF ChIP-seq: extract summit +/- 100bp (200bp window)
    awk 'BEGIN{OFS="\t"} {summit=$2+$10; print $1, summit-100, summit+100, $4, $5}' \
        peaks.narrowPeak > summits_200bp.bed
    
    # Remove blacklisted regions (Amemiya et al. 2019)
    bedtools intersect -a summits_200bp.bed \
        -b hg38-blacklist.v2.bed -v > summits_clean.bed
    
    # Extract FASTA sequences (requires genome FASTA)
    bedtools getfasta -fi hg38.fa -bed summits_clean.bed -fo summits.fa
    
    # For ATAC-seq: use full peak regions (typically 200-500bp)
    bedtools getfasta -fi hg38.fa -bed atac_peaks_clean.bed -fo atac_peaks.fa
    ```
    
    **Critical**: For TF ChIP-seq, always center on the summit (column 10 in narrowPeak format) and use a narrow window (150-250bp). Using the full peak region dilutes the motif signal because TF binding sites are concentrated at the summit. For histone ChIP-seq, use the full peak or a broader window because histone marks cover larger domains.
    
    ### Subsampling Large Peak Sets
    
    For peak sets larger than 50,000, subsample the top peaks by signal strength:
    
    ```bash
    # Sort by signalValue (column 7) descending, take top 10,000
    sort -k7,7nr summits_clean.bed | head -10000 > top10k_summits.bed
    bedtools getfasta -fi hg38.fa -bed top10k_summits.bed -fo top10k_summits.fa
    ```
    
    This improves speed without sacrificing sensitivity, as the strongest peaks contain the most consistent motif instances.
    
    ## Part 1: HOMER findMotifsGenome
    
    HOMER (Heinz et al. 2010) performs both de novo motif discovery and known motif enrichment in a single command. It is the most widely used tool for ChIP-seq motif analysis.
    
    ### 1a. Basic Usage
    
    ```bash
    findMotifsGenome.pl peaks.bed hg38 homer_output/ \
        -size 200 \
        -mask \
        -p 8 \
        -preparsedDir /data/homer_preparsed/
    ```
    
    **Key parameters**:
    
    | Parameter | Value | Rationale |
    |-----------|-------|-----------|
    | `-size` | 200 (TF ChIP-seq) | Window around peak center; 200bp captures typical TF binding site + flanking context |
    | `-size` | given (histone ChIP-seq) | Use actual peak boundaries for broad marks |
    | `-mask` | always include | Mask repeat sequences to avoid spurious repeat-derived motifs |
    | `-p` | 8 (or available cores) | Parallel threads for speed |
    | `-preparsedDir` | reusable directory | Cache parsed genome for repeated runs |
    | `-bg` | background.bed (optional) | Custom background regions; default uses matched GC regions from genome |
    | `-mknown` | motifs.motif (optional) | Test specific known motifs in addition to default database |
    | `-len` | 8,10,12 (default) | Motif lengths to search; default covers most TF motifs |
    
    ### 1b. Output Structure
    
    HOMER produces a structured output directory:
    
    ```
    homer_output/
        homerResults.html         # De novo motif results (interactive HTML)
        knownResults.html         # Known motif enrichment results
        homerResults/
            motif1.motif          # Position weight matrix for each de novo motif
            motif2.motif
            ...
        knownResults/
            known1.motif          # Matched known motif PWMs
            ...
        homerMotifs.all.motifs    # All de novo motifs in one file
        seq.autonorm.tsv          # Normalization statistics
    ```
    
    ### 1c. HOMER for ATAC-seq Peaks
    
    ATAC-seq peaks represent accessible chromatin, not specific TF binding. Motif analysis on ATAC peaks reveals which TFs occupy accessible regions:
    
    ```bash
    findMotifsGenome.pl atac_peaks.bed hg38 homer_atac_output/ \
        -size given \
        -mask \
        -p 8
    ```
    
    Use `-size given` for ATAC-seq to analyze the full accessible region rather than a fixed window.
    
    ## Part 2: MEME-ChIP Suite
    
    The MEME Suite (Bailey et al. 2009) provides a complementary approach with different algorithms and additional capabilities for motif spacing analysis and scanning.
    
    ### 2a. MEME-ChIP: All-in-One Pipeline
    
    MEME-ChIP runs five tools sequentially: MEME (de novo discovery), DREME (short motif discovery), CentriMo (motif centrality), AME (known motif enrichment), and SpaMo (motif spacing).
    
    ```bash
    meme-chip \
        -meme-maxw 30 \
        -meme-nmotifs 10 \
        -meme-minw 6 \
        -db JASPAR2024_CORE_vertebrates.meme \
        -o memechip_output/ \
        summits.fa
    ```
    
    **Required input**: FASTA file of peak sequences (not BED coordinates -- MEME Suite works on sequences, not genomic intervals).
    
    **Key parameters**:
    
    | Parameter | Value | Purpose |
    |-----------|-------|---------|
    | `-meme-maxw` | 30 | Maximum motif width; 30 covers most TF motifs |
    | `-meme-minw` | 6 | Minimum motif width |
    | `-meme-nmotifs` | 10 | Number of de novo motifs to find |
    | `-db` | JASPAR file | Known motif database for enrichment testing |
    | `-o` | output directory | Results directory |
    | `-meme-mod` | zoops (default) | Zero or one occurrence per sequence; appropriate for ChIP-seq |
    
    ### 2b. Individual MEME Suite Tools
    
    **AME (Analysis of Motif Enrichment)**: Known motif enrichment testing, analogous to HOMER's known motif analysis:
    
    ```bash
    ame --control --shuffle-- \
        --oc ame_output/ \
        summits.fa \
        JASPAR2024_CORE_vertebrates.meme
    ```
    
    **FIMO (Find Individual Motif Occurrences)**: Scan sequences for individual instances of a specific motif:
    
    ```bash
    fimo --oc fimo_output/ \
        --thresh 1e-4 \
        target_motif.meme \
        hg38.fa
    ```
    
    **CentriMo (Central Motif Enrichment)**: Tests whether a motif is enriched at the center of peak sequences, which confirms direct binding (as opposed to indirect/co-factor binding):
    
    ```bash
    centrimo --oc centrimo_output/ \
        summits.fa \
        JASPAR2024_CORE_vertebrates.meme
    ```
    
    ### 2c. Obtaining the JASPAR Database
    
    The JASPAR database (Fornes et al. 2020) is the standard reference for known TF binding profiles:
    
    ```bash
    # Download JASPAR 2024 core vertebrate motifs in MEME format
    wget https://jaspar.elixir.no/download/data/2024/CORE/JASPAR2024_CORE_vertebrates_non-redundant_pfms_meme.txt \
        -O JASPAR2024_CORE_vertebrates.meme
    ```
    
    For HOMER, the built-in motif database is used by default. To update:
    ```bash
    perl /path/to/homer/configureHomer.pl -install hg38
    ```
    
    ## Part 3: Interpreting Results
    
    ### 3a. Validating ChIP-seq Target
    
    The primary motif in a TF ChIP-seq experiment should match the antibody target. For example:
    
    | ChIP Target | Expected Primary Motif | Consensus Sequence |
    |-------------|----------------------|-------------------|
    | CTCF | CTCF | CCGCGNGGNGGCAG |
    | FOXA2 | Forkhead | TRTTTAC |
    | PDX1 | Homeodomain | TAAT |
    | NKX6.1 | NK-homeodomain | TTAATTG |
    | TP53 | p53 | RRRCWWGYYY |
    
    **If the expected motif is NOT the top hit**: This could indicate (a) antibody cross-reactivity, (b) indirect binding through a co-factor, (c) poor ChIP enrichment, or (d) a secondary binding mode. Check the experiment's ENCODE audit status and FRiP score before concluding the biology is unexpected.
    
    ### 3b. Discovering Co-Regulatory Partners
    
    Secondary motifs reveal TFs that co-bind near the primary target. These co-factors are biologically significant:
    
    - **Same-family members**: If FOXA2 ChIP shows FOXA1 and FOXA3 motifs, the antibody may recognize multiple family members, or family members bind adjacent sites
    - **Lineage TFs**: Co-enrichment of lineage-determining TFs (e.g., GATA motifs in blood, HNF motifs in liver/pancreas) confirms tissue-specific binding
    - **Architectural factors**: CTCF motifs in non-CTCF ChIP experiments often indicate binding near insulator elements
    - **AP-1 motifs**: Frequently appear as secondary hits because AP-1 family members occupy many enhancers broadly
    
    ### 3c. CentriMo: Motif Centrality
    
    CentriMo tests whether a motif is enriched at the center of peak sequences. This is a powerful validation:
    
    | Centrality Pattern | Interpretation |
    |-------------------|---------------|
    | Strong central enrichment | Direct binding: the TF physically contacts this motif |
    | Uniform distribution | Indirect binding: motif is nearby but not at the binding site |
    | Depleted at center, enriched in flanks | Co-factor: binds adjacent to the primary factor |
    
    ### 3d. p-Value Interpretation
    
    Both HOMER and MEME report p-values, but they are calculated differently:
    
    - **HOMER**: Uses hypergeometric test comparing motif frequency in target peaks vs background sequences. Reports both p-value and percentage of target/background sequences containing the motif.
    - **MEME**: Uses E-value (expected number of motifs with equal or better score found by chance). E-value < 0.05 is significant.
    - **AME**: Uses Fisher's exact test by default. Adjusts for multiple testing.
    
    **Multiple testing caveat**: When testing hundreds of known motifs, many will show nominal significance by chance. Focus on motifs with (a) low p-value AND (b) high enrichment fold change AND (c) biological plausibility.
    
    ## Complete Workflow
    
    ```
    Step 1: Obtain ENCODE ChIP-seq/ATAC-seq peaks
        encode_search_experiments(assay_title="TF ChIP-seq", target="CTCF")
        encode_list_files(..., output_type="IDR thresholded peaks")
        encode_download_files(...)
    
    Step 2: Prepare input sequences
        Extract summit +/- 100bp for TF ChIP-seq
        Remove blacklisted regions (Amemiya et al. 2019)
        Subsample to top 10,000 if needed
        Extract FASTA with bedtools getfasta
    
    Step 3: Run HOMER
        findMotifsGenome.pl peaks.bed hg38 output/ -size 200 -mask -p 8
    
    Step 4: Run MEME-ChIP
        meme-chip -meme-maxw 30 -db JASPAR2024.meme -o output/ summits.fa
    
    Step 5: Interpret results
        Primary motif should match ChIP target (validation)
        Secondary motifs reveal co-factors
        CentriMo confirms direct vs indirect binding
        Compare HOMER and MEME results for concordance
    
    Step 6: Document and track
        encode_log_derived_file(
            file_path="/data/motif_results/homerResults.html",
            source_accessions=["ENCSR..."],
            description="HOMER de novo + known motif analysis of CTCF peaks",
            tool_used="HOMER v4.11 findMotifsGenome.pl",
            parameters="-size 200 -mask -p 8"
        )
    ```
    
    ## Code Examples
    
    ### Complete HOMER Workflow
    
    ```bash
    #!/bin/bash
    # Full HOMER motif analysis for ENCODE TF ChIP-seq peaks
    
    PEAKS="CTCF_idr_peaks.narrowPeak"
    GENOME="hg38"
    BLACKLIST="hg38-blacklist.v2.bed.gz"
    OUTDIR="homer_CTCF"
    THREADS=8
    
    # Step 1: Filter blacklisted regions
    bedtools intersect -a $PEAKS -b $BLACKLIST -v > peaks_clean.narrowPeak
    
    # Step 2: Run HOMER (handles summit extraction internally with -size)
    findMotifsGenome.pl peaks_clean.narrowPeak $GENOME $OUTDIR/ \
        -size 200 \
        -mask \
        -p $THREADS \
        -preparsedDir homer_preparsed/
    
    echo "De novo results: $OUTDIR/homerResults.html"
    echo "Known motif results: $OUTDIR/knownResults.html"
    ```
    
    ### Complete MEME-ChIP Workflow
    
    ```bash
    #!/bin/bash
    # Full MEME-ChIP motif analysis for ENCODE TF ChIP-seq peaks
    
    PEAKS="CTCF_idr_peaks.narrowPeak"
    GENOME_FA="hg38.fa"
    BLACKLIST="hg38-blacklist.v2.bed.gz"
    JASPAR="JASPAR2024_CORE_vertebrates.meme"
    OUTDIR="memechip_CTCF"
    
    # Step 1: Extract summit +/- 100bp
    awk 'BEGIN{OFS="\t"} {s=$2+$10; if(s-100>=0) print $1,s-100,s+100,$4,$7}' \
        $PEAKS > summits_200bp.bed
    
    # Step 2: Remove blacklisted regions
    bedtools intersect -a summits_200bp.bed -b $BLACKLIST -v > summits_clean.bed
    
    # Step 3: Subsample top 5000 by signal
    sort -k5,5nr summits_clean.bed | head -5000 > top5k_summits.bed
    
    # Step 4: Extract FASTA
    bedtools getfasta -fi $GENOME_FA -bed top5k_summits.bed -fo top5k_summits.fa
    
    # Step 5: Run MEME-ChIP
    meme-chip \
        -meme-maxw 30 \
        -meme-nmotifs 10 \
        -meme-minw 6 \
        -db $JASPAR \
        -o $OUTDIR/ \
        top5k_summits.fa
    
    echo "Results: $OUTDIR/index.html"
    ```
    
    ## Common Pitfalls
    
    1. **Peak summit vs full peak region**: For TF ChIP-seq, always use summit-centered windows (150-250bp). Using the full peak region (often 300-1000bp) dilutes the motif signal because TF binding sites occupy only 6-20bp at the summit. For histone ChIP-seq or ATAC-seq, use the full peak region with `-size given` because the relevant sequence features are distributed across the region, not concentrated at a single point.
    
    2. **Background model**: Both HOMER and MEME use background sequence models to calculate enrichment. HOMER generates GC-matched background from the genome by default, which is usually appropriate. For MEME-ChIP, the default shuffle-based background works well. However, if your peaks are strongly biased toward specific genomic features (e.g., all in CpG islands), consider providing a custom background set matched for genomic context to avoid false enrichment from GC bias.
    
    3. **Repeat masking**: Always use repeat masking (`-mask` in HOMER, which uses the soft-masked genome). Without masking, repetitive elements dominate the de novo motif results. Alu elements, LINE elements, and simple repeats contain internal sequence patterns that HOMER and MEME will report as significant "motifs" that have no biological relevance to TF binding.
    
    4. **Too many peaks overwhelm the analysis**: HOMER and MEME become slow and less specific with more than 50,000 sequences. More importantly, including weak peaks adds noise. Subsample to the top 5,000-10,000 peaks ranked by signal value or enrichment score. The strongest peaks have the most consistent motif instances and produce the clearest results. Quality over quantity.
    
    5. **Missing JASPAR or outdated motif database**: MEME-ChIP requires an external motif database file for known motif enrichment. Without it, only de novo discovery runs. Download the current JASPAR core vertebrate set in MEME format from jaspar.elixir.no. HOMER ships with its own motif database, but it should be updated periodically with `configureHomer.pl`. Outdated databases may miss recently characterized TF motifs.
    
    ## Presenting Results
    
    When reporting motif enrichment analysis results:
    
    - **Enrichment table**: Present a table with columns: motif_name, p-value, % of target sequences with motif, % of background sequences with motif, fold_enrichment, and best_known_match (for de novo motifs)
    - **Always report**: Tool and version (HOMER v4.x or MEME Suite v5.x), motif database used (JASPAR 2024 / HOMER default), number of input peaks, peak size used, and whether repeat masking was applied
    - **De novo motifs**: For each de novo motif, report the E-value, number of sites, information content (bits), and the top match from the known motif database with its match p-value
    - **Background model**: Specify the background used (HOMER: GC-matched genomic, MEME: shuffled sequences, or custom), as this directly affects enrichment significance
    - **Context to provide**: Note the peak subsetting strategy (e.g., top 5,000 by signal) and whether results were consistent between HOMER and MEME when both were run
    - **Next steps**: Suggest `jaspar-motifs` for targeted scanning of specific TF motifs at base-pair resolution, or `peak-annotation` to annotate motif-containing peaks with genomic features
    
    ## Walkthrough: Discovering Co-Binding TFs at Liver CTCF Sites
    
    **Goal**: Find enriched motifs in CTCF ChIP-seq peaks from liver to identify co-binding partners.
    **Context**: CTCF organizes chromatin loops; co-bound TFs may regulate liver-specific gene expression.
    
    ### Step 1: Find CTCF ChIP-seq peaks in liver
    
    ```
    encode_search_files(
      assay_title="TF ChIP-seq",
      organ="liver",
      target="CTCF",
      file_format="bed",
      output_type="IDR thresholded peaks",
      assembly="GRCh38"
    )
    ```
    
    Expected output (fields abridged):
    ```json
    {
      "results": [
        {"accession": "ENCFF345CTF", "file_format": "bed", "file_type": "bed narrowPeak", "output_type": "IDR thresholded peaks", "assembly": "GRCh38", "file_size": 2202009, "file_size_human": "2.1 MB", "experiment_accession": "ENCSR000DKB"}
      ],
      "total": 3,
      "limit": 25,
      "offset": 0,
      "has_more": false,
      "next_offset": null
    }
    ```
    
    ### Step 2: Download peaks for motif analysis
    
    ```
    encode_download_files(
      file_accessions=["ENCFF345CTF"],
      download_dir="/data/motifs/liver_ctcf"
    )
    ```
    
    ### Step 3: Run HOMER findMotifsGenome.pl
    `findMotifsGenome.pl ENCFF345CTF.bed hg38 output_dir/ -size 200 -mask`
    
    **Interpretation**: Expect CTCF motif as top hit (validation). Liver-specific co-binders (HNF4A, FOXA2) appearing in the known motif results suggest regulatory cooperation.
    
    ## Code Examples
    
    ### 1. Find ChIP-seq peaks for motif discovery
    
    ```
    encode_search_files(
      assay_title="TF ChIP-seq",
      organ="pancreas",
      target="NKX2-2",
      file_format="bed",
      output_type="IDR thresholded peaks",
      assembly="GRCh38"
    )
    ```
    
    Expected output (fields abridged):
    ```json
    {
      "results": [
        {"accession": "ENCFF789NKX", "file_format": "bed", "file_type": "bed narrowPeak", "output_type": "IDR thresholded peaks", "assembly": "GRCh38", "file_size": 1468006, "file_size_human": "1.4 MB", "experiment_accession": "ENCSR447NKX"}
      ],
      "total": 1,
      "limit": 25,
      "offset": 0,
      "has_more": false,
      "next_offset": null
    }
    ```
    
    ## Integration
    
    | This skill produces... | Feed into... | Using tool/skill |
    |---|---|---|
    | Enriched motif lists (HOMER/MEME output) | TF identification | cross-reference -> Open Targets |
    | De novo motifs (position weight matrices) | JASPAR comparison | jaspar-motifs skill |
    | Co-binding TF predictions | Regulatory network | integrative-analysis skill |
    | Motif locations (BED format) | Variant overlap | variant-annotation skill |
    | Background-corrected enrichment scores | Publication tables | scientific-writing skill |
    
    ## Related Skills
    
    - **regulatory-elements** -- Identify cis-regulatory elements that can be further characterized by motif content
    - **epigenome-profiling** -- Comprehensive epigenomic profiles provide context for interpreting which TFs are active
    - **histone-aggregation** -- Union peak sets from multiple histone experiments provide genomic context for motif results
    - **accessibility-aggregation** -- Union ATAC/DNase peak sets define the accessible genome where TF binding occurs
    - **peak-annotation** -- Annotate motif-containing peaks with genomic features and gene associations
    - **visualization-workflow** -- Visualize motif enrichment at peaks using deepTools heatmaps centered on motif instances
    - **publication-trust** -- Verify literature claims backing analytical decisions
    
    ## For the request: "$ARGUMENTS"
    

Comments (0)

Sign in to join the conversation.

No comments yet.

Reviews (0)

No reviews yet.

Related