[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M73J72Y62PJ7QJ8NRWAR026S":3,"skill-same:01M73J72Y62PJ7QJ8NRWAR026S":48},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":29,"ownerHtmlUrl":30,"ownerBlogUrl":31,"ownerDescription":32,"updatedAt":33,"install":34,"resources":47},"01M73J72Y62PJ7QJ8NRWAR026S","remap-database",null,"Query ReMap 2022 TF ChIP-seq peak database via REST API and BED downloads. Retrieve TF peaks overlapping a region (chr:start-end), peaks near a gene, TFs by species, peaks filtered by biotype (promoter, enhancer), and BED files for a TF-cell type pair. Use for TF co-occupancy, regulatory annotation, and TF binding atlases. Use jaspar-database for PWM motifs; encode-database for ENCODE tracks.","bg-szy\u002FTOP-SKILLS","bg-szy","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F106576190?v=4","01M73A4E8KPV67SFXRY8XZGNBX","ShuZhiyong","01M73A4E96MQ294MHM74TZBVQD",6,"CC-BY-4.0","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fawesome-skills\u002Fremap-database\u002FSKILL.md",[],[],"2026-11-11 15:11:14",false,"---\nname: \"remap-database\"\ndescription: \"Query ReMap 2022 TF ChIP-seq peak database via REST API and BED downloads. Retrieve TF peaks overlapping a region (chr:start-end), peaks near a gene, TFs by species, peaks filtered by biotype (promoter, enhancer), and BED files for a TF-cell type pair. Use for TF co-occupancy, regulatory annotation, and TF binding atlases. Use jaspar-database for PWM motifs; encode-database for ENCODE tracks.\"\nlicense: \"CC-BY-4.0\"\n---\n\n# ReMap Database\n\n## Overview\n\nReMap 2022 is an integrative database of transcription factor (TF), cofactor, and chromatin regulator binding sites derived from uniformly reprocessed ChIP-seq experiments. The 2022 release catalogs 165 million non-redundant peaks from 8,113 ChIP-seq datasets covering 1,210 TFs across human (hg38\u002Fhg19), mouse (mm10), Drosophila, and Arabidopsis genomes. All peaks are called with a consistent pipeline from public GEO\u002FArrayExpress experiments. Access is via the ReMap 2022 REST API at `https:\u002F\u002Fremap2022.univ-amu.fr\u002Fapi\u002F` and bulk BED file downloads; no authentication required.\n\n## When to Use\n\n- Finding all TFs with ChIP-seq peaks overlapping a genomic region of interest (e.g., a GWAS SNP locus or candidate enhancer)\n- Retrieving TF peaks near a gene's transcription start site to map its proximal regulatory landscape\n- Listing all TFs available in ReMap for human or mouse with their peak and dataset counts\n- Filtering ChIP-seq peaks by regulatory biotype annotation (promoter, enhancer, exon, intron, intergenic) for a TF in a specific cell line\n- Downloading a BED file of all binding peaks for a TF across all cell types for offline analysis\n- Identifying co-binding TFs at a locus by querying all overlapping peaks and grouping by TF name\n- Use `jaspar-database` instead when you need PWM\u002FPFM sequence models of TF binding specificity rather than ChIP-seq peak locations\n- For ENCODE-specific regulatory tracks and accessibility data use `encode-database`; ReMap aggregates TF binding peaks from many sources including ENCODE\n\n## Prerequisites\n\n- **Python packages**: `requests`, `pandas`, `matplotlib`\n- **Data requirements**: genomic coordinates (GRCh38\u002Fhg38 or hg19), gene names, or TF names\n- **Environment**: internet connection; no API key required\n- **Rate limits**: no official published limits; use `time.sleep(0.5)` between batch requests to avoid server overload\n- **Note**: The ReMap API is a research API; endpoint availability may vary. All examples include a BED download fallback.\n\n```bash\npip install requests pandas matplotlib\n```\n\n## Quick Start\n\n```python\nimport requests\n\nREMAP_API = \"https:\u002F\u002Fremap2022.univ-amu.fr\u002Fapi\u002Fv1\"\n\n# Query TF peaks overlapping a genomic region\nr = requests.get(f\"{REMAP_API}\u002Fpeaks\u002Foverlap\u002F\", params={\n    \"chr\": \"chr17\",\n    \"start\": 7_670_000,\n    \"end\": 7_690_000,\n    \"assembly\": \"hg38\"\n}, timeout=30)\nr.raise_for_status()\npeaks = r.json()\nprint(f\"Peaks overlapping TP53 locus: {len(peaks)}\")\ntfs = set(p.get(\"name\", \"\").split(\":\")[0] for p in peaks)\nprint(f\"Unique TFs: {len(tfs)}\")\nprint(f\"TF names (first 10): {sorted(tfs)[:10]}\")\n```\n\n## Core API\n\n### Query 1: Region Overlap\n\nFind all TF ChIP-seq peaks overlapping a specified genomic window. Returns peak records including TF name, cell type, coordinates, and score.\n\n```python\nimport requests, time, pandas as pd\n\nREMAP_API = \"https:\u002F\u002Fremap2022.univ-amu.fr\u002Fapi\u002Fv1\"\n\ndef query_region(chrom, start, end, assembly=\"hg38\", timeout=30):\n    \"\"\"Return all ReMap peaks overlapping [chrom:start-end].\"\"\"\n    r = requests.get(f\"{REMAP_API}\u002Fpeaks\u002Foverlap\u002F\", params={\n        \"chr\": chrom, \"start\": start, \"end\": end, \"assembly\": assembly\n    }, timeout=timeout)\n    r.raise_for_status()\n    return r.json()\n\n# Query 100 kb window on chr17 around TP53\npeaks = query_region(\"chr17\", 7_670_000, 7_690_000, assembly=\"hg38\")\nprint(f\"Total peaks: {len(peaks)}\")\n\n# Parse name field: format is \"TF:experiment_id:cell_type\"\nrows = []\nfor p in peaks:\n    parts = p.get(\"name\", \"::\").split(\":\")\n    tf   = parts[0] if len(parts) > 0 else \"\"\n    exp  = parts[1] if len(parts) > 1 else \"\"\n    cell = parts[2] if len(parts) > 2 else \"\"\n    rows.append({\n        \"chr\": p.get(\"chr\", p.get(\"chrom\", \"\")),\n        \"start\": p.get(\"start\", 0),\n        \"end\": p.get(\"end\", 0),\n        \"tf_name\": tf,\n        \"experiment_id\": exp,\n        \"cell_type\": cell,\n        \"score\": p.get(\"score\", 0),\n    })\n\ndf = pd.DataFrame(rows)\nprint(f\"\\nUnique TFs: {df['tf_name'].nunique()}\")\nprint(f\"Top TFs by peak count:\\n{df['tf_name'].value_counts().head(10).to_string()}\")\n```\n\n```python\n# Fallback: if API is unavailable, use a locally downloaded BED file\n# Download from: https:\u002F\u002Fremap2022.univ-amu.fr\u002Fdownload_page\n# e.g., remap2022_all_macs2_hg38_v1_0.bed.gz\n\nimport pandas as pd\n\ndef query_region_from_bed(bed_file, chrom, start, end):\n    \"\"\"Filter a ReMap BED file for overlapping peaks.\"\"\"\n    cols = [\"chr\", \"start\", \"end\", \"name\", \"score\", \"strand\",\n            \"thick_start\", \"thick_end\", \"color\"]\n    df = pd.read_csv(bed_file, sep=\"\\t\", header=None, names=cols,\n                     compression=\"infer\")\n    mask = (df[\"chr\"] == chrom) & (df[\"end\"] > start) & (df[\"start\"] \u003C end)\n    return df[mask].reset_index(drop=True)\n\n# Usage (requires downloaded BED):\n# df = query_region_from_bed(\"remap2022_all_macs2_hg38_v1_0.bed.gz\",\n#                             \"chr17\", 7_670_000, 7_690_000)\n```\n\n### Query 2: Gene-Centric Query\n\nRetrieve all TF ChIP-seq peaks near a gene's TSS, providing a promoter-proximal regulatory landscape for the gene.\n\n```python\nimport requests, time, pandas as pd\n\nREMAP_API = \"https:\u002F\u002Fremap2022.univ-amu.fr\u002Fapi\u002Fv1\"\n\ndef query_gene_peaks(gene_name, assembly=\"hg38\", timeout=30):\n    \"\"\"Return all ReMap peaks near a gene TSS.\"\"\"\n    r = requests.get(f\"{REMAP_API}\u002Fpeaks\u002Fgene\u002F\", params={\n        \"gene\": gene_name, \"assembly\": assembly\n    }, timeout=timeout)\n    r.raise_for_status()\n    return r.json()\n\npeaks = query_gene_peaks(\"MYC\", assembly=\"hg38\")\nprint(f\"Peaks near MYC TSS: {len(peaks)}\")\n\nrows = []\nfor p in peaks:\n    parts = p.get(\"name\", \"::\").split(\":\")\n    rows.append({\n        \"tf_name\": parts[0] if parts else \"\",\n        \"cell_type\": parts[2] if len(parts) > 2 else \"\",\n        \"chr\": p.get(\"chr\", p.get(\"chrom\", \"\")),\n        \"start\": p.get(\"start\", 0),\n        \"end\": p.get(\"end\", 0),\n        \"score\": p.get(\"score\", 0),\n        \"biotype\": p.get(\"biotype\", \"\"),\n    })\n\ndf = pd.DataFrame(rows)\nprint(f\"\\nTFs near MYC TSS ({df['tf_name'].nunique()} unique):\")\nprint(df[\"tf_name\"].value_counts().head(10).to_string())\nprint(f\"\\nCell types represented: {df['cell_type'].nunique()}\")\n```\n\n### Query 3: TF Browser\n\nList all TFs available in ReMap for a given genome assembly, with peak and experiment counts.\n\n```python\nimport requests, time, pandas as pd\n\nREMAP_API = \"https:\u002F\u002Fremap2022.univ-amu.fr\u002Fapi\u002Fv1\"\n\ndef list_tfs(assembly=\"hg38\", timeout=30):\n    \"\"\"Return all TFs in ReMap for the given assembly with statistics.\"\"\"\n    r = requests.get(f\"{REMAP_API}\u002Ftfbs\u002Flist\u002F\", params={\"assembly\": assembly}, timeout=timeout)\n    r.raise_for_status()\n    return r.json()\n\ndef get_database_stats(assembly=\"hg38\", timeout=30):\n    \"\"\"Return overall database statistics for the assembly.\"\"\"\n    r = requests.get(f\"{REMAP_API}\u002Fstats\u002F\", params={\"assembly\": assembly}, timeout=timeout)\n    r.raise_for_status()\n    return r.json()\n\n# Database overview\ntry:\n    stats = get_database_stats(\"hg38\")\n    print(f\"ReMap 2022 hg38 statistics:\")\n    for k, v in stats.items():\n        print(f\"  {k}: {v}\")\nexcept Exception as e:\n    print(f\"Stats endpoint unavailable: {e}\")\n    print(\"ReMap 2022 hg38: 165M peaks, 1,210 TFs, 8,113 datasets (from publication)\")\n\n# TF list\ntry:\n    tfs = list_tfs(\"hg38\")\n    df_tfs = pd.DataFrame(tfs)\n    print(f\"\\nTFs available (hg38): {len(df_tfs)}\")\n    if \"peak_count\" in df_tfs.columns:\n        top = df_tfs.nlargest(10, \"peak_count\")[[\"name\", \"peak_count\", \"dataset_count\"]]\n        print(\"Top 10 TFs by peak count:\")\n        print(top.to_string(index=False))\nexcept Exception as e:\n    print(f\"TF list endpoint unavailable: {e}\")\n    print(\"Use TF name queries directly (Query 4) or download TF-specific BED files.\")\n```\n\n### Query 4: TF-Specific Peak Query\n\nRetrieve all peaks for a named TF in a given assembly, optionally filtered by cell type.\n\n```python\nimport requests, time, pandas as pd\n\nREMAP_API = \"https:\u002F\u002Fremap2022.univ-amu.fr\u002Fapi\u002Fv1\"\n\ndef query_tf_peaks(tf_name, assembly=\"hg38\", timeout=30):\n    \"\"\"Return all ChIP-seq peaks for a TF across all cell types.\"\"\"\n    r = requests.get(f\"{REMAP_API}\u002Ftfbs\u002Fname\u002F\", params={\n        \"name\": tf_name, \"assembly\": assembly\n    }, timeout=timeout)\n    r.raise_for_status()\n    return r.json()\n\npeaks = query_tf_peaks(\"CTCF\", assembly=\"hg38\")\nprint(f\"CTCF peaks (all cell types): {len(peaks)}\")\n\n# Parse and summarize\nrows = []\nfor p in peaks:\n    parts = p.get(\"name\", \"::\").split(\":\")\n    rows.append({\n        \"tf_name\": parts[0] if parts else \"\",\n        \"cell_type\": parts[2] if len(parts) > 2 else \"\",\n        \"chr\":   p.get(\"chr\",   p.get(\"chrom\", \"\")),\n        \"start\": p.get(\"start\", 0),\n        \"end\":   p.get(\"end\",   0),\n        \"score\": p.get(\"score\", 0),\n        \"biotype\": p.get(\"biotype\", \"\"),\n    })\n\ndf = pd.DataFrame(rows)\nprint(f\"Cell types: {df['cell_type'].nunique()}\")\nprint(f\"Chromosomes: {df['chr'].nunique()}\")\nprint(f\"Peak width stats (bp):\")\ndf[\"width\"] = df[\"end\"] - df[\"start\"]\nprint(f\"  Median: {df['width'].median():.0f}  Mean: {df['width'].mean():.0f}  \"\n      f\"Min: {df['width'].min()}  Max: {df['width'].max()}\")\n```\n\n### Query 5: Biotype Filter and Regulatory Annotation\n\nFilter peaks by regulatory biotype annotation to identify binding at promoters, enhancers, or intergenic regions.\n\n```python\nimport requests, pandas as pd, matplotlib.pyplot as plt\n\nREMAP_API = \"https:\u002F\u002Fremap2022.univ-amu.fr\u002Fapi\u002Fv1\"\n\ndef get_biotypes(assembly=\"hg38\", timeout=30):\n    \"\"\"List all regulatory biotype categories available.\"\"\"\n    r = requests.get(f\"{REMAP_API}\u002Fbiotypes\u002F\", params={\"assembly\": assembly}, timeout=timeout)\n    r.raise_for_status()\n    return r.json()\n\ndef query_tf_by_biotype(tf_name, biotype, assembly=\"hg38\", timeout=30):\n    \"\"\"Retrieve TF peaks filtered by regulatory biotype.\"\"\"\n    r = requests.get(f\"{REMAP_API}\u002Fpeaks\u002Fbiotype\u002F\", params={\n        \"name\": tf_name, \"biotype\": biotype, \"assembly\": assembly\n    }, timeout=timeout)\n    r.raise_for_status()\n    return r.json()\n\n# List available biotypes\ntry:\n    biotypes = get_biotypes(\"hg38\")\n    print(f\"Available biotypes: {biotypes}\")\nexcept Exception:\n    biotypes = [\"promoter\", \"enhancer\", \"exon\", \"intron\", \"intergenic\", \"UTR\"]\n    print(f\"Using known biotypes: {biotypes}\")\n\n# Query CTCF peaks and plot biotype distribution\npeaks = query_tf_peaks(\"CTCF\", assembly=\"hg38\")  # from Query 4 function above\n\ndef query_tf_peaks(tf_name, assembly=\"hg38\", timeout=30):\n    r = requests.get(f\"https:\u002F\u002Fremap2022.univ-amu.fr\u002Fapi\u002Fv1\u002Ftfbs\u002Fname\u002F\",\n                     params={\"name\": tf_name, \"assembly\": assembly}, timeout=timeout)\n    r.raise_for_status()\n    return r.json()\n\npeaks = query_tf_peaks(\"CTCF\")\nrows = [{\"biotype\": p.get(\"biotype\", \"unknown\"),\n         \"cell_type\": p.get(\"name\", \"::\").split(\":\")[2] if len(p.get(\"name\",\"\").split(\":\")) > 2 else \"\"}\n        for p in peaks]\ndf = pd.DataFrame(rows)\n\nbiotype_counts = df[\"biotype\"].value_counts()\nbiotype_counts = biotype_counts[biotype_counts > 0]\nprint(f\"\\nCTCF peak biotype distribution:\")\nprint(biotype_counts.to_string())\n\n# Stacked bar chart across top 5 cell types\ntop_cells = df[\"cell_type\"].value_counts().head(5).index.tolist()\npivot = (df[df[\"cell_type\"].isin(top_cells)]\n         .groupby([\"cell_type\", \"biotype\"])\n         .size()\n         .unstack(fill_value=0))\n\nfig, ax = plt.subplots(figsize=(9, 5))\npivot.plot(kind=\"bar\", stacked=True, ax=ax, colormap=\"tab10\", edgecolor=\"white\")\nax.set_xlabel(\"Cell Type\")\nax.set_ylabel(\"Peak Count\")\nax.set_title(\"CTCF ChIP-seq Peak Biotype Distribution by Cell Type (ReMap 2022, hg38)\")\nax.legend(title=\"Biotype\", bbox_to_anchor=(1.01, 1), loc=\"upper left\", fontsize=8)\nplt.tight_layout()\nplt.savefig(\"CTCF_biotype_distribution.png\", dpi=150, bbox_inches=\"tight\")\nprint(\"Saved CTCF_biotype_distribution.png\")\n```\n\n## Key Concepts\n\n### Peak Name Field Format\n\nThe `name` field in every ReMap peak record encodes three pieces of information as a colon-separated string:\n\n```\nTF_NAME:EXPERIMENT_ID:CELL_TYPE\n```\n\nFor example: `CTCF:GSE30263.SRX028592:GM12878`\n\nAlways parse with `.split(\":\")` and guard against missing parts. Some records may have fewer than three components if metadata is incomplete.\n\n### Assemblies\n\n| Assembly code | Organism | Notes |\n|---------------|----------|-------|\n| `hg38` | Homo sapiens (GRCh38) | Primary human assembly in ReMap 2022 |\n| `hg19` | Homo sapiens (GRCh37) | Legacy human assembly; fewer datasets |\n| `mm10` | Mus musculus | Primary mouse assembly |\n| `dm6` | Drosophila melanogaster | Smaller dataset collection |\n| `tair10` | Arabidopsis thaliana | Plant TF dataset |\n\n### BED File Download (API Fallback)\n\nWhen the REST API is unavailable or for offline bulk analysis, ReMap provides pre-built BED files at `https:\u002F\u002Fremap2022.univ-amu.fr\u002Fdownload_page`. Key files:\n\n- `remap2022_all_macs2_hg38_v1_0.bed.gz` — all peaks, hg38 (large, ~5 GB)\n- `remap2022_{TF}_macs2_hg38_v1_0.bed.gz` — per-TF peak files\n- `remap2022_crm_macs2_hg38_v1_0.bed.gz` — cis-regulatory modules (merged peaks)\n\n```python\nimport pandas as pd\n\ndef load_remap_bed(bed_path, chrom=None, start=None, end=None):\n    \"\"\"\n    Load a ReMap BED file with optional region filter.\n    Columns: chr, start, end, name (TF:exp:cell), score, strand,\n             thick_start, thick_end, itemRgb\n    \"\"\"\n    cols = [\"chr\", \"start\", \"end\", \"name\", \"score\", \"strand\",\n            \"thick_start\", \"thick_end\", \"itemRgb\"]\n    df = pd.read_csv(bed_path, sep=\"\\t\", header=None, names=cols,\n                     compression=\"infer\", low_memory=False)\n    if chrom:\n        df = df[df[\"chr\"] == chrom]\n    if start is not None and end is not None:\n        df = df[(df[\"end\"] > start) & (df[\"start\"] \u003C end)]\n    # Parse name field\n    parts = df[\"name\"].str.split(\":\", expand=True)\n    df[\"tf_name\"]       = parts[0]\n    df[\"experiment_id\"] = parts[1] if 1 in parts.columns else \"\"\n    df[\"cell_type\"]     = parts[2] if 2 in parts.columns else \"\"\n    return df.reset_index(drop=True)\n\n# Usage example (offline):\n# df = load_remap_bed(\"remap2022_CTCF_macs2_hg38_v1_0.bed.gz\",\n#                     chrom=\"chr17\", start=7_670_000, end=7_690_000)\n# print(df.head())\n```\n\n## Common Workflows\n\n### Workflow 1: TF Co-occupancy Analysis at a Locus\n\n**Goal**: Identify all TFs with ChIP-seq evidence at a genomic locus and rank by peak count, then export a co-occupancy matrix.\n\n```python\nimport requests, time, pandas as pd, matplotlib.pyplot as plt\n\nREMAP_API = \"https:\u002F\u002Fremap2022.univ-amu.fr\u002Fapi\u002Fv1\"\n\ndef query_region(chrom, start, end, assembly=\"hg38\", timeout=30):\n    r = requests.get(f\"{REMAP_API}\u002Fpeaks\u002Foverlap\u002F\", params={\n        \"chr\": chrom, \"start\": start, \"end\": end, \"assembly\": assembly\n    }, timeout=timeout)\n    r.raise_for_status()\n    return r.json()\n\ndef parse_peaks(peaks):\n    rows = []\n    for p in peaks:\n        parts = p.get(\"name\", \"::\").split(\":\")\n        rows.append({\n            \"tf_name\":  parts[0] if len(parts) > 0 else \"unknown\",\n            \"cell_type\": parts[2] if len(parts) > 2 else \"unknown\",\n            \"chr\":   p.get(\"chr\",   p.get(\"chrom\", \"\")),\n            \"start\": p.get(\"start\", 0),\n            \"end\":   p.get(\"end\",   0),\n            \"score\": p.get(\"score\", 0),\n        })\n    return pd.DataFrame(rows)\n\n# BRCA1 promoter region (GRCh38)\npeaks = query_region(\"chr17\", 43_044_000, 43_050_000, assembly=\"hg38\")\ndf = parse_peaks(peaks)\nprint(f\"Peaks at BRCA1 promoter: {len(df)}\")\n\n# TF occupancy summary\ntf_summary = (df.groupby(\"tf_name\")\n                .agg(peak_count=(\"tf_name\", \"count\"),\n                     cell_types=(\"cell_type\", \"nunique\"),\n                     mean_score=(\"score\", \"mean\"))\n                .sort_values(\"peak_count\", ascending=False))\nprint(f\"\\nTop TFs at BRCA1 promoter:\")\nprint(tf_summary.head(15).to_string())\ntf_summary.to_csv(\"BRCA1_promoter_TF_occupancy.csv\")\n\n# Horizontal bar chart\ntop = tf_summary.head(20)\nfig, ax = plt.subplots(figsize=(8, 6))\nax.barh(top.index[::-1], top[\"peak_count\"][::-1], color=\"#1f77b4\", edgecolor=\"white\")\nax.set_xlabel(\"Number of ChIP-seq Peaks\")\nax.set_title(\"TF Co-occupancy at BRCA1 Promoter (ReMap 2022, hg38)\")\nplt.tight_layout()\nplt.savefig(\"BRCA1_promoter_TF_cooccupancy.png\", dpi=150, bbox_inches=\"tight\")\nprint(\"Saved BRCA1_promoter_TF_cooccupancy.png\")\n```\n\n### Workflow 2: Gene Regulatory Profile — TSS-Proximal TF Binding Atlas\n\n**Goal**: For a list of genes, retrieve their promoter-proximal TF binding profiles and compare the TF repertoires across genes.\n\n```python\nimport requests, time, pandas as pd\n\nREMAP_API = \"https:\u002F\u002Fremap2022.univ-amu.fr\u002Fapi\u002Fv1\"\n\ndef query_gene_peaks(gene_name, assembly=\"hg38\", timeout=30):\n    try:\n        r = requests.get(f\"{REMAP_API}\u002Fpeaks\u002Fgene\u002F\", params={\n            \"gene\": gene_name, \"assembly\": assembly\n        }, timeout=timeout)\n        r.raise_for_status()\n        return r.json()\n    except Exception as e:\n        print(f\"  Warning: {gene_name} failed — {e}\")\n        return []\n\ngenes_of_interest = [\"MYC\", \"TP53\", \"BRCA1\", \"EGFR\", \"CDK4\"]\ngene_tf_profiles = {}\n\nfor gene in genes_of_interest:\n    peaks = query_gene_peaks(gene, assembly=\"hg38\")\n    if peaks:\n        tfs = set()\n        for p in peaks:\n            parts = p.get(\"name\", \"\").split(\":\")\n            if parts:\n                tfs.add(parts[0])\n        gene_tf_profiles[gene] = tfs\n        print(f\"{gene}: {len(peaks)} peaks, {len(tfs)} unique TFs\")\n    time.sleep(0.5)\n\n# Build binary TF presence matrix\nall_tfs = sorted(set().union(*gene_tf_profiles.values()))\nmatrix = pd.DataFrame(\n    {gene: [1 if tf in gene_tf_profiles.get(gene, set()) else 0 for tf in all_tfs]\n     for gene in genes_of_interest},\n    index=all_tfs\n)\nprint(f\"\\nTF × Gene matrix: {matrix.shape}\")\nprint(f\"TFs shared by all genes: {(matrix.sum(axis=1) == len(genes_of_interest)).sum()}\")\nmatrix.to_csv(\"gene_TF_binding_atlas.csv\")\nprint(\"Saved gene_TF_binding_atlas.csv\")\n```\n\n### Workflow 3: Download and Analyze TF Peak BED File\n\n**Goal**: Download a TF-specific ReMap BED file and analyze its genomic distribution with pandas.\n\n```python\nimport requests, gzip, io, pandas as pd, time\n\n# ReMap provides per-TF BED files. For large-scale offline analysis:\nREMAP_DOWNLOAD_BASE = \"https:\u002F\u002Fremap2022.univ-amu.fr\u002Fstorage\u002Fremap2022\u002Fhg38\u002FMACS2\"\n\ndef download_tf_bed(tf_name, assembly=\"hg38\", save_path=None):\n    \"\"\"\n    Attempt to download TF-specific BED file from ReMap.\n    Falls back to API region query if download unavailable.\n    \"\"\"\n    filename = f\"remap2022_{tf_name}_macs2_{assembly}_v1_0.bed.gz\"\n    url = f\"{REMAP_DOWNLOAD_BASE}\u002F{filename}\"\n    print(f\"Attempting download: {url}\")\n    r = requests.get(url, stream=True, timeout=60)\n    if r.status_code == 200:\n        if save_path:\n            with open(save_path, \"wb\") as f:\n                for chunk in r.iter_content(chunk_size=8192):\n                    f.write(chunk)\n            print(f\"Saved: {save_path}\")\n            return save_path\n        else:\n            # Read directly into DataFrame\n            content = b\"\".join(r.iter_content(chunk_size=8192))\n            cols = [\"chr\", \"start\", \"end\", \"name\", \"score\", \"strand\",\n                    \"thick_start\", \"thick_end\", \"itemRgb\"]\n            with gzip.open(io.BytesIO(content), \"rt\") as gz:\n                df = pd.read_csv(gz, sep=\"\\t\", header=None, names=cols)\n            return df\n    else:\n        print(f\"Download returned {r.status_code}; use API query as fallback\")\n        return None\n\n# Analyze a downloaded BED file\ndef analyze_remap_bed(df):\n    \"\"\"Compute summary statistics for a ReMap peak DataFrame.\"\"\"\n    parts = df[\"name\"].str.split(\":\", expand=True)\n    df = df.copy()\n    df[\"tf_name\"]   = parts[0]\n    df[\"cell_type\"] = parts[2] if 2 in parts.columns else \"unknown\"\n    df[\"width\"] = df[\"end\"] - df[\"start\"]\n\n    print(f\"Total peaks: {len(df):,}\")\n    print(f\"Unique TFs: {df['tf_name'].nunique()}\")\n    print(f\"Unique cell types: {df['cell_type'].nunique()}\")\n    print(f\"\\nPeak width (bp): median={df['width'].median():.0f}  \"\n          f\"mean={df['width'].mean():.0f}  range=[{df['width'].min()}, {df['width'].max()}]\")\n    print(f\"\\nChromosome distribution:\")\n    chr_counts = df[\"chr\"].value_counts().head(5)\n    print(chr_counts.to_string())\n    return df\n\n# Example usage (requires BED download or substitute with API results):\n# df_raw = download_tf_bed(\"CTCF\", save_path=\"CTCF_hg38.bed.gz\")\n# if df_raw is not None:\n#     df_analyzed = analyze_remap_bed(df_raw)\n```\n\n## Key Parameters\n\n| Parameter | Endpoint | Default | Range \u002F Options | Effect |\n|-----------|----------|---------|-----------------|--------|\n| `chr` | `\u002Fpeaks\u002Foverlap\u002F` | — | `chr1`–`chrX`, `chrY`, `chrM` | Chromosome for region query (include `chr` prefix) |\n| `start` | `\u002Fpeaks\u002Foverlap\u002F` | — | Integer genomic coordinate | Region start (0-based) |\n| `end` | `\u002Fpeaks\u002Foverlap\u002F` | — | Integer genomic coordinate | Region end (exclusive) |\n| `assembly` | All endpoints | — | `hg38`, `hg19`, `mm10`, `dm6`, `tair10` | Genome assembly for coordinates and peak lookup |\n| `gene` | `\u002Fpeaks\u002Fgene\u002F` | — | HGNC gene symbol (e.g., `TP53`, `MYC`) | Queries peaks near the gene's annotated TSS |\n| `name` | `\u002Ftfbs\u002Fname\u002F` | — | TF name as in ReMap (e.g., `CTCF`, `SP1`) | TF name is case-sensitive; match ReMap TF naming |\n| `biotype` | `\u002Fpeaks\u002Fbiotype\u002F` | — | `promoter`, `enhancer`, `exon`, `intron`, `intergenic`, `UTR` | Filters peaks by Ensembl regulatory biotype |\n| `timeout` | All requests | 30 | Integer seconds | Increase to 60–120 for large gene\u002FTF queries |\n\n## Best Practices\n\n1. **Parse the `name` field defensively**: The `TF:experiment:cell_type` format may have fewer than three components for some records. Always guard with `parts[n] if len(parts) > n else \"\"`.\n\n2. **Use BED downloads for genome-wide analyses**: Querying large genomic regions or all peaks for a TF via the REST API can time out. For whole-genome or per-chromosome scans, download the per-TF or per-assembly BED files from the ReMap download page and filter locally with pandas or bedtools.\n\n3. **Cross-reference with JASPAR for sequence evidence**: ReMap peaks show where TF binding was detected by ChIP-seq (positional evidence); JASPAR PWMs show what sequence the TF prefers (motif evidence). For robust regulatory annotation, require both: a ReMap peak in the region AND a JASPAR motif hit within the peak.\n\n4. **Use `time.sleep(0.5)` in batch loops**: The ReMap API serves a research community; polite request pacing prevents throttling.\n\n5. **Validate assembly coordinates**: ReMap 2022 hg38 peaks use 0-based half-open BED coordinates (`[start, end)`). When comparing with VCF or 1-based GFF coordinates, add 1 to `start`.\n\n## Common Recipes\n\n### Recipe: Find TFs Binding at a GWAS SNP\n\nWhen to use: Prioritize functional candidates from a GWAS hit by identifying which TFs bind at the SNP location.\n\n```python\nimport requests\n\nREMAP_API = \"https:\u002F\u002Fremap2022.univ-amu.fr\u002Fapi\u002Fv1\"\n\ndef tfs_at_snp(chrom, pos, window=500, assembly=\"hg38\"):\n    \"\"\"Find TFs with ChIP-seq peaks overlapping a SNP position ± window bp.\"\"\"\n    r = requests.get(f\"{REMAP_API}\u002Fpeaks\u002Foverlap\u002F\", params={\n        \"chr\": chrom, \"start\": pos - window, \"end\": pos + window,\n        \"assembly\": assembly\n    }, timeout=30)\n    r.raise_for_status()\n    peaks = r.json()\n    tfs = {}\n    for p in peaks:\n        parts = p.get(\"name\", \"::\").split(\":\")\n        tf = parts[0] if parts else \"unknown\"\n        tfs[tf] = tfs.get(tf, 0) + 1\n    return dict(sorted(tfs.items(), key=lambda x: -x[1]))\n\n# Example: rs2736100 (TERT locus, chr5:1,286,401)\nsnp_tfs = tfs_at_snp(\"chr5\", 1_286_401, window=500, assembly=\"hg38\")\nprint(f\"TFs at TERT GWAS SNP (±500 bp): {len(snp_tfs)}\")\nfor tf, count in list(snp_tfs.items())[:10]:\n    print(f\"  {tf:\u003C20s} {count:3d} peaks\")\n```\n\n### Recipe: Compare TF Binding Profiles of Two Genes\n\nWhen to use: Check whether two co-regulated genes share the same upstream TF binding landscape.\n\n```python\nimport requests, time\n\nREMAP_API = \"https:\u002F\u002Fremap2022.univ-amu.fr\u002Fapi\u002Fv1\"\n\ndef get_gene_tfs(gene, assembly=\"hg38\"):\n    try:\n        r = requests.get(f\"{REMAP_API}\u002Fpeaks\u002Fgene\u002F\", params={\"gene\": gene, \"assembly\": assembly}, timeout=30)\n        r.raise_for_status()\n        peaks = r.json()\n        return set(p.get(\"name\", \"\").split(\":\")[0] for p in peaks if p.get(\"name\", \"\"))\n    except Exception as e:\n        print(f\"Warning: {gene} → {e}\")\n        return set()\n\ngene_a, gene_b = \"MYC\", \"MYCN\"\ntfs_a = get_gene_tfs(gene_a)\ntime.sleep(0.5)\ntfs_b = get_gene_tfs(gene_b)\n\nshared = tfs_a & tfs_b\nonly_a = tfs_a - tfs_b\nonly_b = tfs_b - tfs_a\n\nprint(f\"{gene_a} TFs: {len(tfs_a)}  |  {gene_b} TFs: {len(tfs_b)}\")\nprint(f\"Shared: {len(shared)}  |  {gene_a}-only: {len(only_a)}  |  {gene_b}-only: {len(only_b)}\")\nprint(f\"\\nShared TFs (first 15): {sorted(shared)[:15]}\")\nprint(f\"\\n{gene_a}-only (first 10): {sorted(only_a)[:10]}\")\n```\n\n### Recipe: Export Region Peaks as BED\n\nWhen to use: Export ReMap query results to BED format for downstream bedtools intersection or IGV visualization.\n\n```python\nimport requests, pandas as pd\n\nREMAP_API = \"https:\u002F\u002Fremap2022.univ-amu.fr\u002Fapi\u002Fv1\"\n\ndef export_region_as_bed(chrom, start, end, outfile, assembly=\"hg38\"):\n    \"\"\"Query ReMap region and save as 6-column BED file.\"\"\"\n    r = requests.get(f\"{REMAP_API}\u002Fpeaks\u002Foverlap\u002F\", params={\n        \"chr\": chrom, \"start\": start, \"end\": end, \"assembly\": assembly\n    }, timeout=30)\n    r.raise_for_status()\n    peaks = r.json()\n    rows = [{\n        \"chr\":   p.get(\"chr\",   p.get(\"chrom\", \"\")),\n        \"start\": p.get(\"start\", 0),\n        \"end\":   p.get(\"end\",   0),\n        \"name\":  p.get(\"name\",  \".\"),\n        \"score\": p.get(\"score\", 0),\n        \"strand\": p.get(\"strand\", \".\"),\n    } for p in peaks]\n    df = pd.DataFrame(rows)\n    df = df.sort_values([\"chr\", \"start\"])\n    df.to_csv(outfile, sep=\"\\t\", header=False, index=False)\n    print(f\"Saved {len(df)} peaks to {outfile}\")\n    return df\n\nexport_region_as_bed(\"chr17\", 7_670_000, 7_690_000, \"TP53_locus_remap.bed\")\n```\n\n## Troubleshooting\n\n| Problem | Cause | Solution |\n|---------|-------|----------|\n| `404 Not Found` from API | Endpoint path changed or unavailable | Check `https:\u002F\u002Fremap2022.univ-amu.fr\u002Fapi\u002F` for current endpoint list; fall back to BED download |\n| Empty JSON list `[]` from region query | No peaks in region, or assembly mismatch | Verify coordinates are on the correct assembly; try a wider window (±10 kb) |\n| Gene query returns empty | Gene symbol not recognized by ReMap | Try Ensembl gene symbol; some aliases are not mapped — verify with HGNC |\n| `requests.exceptions.Timeout` | Large region or slow server | Increase `timeout=60`; for regions >1 Mb use BED file download instead |\n| `name` field has only one component | Incomplete metadata in ReMap for that experiment | Guard with `parts[n] if len(parts) > n else \"unknown\"` |\n| BED download 404 | Per-TF files use exact ReMap TF naming | Check TF name case and spelling at `https:\u002F\u002Fremap2022.univ-amu.fr\u002Fdownload_page` |\n| Duplicate peaks for same TF | Multiple experiments per TF in a cell type | Group by `tf_name` and count unique experiments; deduplicate peaks with bedtools merge |\n\n## Related Skills\n\n- `jaspar-database` — TF binding motif matrices (PWMs\u002FPFMs); use alongside ReMap peak evidence for sequence-level validation\n- `encode-database` — ENCODE regulatory tracks including TF ChIP-seq, DNase-seq, and ATAC-seq; partially overlaps with ReMap\n- `homer-motif-analysis` — de novo motif discovery in ChIP-seq peak sets from ReMap or MACS3\n- `macs3-peak-calling` — call peaks from raw ChIP-seq BAM files; ReMap provides pre-called peaks from the same approach\n- `regulomedb-database` — regulatory variant scoring that integrates TF binding evidence similar to ReMap\n\n## References\n\n- [ReMap 2022 API documentation](https:\u002F\u002Fremap2022.univ-amu.fr\u002Fapi\u002F) — REST API endpoint reference and interactive explorer\n- [Hammal et al., Nucleic Acids Research 2022](https:\u002F\u002Fdoi.org\u002F10.1093\u002Fnar\u002Fgkab996) — ReMap 2022 paper describing the 2022 release (165M peaks, 1,210 TFs)\n- [ReMap portal and download page](https:\u002F\u002Fremap2022.univ-amu.fr\u002F) — web browser, download page for BED files and cis-regulatory modules\n- [Chèneby et al., Nucleic Acids Research 2020](https:\u002F\u002Fdoi.org\u002F10.1093\u002Fnar\u002Fgkz945) — ReMap 2020 paper describing the reprocessing pipeline and quality control methodology\n","# ReMap Database\n\n## Overview\n\nReMap 2022 is an integrative database of transcription factor (TF), cofactor, and chromatin regulator binding sites derived from uniformly reprocessed ChIP-seq experiments. The 2022 release catalogs 165 million non-redundant peaks from 8,113 ChIP-seq datasets covering 1,210 TFs across human (hg38\u002Fhg19), mouse (mm10), Drosophila, and Arabidopsis genomes. All peaks are called with a consistent pipeline from public GEO\u002FArrayExpress experiments. Access is via the ReMap 2022 REST API at `https:\u002F\u002Fremap2022.univ-amu.fr\u002Fapi\u002F` and bulk BED file downloads; no authentication required.\n\n## When to Use\n\n- Finding all TFs with ChIP-seq peaks overlapping a genomic region of interest (e.g., a GWAS SNP locus or candidate enhancer)\n- Retrieving TF peaks near a gene's transcription start site to map its proximal regulatory landscape\n- Listing all TFs available in ReMap for human or mouse with their peak and dataset counts\n- Filtering ChIP-seq peaks by regulatory biotype annotation (promoter, enhancer, exon, intron, intergenic) for a TF in a specific cell line\n- Downloading a BED file of all binding peaks for a TF across all cell types for offline analysis\n- Identifying co-binding TFs at a locus by querying all overlapping peaks and grouping by TF name\n- Use `jaspar-database` instead when you need PWM\u002FPFM sequence models of TF binding specificity rather than ChIP-seq peak locations\n- For ENCODE-specific regulatory tracks and accessibility data use `encode-database`; ReMap aggregates TF binding peaks from many sources including ENCODE\n\n## Prerequisites\n\n- **Python packages**: `requests`, `pandas`, `matplotlib`\n- **Data requirements**: genomic coordinates (GRCh38\u002Fhg38 or hg19), gene names, or TF names\n- **Environment**: internet connection; no API key required\n- **Rate limits**: no official published limits; use `time.sleep(0.5)` between batch requests to avoid server overload\n- **Note**: The ReMap API is a research API; endpoint availability may vary. All examples include a BED download fallback.\n\n```bash\npip install requests pandas matplotlib\n```\n\n## Quick Start\n\n```python\nimport requests\n\nREMAP_API = \"https:\u002F\u002Fremap2022.univ-amu.fr\u002Fapi\u002Fv1\"\n\n# Query TF peaks overlapping a genomic region\nr = requests.get(f\"{REMAP_API}\u002Fpeaks\u002Foverlap\u002F\", params={\n    \"chr\": \"chr17\",\n    \"start\": 7_670_000,\n    \"end\": 7_690_000,\n    \"assembly\": \"hg38\"\n}, timeout=30)\nr.raise_for_status()\npeaks = r.json()\nprint(f\"Peaks overlapping TP53 locus: {len(peaks)}\")\ntfs = set(p.get(\"name\", \"\").split(\":\")[0] for p in peaks)\nprint(f\"Unique TFs: {len(tfs)}\")\nprint(f\"TF names (first 10): {sorted(tfs)[:10]}\")\n```\n\n## Core API\n\n### Query 1: Region Overlap\n\nFind all TF ChIP-seq peaks overlapping a specified genomic window. Returns peak records including TF name, cell type, coordinates, and score.\n\n```python\nimport requests, time, pandas as pd\n\nREMAP_API = \"https:\u002F\u002Fremap2022.univ-amu.fr\u002Fapi\u002Fv1\"\n\ndef query_region(chrom, start, end, assembly=\"hg38\", timeout=30):\n    \"\"\"Return all ReMap peaks overlapping [chrom:start-end].\"\"\"\n    r = requests.get(f\"{REMAP_API}\u002Fpeaks\u002Foverlap\u002F\", params={\n        \"chr\": chrom, \"start\": start, \"end\": end, \"assembly\": assembly\n    }, timeout=timeout)\n    r.raise_for_status()\n    return r.json()\n\n# Query 100 kb window on chr17 around TP53\npeaks = query_region(\"chr17\", 7_670_000, 7_690_000, assembly=\"hg38\")\nprint(f\"Total peaks: {len(peaks)}\")\n\n# Parse name field: format is \"TF:experiment_id:cell_type\"\nrows = []\nfor p in peaks:\n    parts = p.get(\"name\", \"::\").split(\":\")\n    tf   = parts[0] if len(parts) > 0 else \"\"\n    exp  = parts[1] if len(parts) > 1 else \"\"\n    cell = parts[2] if len(parts) > 2 else \"\"\n    rows.append({\n        \"chr\": p.get(\"chr\", p.get(\"chrom\", \"\")),\n        \"start\": p.get(\"start\", 0),\n        \"end\": p.get(\"end\", 0),\n        \"tf_name\": tf,\n        \"experiment_id\": exp,\n        \"cell_type\": cell,\n        \"score\": p.get(\"score\", 0),\n    })\n\ndf = pd.DataFrame(rows)\nprint(f\"\\nUnique TFs: {df['tf_name'].nunique()}\")\nprint(f\"Top TFs by peak count:\\n{df['tf_name'].value_counts().head(10).to_string()}\")\n```\n\n```python\n# Fallback: if API is unavailable, use a locally downloaded BED file\n# Download from: https:\u002F\u002Fremap2022.univ-amu.fr\u002Fdownload_page\n# e.g., remap2022_all_macs2_hg38_v1_0.bed.gz\n\nimport pandas as pd\n\ndef query_region_from_bed(bed_file, chrom, start, end):\n    \"\"\"Filter a ReMap BED file for overlapping peaks.\"\"\"\n    cols = [\"chr\", \"start\", \"end\", \"name\", \"score\", \"strand\",\n            \"thick_start\", \"thick_end\", \"color\"]\n    df = pd.read_csv(bed_file, sep=\"\\t\", header=None, names=cols,\n                     compression=\"infer\")\n    mask = (df[\"chr\"] == chrom) & (df[\"end\"] > start) & (df[\"start\"] \u003C end)\n    return df[mask].reset_index(drop=True)\n\n# Usage (requires downloaded BED):\n# df = query_region_from_bed(\"remap2022_all_macs2_hg38_v1_0.bed.gz\",\n#                             \"chr17\", 7_670_000, 7_690_000)\n```\n\n### Query 2: Gene-Centric Query\n\nRetrieve all TF ChIP-seq peaks near a gene's TSS, providing a promoter-proximal regulatory landscape for the gene.\n\n```python\nimport requests, time, pandas as pd\n\nREMAP_API = \"https:\u002F\u002Fremap2022.univ-amu.fr\u002Fapi\u002Fv1\"\n\ndef query_gene_peaks(gene_name, assembly=\"hg38\", timeout=30):\n    \"\"\"Return all ReMap peaks near a gene TSS.\"\"\"\n    r = requests.get(f\"{REMAP_API}\u002Fpeaks\u002Fgene\u002F\", params={\n        \"gene\": gene_name, \"assembly\": assembly\n    }, timeout=timeout)\n    r.raise_for_status()\n    return r.json()\n\npeaks = query_gene_peaks(\"MYC\", assembly=\"hg38\")\nprint(f\"Peaks near MYC TSS: {len(peaks)}\")\n\nrows = []\nfor p in peaks:\n    parts = p.get(\"name\", \"::\").split(\":\")\n    rows.append({\n        \"tf_name\": parts[0] if parts else \"\",\n        \"cell_type\": parts[2] if len(parts) > 2 else \"\",\n        \"chr\": p.get(\"chr\", p.get(\"chrom\", \"\")),\n        \"start\": p.get(\"start\", 0),\n        \"end\": p.get(\"end\", 0),\n        \"score\": p.get(\"score\", 0),\n        \"biotype\": p.get(\"biotype\", \"\"),\n    })\n\ndf = pd.DataFrame(rows)\nprint(f\"\\nTFs near MYC TSS ({df['tf_name'].nunique()} unique):\")\nprint(df[\"tf_name\"].value_counts().head(10).to_string())\nprint(f\"\\nCell types represented: {df['cell_type'].nunique()}\")\n```\n\n### Query 3: TF Browser\n\nList all TFs available in ReMap for a given genome assembly, with peak and experiment counts.\n\n```python\nimport requests, time, pandas as pd\n\nREMAP_API = \"https:\u002F\u002Fremap2022.univ-amu.fr\u002Fapi\u002Fv1\"\n\ndef list_tfs(assembly=\"hg38\", timeout=30):\n    \"\"\"Return all TFs in ReMap for the given assembly with statistics.\"\"\"\n    r = requests.get(f\"{REMAP_API}\u002Ftfbs\u002Flist\u002F\", params={\"assembly\": assembly}, timeout=timeout)\n    r.raise_for_status()\n    return r.json()\n\ndef get_database_stats(assembly=\"hg38\", timeout=30):\n    \"\"\"Return overall database statistics for the assembly.\"\"\"\n    r = requests.get(f\"{REMAP_API}\u002Fstats\u002F\", params={\"assembly\": assembly}, timeout=timeout)\n    r.raise_for_status()\n    return r.json()\n\n# Database overview\ntry:\n    stats = get_database_stats(\"hg38\")\n    print(f\"ReMap 2022 hg38 statistics:\")\n    for k, v in stats.items():\n        print(f\"  {k}: {v}\")\nexcept Exception as e:\n    print(f\"Stats endpoint unavailable: {e}\")\n    print(\"ReMap 2022 hg38: 165M peaks, 1,210 TFs, 8,113 datasets (from publication)\")\n\n# TF list\ntry:\n    tfs = list_tfs(\"hg38\")\n    df_tfs = pd.DataFrame(tfs)\n    print(f\"\\nTFs available (hg38): {len(df_tfs)}\")\n    if \"peak_count\" in df_tfs.columns:\n        top = df_tfs.nlargest(10, \"peak_count\")[[\"name\", \"peak_count\", \"dataset_count\"]]\n        print(\"Top 10 TFs by peak count:\")\n        print(top.to_string(index=False))\nexcept Exception as e:\n    print(f\"TF list endpoint unavailable: {e}\")\n    print(\"Use TF name queries directly (Query 4) or download TF-specific BED files.\")\n```\n\n### Query 4: TF-Specific Peak Query\n\nRetrieve all peaks for a named TF in a given assembly, optionally filtered by cell type.\n\n```python\nimport requests, time, pandas as pd\n\nREMAP_API = \"https:\u002F\u002Fremap2022.univ-amu.fr\u002Fapi\u002Fv1\"\n\ndef query_tf_peaks(tf_name, assembly=\"hg38\", timeout=30):\n    \"\"\"Return all ChIP-seq peaks for a TF across all cell types.\"\"\"\n    r = requests.get(f\"{REMAP_API}\u002Ftfbs\u002Fname\u002F\", params={\n        \"name\": tf_name, \"assembly\": assembly\n    }, timeout=timeout)\n    r.raise_for_status()\n    return r.json()\n\npeaks = query_tf_peaks(\"CTCF\", assembly=\"hg38\")\nprint(f\"CTCF peaks (all cell types): {len(peaks)}\")\n\n# Parse and summarize\nrows = []\nfor p in peaks:\n    parts = p.get(\"name\", \"::\").split(\":\")\n    rows.append({\n        \"tf_name\": parts[0] if parts else \"\",\n        \"cell_type\": parts[2] if len(parts) > 2 else \"\",\n        \"chr\":   p.get(\"chr\",   p.get(\"chrom\", \"\")),\n        \"start\": p.get(\"start\", 0),\n        \"end\":   p.get(\"end\",   0),\n        \"score\": p.get(\"score\", 0),\n        \"biotype\": p.get(\"biotype\", \"\"),\n    })\n\ndf = pd.DataFrame(rows)\nprint(f\"Cell types: {df['cell_type'].nunique()}\")\nprint(f\"Chromosomes: {df['chr'].nunique()}\")\nprint(f\"Peak width stats (bp):\")\ndf[\"width\"] = df[\"end\"] - df[\"start\"]\nprint(f\"  Median: {df['width'].median():.0f}  Mean: {df['width'].mean():.0f}  \"\n      f\"Min: {df['width'].min()}  Max: {df['width'].max()}\")\n```\n\n### Query 5: Biotype Filter and Regulatory Annotation\n\nFilter peaks by regulatory biotype annotation to identify binding at promoters, enhancers, or intergenic regions.\n\n```python\nimport requests, pandas as pd, matplotlib.pyplot as plt\n\nREMAP_API = \"https:\u002F\u002Fremap2022.univ-amu.fr\u002Fapi\u002Fv1\"\n\ndef get_biotypes(assembly=\"hg38\", timeout=30):\n    \"\"\"List all regulatory biotype categories available.\"\"\"\n    r = requests.get(f\"{REMAP_API}\u002Fbiotypes\u002F\", params={\"assembly\": assembly}, timeout=timeout)\n    r.raise_for_status()\n    return r.json()\n\ndef query_tf_by_biotype(tf_name, biotype, assembly=\"hg38\", timeout=30):\n    \"\"\"Retrieve TF peaks filtered by regulatory biotype.\"\"\"\n    r = requests.get(f\"{REMAP_API}\u002Fpeaks\u002Fbiotype\u002F\", params={\n        \"name\": tf_name, \"biotype\": biotype, \"assembly\": assembly\n    }, timeout=timeout)\n    r.raise_for_status()\n    return r.json()\n\n# List available biotypes\ntry:\n    biotypes = get_biotypes(\"hg38\")\n    print(f\"Available biotypes: {biotypes}\")\nexcept Exception:\n    biotypes = [\"promoter\", \"enhancer\", \"exon\", \"intron\", \"intergenic\", \"UTR\"]\n    print(f\"Using known biotypes: {biotypes}\")\n\n# Query CTCF peaks and plot biotype distribution\npeaks = query_tf_peaks(\"CTCF\", assembly=\"hg38\")  # from Query 4 function above\n\ndef query_tf_peaks(tf_name, assembly=\"hg38\", timeout=30):\n    r = requests.get(f\"https:\u002F\u002Fremap2022.univ-amu.fr\u002Fapi\u002Fv1\u002Ftfbs\u002Fname\u002F\",\n                     params={\"name\": tf_name, \"assembly\": assembly}, timeout=timeout)\n    r.raise_for_status()\n    return r.json()\n\npeaks = query_tf_peaks(\"CTCF\")\nrows = [{\"biotype\": p.get(\"biotype\", \"unknown\"),\n         \"cell_type\": p.get(\"name\", \"::\").split(\":\")[2] if len(p.get(\"name\",\"\").split(\":\")) > 2 else \"\"}\n        for p in peaks]\ndf = pd.DataFrame(rows)\n\nbiotype_counts = df[\"biotype\"].value_counts()\nbiotype_counts = biotype_counts[biotype_counts > 0]\nprint(f\"\\nCTCF peak biotype distribution:\")\nprint(biotype_counts.to_string())\n\n# Stacked bar chart across top 5 cell types\ntop_cells = df[\"cell_type\"].value_counts().head(5).index.tolist()\npivot = (df[df[\"cell_type\"].isin(top_cells)]\n         .groupby([\"cell_type\", \"biotype\"])\n         .size()\n         .unstack(fill_value=0))\n\nfig, ax = plt.subplots(figsize=(9, 5))\npivot.plot(kind=\"bar\", stacked=True, ax=ax, colormap=\"tab10\", edgecolor=\"white\")\nax.set_xlabel(\"Cell Type\")\nax.set_ylabel(\"Peak Count\")\nax.set_title(\"CTCF ChIP-seq Peak Biotype Distribution by Cell Type (ReMap 2022, hg38)\")\nax.legend(title=\"Biotype\", bbox_to_anchor=(1.01, 1), loc=\"upper left\", fontsize=8)\nplt.tight_layout()\nplt.savefig(\"CTCF_biotype_distribution.png\", dpi=150, bbox_inches=\"tight\")\nprint(\"Saved CTCF_biotype_distribution.png\")\n```\n\n## Key Concepts\n\n### Peak Name Field Format\n\nThe `name` field in every ReMap peak record encodes three pieces of information as a colon-separated string:\n\n```\nTF_NAME:EXPERIMENT_ID:CELL_TYPE\n```\n\nFor example: `CTCF:GSE30263.SRX028592:GM12878`\n\nAlways parse with `.split(\":\")` and guard against missing parts. Some records may have fewer than three components if metadata is incomplete.\n\n### Assemblies\n\n| Assembly code | Organism | Notes |\n|---------------|----------|-------|\n| `hg38` | Homo sapiens (GRCh38) | Primary human assembly in ReMap 2022 |\n| `hg19` | Homo sapiens (GRCh37) | Legacy human assembly; fewer datasets |\n| `mm10` | Mus musculus | Primary mouse assembly |\n| `dm6` | Drosophila melanogaster | Smaller dataset collection |\n| `tair10` | Arabidopsis thaliana | Plant TF dataset |\n\n### BED File Download (API Fallback)\n\nWhen the REST API is unavailable or for offline bulk analysis, ReMap provides pre-built BED files at `https:\u002F\u002Fremap2022.univ-amu.fr\u002Fdownload_page`. Key files:\n\n- `remap2022_all_macs2_hg38_v1_0.bed.gz` — all peaks, hg38 (large, ~5 GB)\n- `remap2022_{TF}_macs2_hg38_v1_0.bed.gz` — per-TF peak files\n- `remap2022_crm_macs2_hg38_v1_0.bed.gz` — cis-regulatory modules (merged peaks)\n\n```python\nimport pandas as pd\n\ndef load_remap_bed(bed_path, chrom=None, start=None, end=None):\n    \"\"\"\n    Load a ReMap BED file with optional region filter.\n    Columns: chr, start, end, name (TF:exp:cell), score, strand,\n             thick_start, thick_end, itemRgb\n    \"\"\"\n    cols = [\"chr\", \"start\", \"end\", \"name\", \"score\", \"strand\",\n            \"thick_start\", \"thick_end\", \"itemRgb\"]\n    df = pd.read_csv(bed_path, sep=\"\\t\", header=None, names=cols,\n                     compression=\"infer\", low_memory=False)\n    if chrom:\n        df = df[df[\"chr\"] == chrom]\n    if start is not None and end is not None:\n        df = df[(df[\"end\"] > start) & (df[\"start\"] \u003C end)]\n    # Parse name field\n    parts = df[\"name\"].str.split(\":\", expand=True)\n    df[\"tf_name\"]       = parts[0]\n    df[\"experiment_id\"] = parts[1] if 1 in parts.columns else \"\"\n    df[\"cell_type\"]     = parts[2] if 2 in parts.columns else \"\"\n    return df.reset_index(drop=True)\n\n# Usage example (offline):\n# df = load_remap_bed(\"remap2022_CTCF_macs2_hg38_v1_0.bed.gz\",\n#                     chrom=\"chr17\", start=7_670_000, end=7_690_000)\n# print(df.head())\n```\n\n## Common Workflows\n\n### Workflow 1: TF Co-occupancy Analysis at a Locus\n\n**Goal**: Identify all TFs with ChIP-seq evidence at a genomic locus and rank by peak count, then export a co-occupancy matrix.\n\n```python\nimport requests, time, pandas as pd, matplotlib.pyplot as plt\n\nREMAP_API = \"https:\u002F\u002Fremap2022.univ-amu.fr\u002Fapi\u002Fv1\"\n\ndef query_region(chrom, start, end, assembly=\"hg38\", timeout=30):\n    r = requests.get(f\"{REMAP_API}\u002Fpeaks\u002Foverlap\u002F\", params={\n        \"chr\": chrom, \"start\": start, \"end\": end, \"assembly\": assembly\n    }, timeout=timeout)\n    r.raise_for_status()\n    return r.json()\n\ndef parse_peaks(peaks):\n    rows = []\n    for p in peaks:\n        parts = p.get(\"name\", \"::\").split(\":\")\n        rows.append({\n            \"tf_name\":  parts[0] if len(parts) > 0 else \"unknown\",\n            \"cell_type\": parts[2] if len(parts) > 2 else \"unknown\",\n            \"chr\":   p.get(\"chr\",   p.get(\"chrom\", \"\")),\n            \"start\": p.get(\"start\", 0),\n            \"end\":   p.get(\"end\",   0),\n            \"score\": p.get(\"score\", 0),\n        })\n    return pd.DataFrame(rows)\n\n# BRCA1 promoter region (GRCh38)\npeaks = query_region(\"chr17\", 43_044_000, 43_050_000, assembly=\"hg38\")\ndf = parse_peaks(peaks)\nprint(f\"Peaks at BRCA1 promoter: {len(df)}\")\n\n# TF occupancy summary\ntf_summary = (df.groupby(\"tf_name\")\n                .agg(peak_count=(\"tf_name\", \"count\"),\n                     cell_types=(\"cell_type\", \"nunique\"),\n                     mean_score=(\"score\", \"mean\"))\n                .sort_values(\"peak_count\", ascending=False))\nprint(f\"\\nTop TFs at BRCA1 promoter:\")\nprint(tf_summary.head(15).to_string())\ntf_summary.to_csv(\"BRCA1_promoter_TF_occupancy.csv\")\n\n# Horizontal bar chart\ntop = tf_summary.head(20)\nfig, ax = plt.subplots(figsize=(8, 6))\nax.barh(top.index[::-1], top[\"peak_count\"][::-1], color=\"#1f77b4\", edgecolor=\"white\")\nax.set_xlabel(\"Number of ChIP-seq Peaks\")\nax.set_title(\"TF Co-occupancy at BRCA1 Promoter (ReMap 2022, hg38)\")\nplt.tight_layout()\nplt.savefig(\"BRCA1_promoter_TF_cooccupancy.png\", dpi=150, bbox_inches=\"tight\")\nprint(\"Saved BRCA1_promoter_TF_cooccupancy.png\")\n```\n\n### Workflow 2: Gene Regulatory Profile — TSS-Proximal TF Binding Atlas\n\n**Goal**: For a list of genes, retrieve their promoter-proximal TF binding profiles and compare the TF repertoires across genes.\n\n```python\nimport requests, time, pandas as pd\n\nREMAP_API = \"https:\u002F\u002Fremap2022.univ-amu.fr\u002Fapi\u002Fv1\"\n\ndef query_gene_peaks(gene_name, assembly=\"hg38\", timeout=30):\n    try:\n        r = requests.get(f\"{REMAP_API}\u002Fpeaks\u002Fgene\u002F\", params={\n            \"gene\": gene_name, \"assembly\": assembly\n        }, timeout=timeout)\n        r.raise_for_status()\n        return r.json()\n    except Exception as e:\n        print(f\"  Warning: {gene_name} failed — {e}\")\n        return []\n\ngenes_of_interest = [\"MYC\", \"TP53\", \"BRCA1\", \"EGFR\", \"CDK4\"]\ngene_tf_profiles = {}\n\nfor gene in genes_of_interest:\n    peaks = query_gene_peaks(gene, assembly=\"hg38\")\n    if peaks:\n        tfs = set()\n        for p in peaks:\n            parts = p.get(\"name\", \"\").split(\":\")\n            if parts:\n                tfs.add(parts[0])\n        gene_tf_profiles[gene] = tfs\n        print(f\"{gene}: {len(peaks)} peaks, {len(tfs)} unique TFs\")\n    time.sleep(0.5)\n\n# Build binary TF presence matrix\nall_tfs = sorted(set().union(*gene_tf_profiles.values()))\nmatrix = pd.DataFrame(\n    {gene: [1 if tf in gene_tf_profiles.get(gene, set()) else 0 for tf in all_tfs]\n     for gene in genes_of_interest},\n    index=all_tfs\n)\nprint(f\"\\nTF × Gene matrix: {matrix.shape}\")\nprint(f\"TFs shared by all genes: {(matrix.sum(axis=1) == len(genes_of_interest)).sum()}\")\nmatrix.to_csv(\"gene_TF_binding_atlas.csv\")\nprint(\"Saved gene_TF_binding_atlas.csv\")\n```\n\n### Workflow 3: Download and Analyze TF Peak BED File\n\n**Goal**: Download a TF-specific ReMap BED file and analyze its genomic distribution with pandas.\n\n```python\nimport requests, gzip, io, pandas as pd, time\n\n# ReMap provides per-TF BED files. For large-scale offline analysis:\nREMAP_DOWNLOAD_BASE = \"https:\u002F\u002Fremap2022.univ-amu.fr\u002Fstorage\u002Fremap2022\u002Fhg38\u002FMACS2\"\n\ndef download_tf_bed(tf_name, assembly=\"hg38\", save_path=None):\n    \"\"\"\n    Attempt to download TF-specific BED file from ReMap.\n    Falls back to API region query if download unavailable.\n    \"\"\"\n    filename = f\"remap2022_{tf_name}_macs2_{assembly}_v1_0.bed.gz\"\n    url = f\"{REMAP_DOWNLOAD_BASE}\u002F{filename}\"\n    print(f\"Attempting download: {url}\")\n    r = requests.get(url, stream=True, timeout=60)\n    if r.status_code == 200:\n        if save_path:\n            with open(save_path, \"wb\") as f:\n                for chunk in r.iter_content(chunk_size=8192):\n                    f.write(chunk)\n            print(f\"Saved: {save_path}\")\n            return save_path\n        else:\n            # Read directly into DataFrame\n            content = b\"\".join(r.iter_content(chunk_size=8192))\n            cols = [\"chr\", \"start\", \"end\", \"name\", \"score\", \"strand\",\n                    \"thick_start\", \"thick_end\", \"itemRgb\"]\n            with gzip.open(io.BytesIO(content), \"rt\") as gz:\n                df = pd.read_csv(gz, sep=\"\\t\", header=None, names=cols)\n            return df\n    else:\n        print(f\"Download returned {r.status_code}; use API query as fallback\")\n        return None\n\n# Analyze a downloaded BED file\ndef analyze_remap_bed(df):\n    \"\"\"Compute summary statistics for a ReMap peak DataFrame.\"\"\"\n    parts = df[\"name\"].str.split(\":\", expand=True)\n    df = df.copy()\n    df[\"tf_name\"]   = parts[0]\n    df[\"cell_type\"] = parts[2] if 2 in parts.columns else \"unknown\"\n    df[\"width\"] = df[\"end\"] - df[\"start\"]\n\n    print(f\"Total peaks: {len(df):,}\")\n    print(f\"Unique TFs: {df['tf_name'].nunique()}\")\n    print(f\"Unique cell types: {df['cell_type'].nunique()}\")\n    print(f\"\\nPeak width (bp): median={df['width'].median():.0f}  \"\n          f\"mean={df['width'].mean():.0f}  range=[{df['width'].min()}, {df['width'].max()}]\")\n    print(f\"\\nChromosome distribution:\")\n    chr_counts = df[\"chr\"].value_counts().head(5)\n    print(chr_counts.to_string())\n    return df\n\n# Example usage (requires BED download or substitute with API results):\n# df_raw = download_tf_bed(\"CTCF\", save_path=\"CTCF_hg38.bed.gz\")\n# if df_raw is not None:\n#     df_analyzed = analyze_remap_bed(df_raw)\n```\n\n## Key Parameters\n\n| Parameter | Endpoint | Default | Range \u002F Options | Effect |\n|-----------|----------|---------|-----------------|--------|\n| `chr` | `\u002Fpeaks\u002Foverlap\u002F` | — | `chr1`–`chrX`, `chrY`, `chrM` | Chromosome for region query (include `chr` prefix) |\n| `start` | `\u002Fpeaks\u002Foverlap\u002F` | — | Integer genomic coordinate | Region start (0-based) |\n| `end` | `\u002Fpeaks\u002Foverlap\u002F` | — | Integer genomic coordinate | Region end (exclusive) |\n| `assembly` | All endpoints | — | `hg38`, `hg19`, `mm10`, `dm6`, `tair10` | Genome assembly for coordinates and peak lookup |\n| `gene` | `\u002Fpeaks\u002Fgene\u002F` | — | HGNC gene symbol (e.g., `TP53`, `MYC`) | Queries peaks near the gene's annotated TSS |\n| `name` | `\u002Ftfbs\u002Fname\u002F` | — | TF name as in ReMap (e.g., `CTCF`, `SP1`) | TF name is case-sensitive; match ReMap TF naming |\n| `biotype` | `\u002Fpeaks\u002Fbiotype\u002F` | — | `promoter`, `enhancer`, `exon`, `intron`, `intergenic`, `UTR` | Filters peaks by Ensembl regulatory biotype |\n| `timeout` | All requests | 30 | Integer seconds | Increase to 60–120 for large gene\u002FTF queries |\n\n## Best Practices\n\n1. **Parse the `name` field defensively**: The `TF:experiment:cell_type` format may have fewer than three components for some records. Always guard with `parts[n] if len(parts) > n else \"\"`.\n\n2. **Use BED downloads for genome-wide analyses**: Querying large genomic regions or all peaks for a TF via the REST API can time out. For whole-genome or per-chromosome scans, download the per-TF or per-assembly BED files from the ReMap download page and filter locally with pandas or bedtools.\n\n3. **Cross-reference with JASPAR for sequence evidence**: ReMap peaks show where TF binding was detected by ChIP-seq (positional evidence); JASPAR PWMs show what sequence the TF prefers (motif evidence). For robust regulatory annotation, require both: a ReMap peak in the region AND a JASPAR motif hit within the peak.\n\n4. **Use `time.sleep(0.5)` in batch loops**: The ReMap API serves a research community; polite request pacing prevents throttling.\n\n5. **Validate assembly coordinates**: ReMap 2022 hg38 peaks use 0-based half-open BED coordinates (`[start, end)`). When comparing with VCF or 1-based GFF coordinates, add 1 to `start`.\n\n## Common Recipes\n\n### Recipe: Find TFs Binding at a GWAS SNP\n\nWhen to use: Prioritize functional candidates from a GWAS hit by identifying which TFs bind at the SNP location.\n\n```python\nimport requests\n\nREMAP_API = \"https:\u002F\u002Fremap2022.univ-amu.fr\u002Fapi\u002Fv1\"\n\ndef tfs_at_snp(chrom, pos, window=500, assembly=\"hg38\"):\n    \"\"\"Find TFs with ChIP-seq peaks overlapping a SNP position ± window bp.\"\"\"\n    r = requests.get(f\"{REMAP_API}\u002Fpeaks\u002Foverlap\u002F\", params={\n        \"chr\": chrom, \"start\": pos - window, \"end\": pos + window,\n        \"assembly\": assembly\n    }, timeout=30)\n    r.raise_for_status()\n    peaks = r.json()\n    tfs = {}\n    for p in peaks:\n        parts = p.get(\"name\", \"::\").split(\":\")\n        tf = parts[0] if parts else \"unknown\"\n        tfs[tf] = tfs.get(tf, 0) + 1\n    return dict(sorted(tfs.items(), key=lambda x: -x[1]))\n\n# Example: rs2736100 (TERT locus, chr5:1,286,401)\nsnp_tfs = tfs_at_snp(\"chr5\", 1_286_401, window=500, assembly=\"hg38\")\nprint(f\"TFs at TERT GWAS SNP (±500 bp): {len(snp_tfs)}\")\nfor tf, count in list(snp_tfs.items())[:10]:\n    print(f\"  {tf:\u003C20s} {count:3d} peaks\")\n```\n\n### Recipe: Compare TF Binding Profiles of Two Genes\n\nWhen to use: Check whether two co-regulated genes share the same upstream TF binding landscape.\n\n```python\nimport requests, time\n\nREMAP_API = \"https:\u002F\u002Fremap2022.univ-amu.fr\u002Fapi\u002Fv1\"\n\ndef get_gene_tfs(gene, assembly=\"hg38\"):\n    try:\n        r = requests.get(f\"{REMAP_API}\u002Fpeaks\u002Fgene\u002F\", params={\"gene\": gene, \"assembly\": assembly}, timeout=30)\n        r.raise_for_status()\n        peaks = r.json()\n        return set(p.get(\"name\", \"\").split(\":\")[0] for p in peaks if p.get(\"name\", \"\"))\n    except Exception as e:\n        print(f\"Warning: {gene} → {e}\")\n        return set()\n\ngene_a, gene_b = \"MYC\", \"MYCN\"\ntfs_a = get_gene_tfs(gene_a)\ntime.sleep(0.5)\ntfs_b = get_gene_tfs(gene_b)\n\nshared = tfs_a & tfs_b\nonly_a = tfs_a - tfs_b\nonly_b = tfs_b - tfs_a\n\nprint(f\"{gene_a} TFs: {len(tfs_a)}  |  {gene_b} TFs: {len(tfs_b)}\")\nprint(f\"Shared: {len(shared)}  |  {gene_a}-only: {len(only_a)}  |  {gene_b}-only: {len(only_b)}\")\nprint(f\"\\nShared TFs (first 15): {sorted(shared)[:15]}\")\nprint(f\"\\n{gene_a}-only (first 10): {sorted(only_a)[:10]}\")\n```\n\n### Recipe: Export Region Peaks as BED\n\nWhen to use: Export ReMap query results to BED format for downstream bedtools intersection or IGV visualization.\n\n```python\nimport requests, pandas as pd\n\nREMAP_API = \"https:\u002F\u002Fremap2022.univ-amu.fr\u002Fapi\u002Fv1\"\n\ndef export_region_as_bed(chrom, start, end, outfile, assembly=\"hg38\"):\n    \"\"\"Query ReMap region and save as 6-column BED file.\"\"\"\n    r = requests.get(f\"{REMAP_API}\u002Fpeaks\u002Foverlap\u002F\", params={\n        \"chr\": chrom, \"start\": start, \"end\": end, \"assembly\": assembly\n    }, timeout=30)\n    r.raise_for_status()\n    peaks = r.json()\n    rows = [{\n        \"chr\":   p.get(\"chr\",   p.get(\"chrom\", \"\")),\n        \"start\": p.get(\"start\", 0),\n        \"end\":   p.get(\"end\",   0),\n        \"name\":  p.get(\"name\",  \".\"),\n        \"score\": p.get(\"score\", 0),\n        \"strand\": p.get(\"strand\", \".\"),\n    } for p in peaks]\n    df = pd.DataFrame(rows)\n    df = df.sort_values([\"chr\", \"start\"])\n    df.to_csv(outfile, sep=\"\\t\", header=False, index=False)\n    print(f\"Saved {len(df)} peaks to {outfile}\")\n    return df\n\nexport_region_as_bed(\"chr17\", 7_670_000, 7_690_000, \"TP53_locus_remap.bed\")\n```\n\n## Troubleshooting\n\n| Problem | Cause | Solution |\n|---------|-------|----------|\n| `404 Not Found` from API | Endpoint path changed or unavailable | Check `https:\u002F\u002Fremap2022.univ-amu.fr\u002Fapi\u002F` for current endpoint list; fall back to BED download |\n| Empty JSON list `[]` from region query | No peaks in region, or assembly mismatch | Verify coordinates are on the correct assembly; try a wider window (±10 kb) |\n| Gene query returns empty | Gene symbol not recognized by ReMap | Try Ensembl gene symbol; some aliases are not mapped — verify with HGNC |\n| `requests.exceptions.Timeout` | Large region or slow server | Increase `timeout=60`; for regions >1 Mb use BED file download instead |\n| `name` field has only one component | Incomplete metadata in ReMap for that experiment | Guard with `parts[n] if len(parts) > n else \"unknown\"` |\n| BED download 404 | Per-TF files use exact ReMap TF naming | Check TF name case and spelling at `https:\u002F\u002Fremap2022.univ-amu.fr\u002Fdownload_page` |\n| Duplicate peaks for same TF | Multiple experiments per TF in a cell type | Group by `tf_name` and count unique experiments; deduplicate peaks with bedtools merge |\n\n## Related Skills\n\n- `jaspar-database` — TF binding motif matrices (PWMs\u002FPFMs); use alongside ReMap peak evidence for sequence-level validation\n- `encode-database` — ENCODE regulatory tracks including TF ChIP-seq, DNase-seq, and ATAC-seq; partially overlaps with ReMap\n- `homer-motif-analysis` — de novo motif discovery in ChIP-seq peak sets from ReMap or MACS3\n- `macs3-peak-calling` — call peaks from raw ChIP-seq BAM files; ReMap provides pre-called peaks from the same approach\n- `regulomedb-database` — regulatory variant scoring that integrates TF binding evidence similar to ReMap\n\n## References\n\n- [ReMap 2022 API documentation](https:\u002F\u002Fremap2022.univ-amu.fr\u002Fapi\u002F) — REST API endpoint reference and interactive explorer\n- [Hammal et al., Nucleic Acids Research 2022](https:\u002F\u002Fdoi.org\u002F10.1093\u002Fnar\u002Fgkab996) — ReMap 2022 paper describing the 2022 release (165M peaks, 1,210 TFs)\n- [ReMap portal and download page](https:\u002F\u002Fremap2022.univ-amu.fr\u002F) — web browser, download page for BED files and cis-regulatory modules\n- [Chèneby et al., Nucleic Acids Research 2020](https:\u002F\u002Fdoi.org\u002F10.1093\u002Fnar\u002Fgkz945) — ReMap 2020 paper describing the reprocessing pipeline and quality control methodology\n",{"name":5,"license":15,"description":7},"master","63f17866001c5ca854bf2fa0b678ce277133de5b","skills\u002Fawesome-skills\u002Fremap-database",0,"https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS","https:\u002F\u002Fbg-szy.github.io\u002FTOP-SKILLS\u002F","https:\u002F\u002Fgithub.com\u002Fbg-szy","https:\u002F\u002Fwww.ecust.edu.cn\u002F","a student of East China University of Science and Technology","2026-11-15 03:38:02",{"source":8,"skillName":5,"commands":35,"prompt":45,"zipAvailable":46},[36,39,42],{"tool":37,"command":38},"npx","npx skills add bg-szy\u002FTOP-SKILLS --skill remap-database",{"tool":40,"command":41},"bunx","bunx skills add bg-szy\u002FTOP-SKILLS --skill remap-database",{"tool":43,"command":44},"pnpm","pnpm dlx skills add bg-szy\u002FTOP-SKILLS --skill remap-database","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fawesome-skills\u002Fremap-database\u002FSKILL.md",true,[],[49,58,65,72,79,86],{"skillNo":50,"name":51,"nameZh":6,"description":52,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":53,"licenseFileUrl":6,"sourceHtmlUrl":54,"categories":55,"keywords":56,"publishedAt":57},"01M7DXW9N826PKXK174PVW3038","serpmaven","Scrape Google search results (SERP) to JSON with SERP Maven (serpmaven) - a real Chrome browser on a residential proxy with sticky sessions. Run it as a CLI, a Python library, a local HTTP search API (`serve`), an MCP server or a Docker image; set the proxy login, workers, pages and cost tracking. Use when the user wants Google results, rank tracking, a self-hosted SERP API, or live Google search for an AI agent.","MIT","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Fserpmaven\u002FSKILL.md",[],[],"2026-11-15 14:19:17",{"skillNo":59,"name":60,"nameZh":6,"description":61,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":53,"licenseFileUrl":6,"sourceHtmlUrl":62,"categories":63,"keywords":64,"publishedAt":57},"01M7DXVHSTWDV65475QEQ915M7","revnu-landing-page-audit","Find out why a landing page isn't turning visitors into signups, demos or sales. Audits one page against what the ad, post or search that sends people there promised, then checks the first screen, proof, call to action, friction and mobile. Returns at most 7 prioritized fixes, plus what is fine and what could not be checked; rewrites specific lines and fixes the page in the repo when asked. Never promises a conversion lift. Works without a Revnu account. Use when the user says or asks: \"audit my landing page\", \"why isn't this page converting\", \"review my homepage\", \"my ads get clicks but no signups\", \"people bounce from the pricing page\", \"CRO review\", \"improve conversion rate\", \"is my hero section clear\", \"roast my landing page\", \"rewrite my headline\", \"what's wrong with this page\", \"landing page feedback\", \"make the signup page convert better\". Not for SEO or AI-search audits, page speed engineering on its own, or building a new page from scratch.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Frevnu-landing-page-audit\u002FSKILL.md",[],[],{"skillNo":66,"name":67,"nameZh":6,"description":68,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":53,"licenseFileUrl":6,"sourceHtmlUrl":69,"categories":70,"keywords":71,"publishedAt":57},"01M7DXV8X2D7B3VTD4HHYYHTGR","revnu-growth-context","Write down once who buys, what they're stuck on, what it costs, what proof you have and what you've already tried, so every growth task starts from facts instead of a questionnaire. Creates or updates .agents\u002Frevnu-growth.md from the repo, the live site and the user, and imports an existing product-marketing.md. Use when the user says \"set up our marketing context\", \"who is our ideal customer\", \"write our ICP\", \"describe the product for marketing\", \"positioning doc\", \"what's our brand voice\", \"remember this about our customers\", \"log what we tried\", \"what have we learned from marketing\", \"we changed pricing, update the context\", \"update our growth notes\", \"summarize the business for the agent\", \"import my product-marketing.md\", \"start a growth doc\", or before a first marketing, SEO, outreach or launch task when no context file exists. Works without a Revnu account.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Frevnu-growth-context\u002FSKILL.md",[],[],{"skillNo":73,"name":74,"nameZh":6,"description":75,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":53,"licenseFileUrl":6,"sourceHtmlUrl":76,"categories":77,"keywords":78,"publishedAt":57},"01M7DXV0DGJ1G0A60PAHC6J3C5","revnu-get-listed","Get onto the third-party pages AI answers and search cite when buyers ask for the best tool in your category: \"best X\" roundups, directories, review sites, GitHub awesome lists, community threads and comparison pages. Finds which ones are cited, ranks them by fit and effort, and drafts each submission, PR or pitch by the target's own rules. Use when the user says \"get us listed\", \"which directories should we submit to\", \"how do we get into best-of lists\", \"why does ChatGPT recommend competitors and not us\", \"get mentioned in AI answers\", \"submit to awesome lists\", \"get on G2\", \"where are our competitors listed\", \"pitch listicle authors\", \"find backlink opportunities\", \"launch directories\", \"get into roundups\", \"Product Hunt alternatives\", \"where should we be listed\", \"get cited by Perplexity\". Never submits, pays or posts without a yes. Works without a Revnu account.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Frevnu-get-listed\u002FSKILL.md",[],[],{"skillNo":80,"name":81,"nameZh":6,"description":82,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":53,"licenseFileUrl":6,"sourceHtmlUrl":83,"categories":84,"keywords":85,"publishedAt":57},"01M7DXTSPMGT9D6DSS0HP9BSTA","revnu-ai-readiness-audit","Audit whether your website gives ChatGPT, Perplexity, Claude, Gemini and Google's AI Overviews something worth quoting, and fix the pages that don't. Use when the user says or asks \"is my site ready for AI search\", \"audit my site for AI answers\", \"AEO audit\", \"GEO audit\", \"why doesn't ChatGPT quote our pricing\", \"make our pages citable by AI\", \"do I need llms.txt\", \"does schema help with ChatGPT\", \"check our structured data\", \"is our content visible without JavaScript\", \"AI SEO audit\", \"optimize our homepage for AI answers\", \"LLM SEO check\", \"why does AI get our product wrong\", \"fix our site for AI Overviews\". Checks fetchability and indexability, answers in the raw HTML, entity facts, schema (including JS-injected markup), headings, dates and llms.txt, then gives at most 10 prioritised fixes and edits the repo when asked. Works without a Revnu account.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Frevnu-ai-readiness-audit\u002FSKILL.md",[],[],{"skillNo":87,"name":88,"nameZh":6,"description":89,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":53,"licenseFileUrl":6,"sourceHtmlUrl":90,"categories":91,"keywords":92,"publishedAt":57},"01M7DXSZHCVTRS620GC3S97JZV","proxy-troubleshooting","Diagnose residential proxy failures, with NodeMaven's gateway as the reference - 407 with correct credentials, 406, 410, 500, a connection that hangs, ERR_TUNNEL_CONNECTION_FAILED in a browser, Playwright or Puppeteer ignoring proxy credentials, a sticky session that changes IP, geo-targeting that is silently ignored, passwords with special characters, and unexpected traffic from headless Chrome. Use when a proxy connection fails, returns the wrong location, or costs more traffic than expected.","https:\u002F\u002Fgithub.com\u002Fbg-szy\u002FTOP-SKILLS\u002Fblob\u002Fmaster\u002Fskills\u002Fmarketplace\u002Fproxy-troubleshooting\u002FSKILL.md",[],[]]