find_differentially_methylated_regions
Identify differentially methylated regions (hyper/hypo) from GeneLab assays. Pool replicates, filter by genomic location, and export complete CSV results.
Instructions
USE THIS TOOL (not the query tool) for any "hyper/hypo-methylated
regions", "DMRs", or "differential methylation" question — including
all-rows requests, promoter/exon/intron-filtered methylation queries,
and pooling methylation across replicate assays. Falling back to query
for this category reproduces the work this tool already does (proper
IS-NOT-NULL guards, gene-symbol join, parallel count queries, location
filtering, deterministic CSV emission) and loses the formatted markdown
inline CSV side-channel.
Return hyper- and hypo-methylated regions for one or more assays.
This tool runs two queries on the GeneLab KG:
Hypermethylated regions (methylation_diff > methylation_diff_threshold, q_value <= q_value_threshold, highest first)
Hypomethylated regions (methylation_diff < -methylation_diff_threshold, q_value <= q_value_threshold, lowest first)
Pooling across assays:
Pass a list to assay_id to pool results across multiple methylation
assays (the Cypher uses a.identifier IN $assay_ids). Common use case:
a study has 2+ methylation assays representing replicate runs of the
same comparison, and the user wants the combined evidence rather than
per-assay tables. The output adds an assay_id column so each row's
source is visible.
Returning all passing rows:
Pass top_n=None to return ALL rows that pass the filters rather
than a top-N ranking. Use this when the user asks for "all
hypermethylated promoter regions" or wants the complete filtered
set as CSV. To keep the response readable when the full set is
large, the inline markdown table is capped at the first 100 rows
and a note is shown; the CSV contains every row.
MethylationRegion location filters (in_promoter, in_exon, in_intron, dist_to_feature_max) are applied DURING the Cypher query. This means when a user asks for "top hypermethylated regions in the promoter", pass in_promoter=True and the tool will correctly rank within the promoter universe. Do NOT post-filter the unfiltered top-N — that produces wrong results because regions outside the filter (e.g. non-promoter regions) occupy slots in the unfiltered top-N and displace correctly-ranked filtered regions. Multiple filters combine with AND, so in_promoter=True with in_intron=False returns promoter regions that are not intronic.
WHEN TO USE THIS TOOL vs. direct Cypher via the query tool:
Use THIS tool for any "hyper/hypo methylated regions" question,
including pooled-across-assays, all-passing-rows, and filter-by-location
variants. It produces formatted markdown tables AND an inline CSV
that the user can save directly. Falling back to direct Cypher loses
the formatted output and the CSV.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| top_n | No | How many regions to display for each of hyper- and hypo-methylated lists. Pass None (or omit) to return ALL rows passing the filters rather than a top-N — useful when the user asks for 'all hypermethylated promoter regions' or wants to download the complete filtered set as CSV. When the full set is large (>100 rows), the inline markdown table is capped at the first 100 rows for readability while the CSV contains every row. | |
| in_exon | No | MethylationRegion location filter. When True, return only regions overlapping an exon (mr.in_exon = true). When False, exclude exon-overlapping regions. None (default) imposes no exon filter. Combines with other filters via AND. | |
| assay_id | Yes | Assay identifier, or a list of assay identifiers to pool. Pass a single string (e.g. 'OSD-48-968c...') to query one assay. Pass a list (e.g. ['OSD-48-968c...', 'OSD-48-4dc1...']) to pool results across multiple methylation assays — useful when a study has independent replicate methylation assays with identical factor spaces and you want the combined evidence. The output table will have an additional 'assay_id' column so each row's source is identifiable, and the same region significantly methylated in two pooled assays will appear as two rows. | |
| in_intron | No | MethylationRegion location filter. When True, return only regions overlapping an intron (mr.in_intron = true). When False, exclude intron-overlapping regions. None (default) imposes no intron filter. Combines with other filters via AND. | |
| session_id | No | Session id returned by `create_session()`. This server serves many users from one process; the session id is what keeps your output directory and generated plots private to you. Pass the SAME value on every tool call. If the server replies that the session is unknown or expired, call `create_session()` again and use the new id. | |
| in_promoter | No | MethylationRegion location filter. When True, return only regions overlapping a gene promoter (mr.in_promoter = true). When False, exclude promoter-overlapping regions (mr.in_promoter = false). None (default) imposes no promoter filter. The filter is applied during the Cypher query, so 'top_n' and the 'showing N of TOTAL' count both reflect the filtered set — promoter-only top-N rankings are computed from the promoter-only universe, NOT post-filtered from the global top-N. | |
| q_value_threshold | No | q-value threshold for significance (default: 0.05). Only regions with q_value <= this value are returned. | |
| dist_to_feature_max | No | MethylationRegion distance filter. When set, return only regions whose dist_to_feature (bp to the nearest annotated gene feature) is <= this value. None (default) imposes no distance filter. Useful for narrowing to regions tightly associated with gene bodies. | |
| methylation_diff_threshold | No | Minimum |methylation_diff| magnitude (in percentage points) required for a row to be kept (default: 0.0 = any change). Hypermethylated rows must have methylation_diff > methylation_diff_threshold; hypomethylated rows must have methylation_diff < -methylation_diff_threshold. The GeneLab KG stores methylation_diff as a raw percentage, so a threshold of 10 means '10 percentage points or more', matching typical methylKit reporting conventions. |