Package {EWAScaller}


Title: Query and Analyse the 'EWAS Atlas' Database
Version: 0.2.0
Description: Provides a client for the 'EWAS Atlas' web services (https://ngdc.cncb.ac.cn/ewas/; Li et al. (2019) <doi:10.1093/nar/gky1027>), allowing users to query epigenome-wide association study (EWAS) data by CpG (cytosine-phosphate-guanine) probe identifier, gene symbol, or genomic region, and to run trait, Gene Ontology, KEGG (Kyoto Encyclopedia of Genes and Genomes) pathway, and genomic location enrichment analyses on a set of CpG probes. It also retrieves expression quantitative trait methylation (eQTM) associations, i.e. correlations between CpG methylation and gene expression in 'TCGA' (The Cancer Genome Atlas) tissue data. Query functions support concurrent, rate-limited requests to the remote service. Results are returned as tidy data frames with dedicated summary and customizable plotting methods, including word clouds of enriched 'EWAS Atlas' trait terms and eQTM heatmap, volcano, and scatter plots.
License: MIT + file LICENSE
URL: https://github.com/SAADAT-Abu/EWAScaller
BugReports: https://github.com/SAADAT-Abu/EWAScaller/issues
Depends: R (≥ 4.1.0)
Imports: httr, jsonlite, digest, parallel, ggplot2, ggwordcloud, stats, utils
Suggests: testthat (≥ 3.0.0), knitr, rmarkdown
Encoding: UTF-8
Config/testthat/edition: 3
VignetteBuilder: knitr
LazyData: true
Config/roxygen2/version: 8.1.1
NeedsCompilation: no
Packaged: 2026-11-24 10:32:54 UTC; saadat
Author: Saadat Abu [aut, cre]
Maintainer: Saadat Abu <saadatabu1996@gmail.com>
Repository: CRAN
Date/Publication: 2026-11-24 16:00:22 UTC

EWAScaller: Query and Analyse the EWAS Atlas Database

Description

Tools to query the EWAS Atlas (https://ngdc.cncb.ac.cn/ewas/) by CpG probe, gene symbol, or genomic region, and to run enrichment analyses on probe sets. Query functions dispatch requests concurrently across a small worker pool with configurable pacing to stay within reasonable request rates. Results are returned as tidy data frames with summary and plotting helpers, including trait-term word clouds.

Main functions

Author(s)

Maintainer: Saadat Abu saadatabu1996@gmail.com

Authors:

See Also

Useful links:


Plot an EWAS Atlas enrichment result

Description

Draws the top enriched terms of one analysis, either as a dot plot (mirroring the EWAS Atlas toolkit chart: position given by -log10(p), point size by the differentially-methylated CpG/gene count) or as a bar chart of -log10(p).

Usage

## S3 method for class 'ewas_enrichment'
autoplot(
  object,
  type = "trait",
  top_n = 20L,
  style = c("dot", "bar"),
  colors = NULL,
  title = NULL,
  subtitle = NULL,
  base_size = 11,
  theme = ggplot2::theme_minimal,
  wrap = 40,
  ...
)

Arguments

object

An ewas_enrichment object.

type

Which analysis result to plot (default "trait").

top_n

Number of top terms to display.

style

"dot" (default) or "bar".

colors

Colour of the points or bars (first element used).

title, subtitle

Plot title and subtitle. NULL (default) uses the built-in title; NA or "" removes it.

base_size

Base font size passed to theme.

theme

A ggplot2 theme function such as ggplot2::theme_bw() (called with base_size), or a complete theme object.

wrap

Wrap long category labels at this many characters; NULL to disable wrapping.

...

Unused.

Value

A ggplot object.


Plot an EWAS Atlas eQTM result

Description

Visualises CpG-gene expression correlations from ewas_eqtm():

"heatmap"

CpG probes against genes, coloured by correlation, one panel per tissue.

"volcano"

Correlation against -log10(p) for every pair, coloured by tissue, with the strongest pairs labelled.

"tissue"

Number of pairs per tissue, split into negative and positive correlations.

"scatter"

Per-sample methylation against expression for one pair (chosen with probe, gene, and tissue). This downloads the sample data with eqtm_samples(), so it needs internet access.

Usage

## S3 method for class 'ewas_eqtm'
autoplot(
  object,
  type = c("heatmap", "volcano", "tissue", "scatter"),
  tissue = NULL,
  top_n = 30L,
  label_top = 5L,
  probe = NULL,
  gene = NULL,
  colors = NULL,
  title = NULL,
  subtitle = NULL,
  base_size = 11,
  theme = ggplot2::theme_minimal,
  wrap = 40,
  ...
)

Arguments

object

An ewas_eqtm object.

type

One of "heatmap", "volcano", "tissue", "scatter".

tissue

Optional character vector of tissues to keep. Required for type = "scatter" when the pair was found in more than one tissue.

top_n

For "heatmap", the number of strongest pairs (by p-value) to show.

label_top

For "volcano", how many of the strongest pairs to label (0 for none).

probe, gene

For "scatter", the probe and gene of the pair to plot. gene may be a gene symbol or an Ensembl identifier.

colors

Colours to use. "heatmap": low, mid, and high colours of the correlation scale (default teal-white-orange). "volcano": one colour per tissue (optionally named by tissue). "tissue": a vector named negative and positive (or two unnamed colours in that order). "scatter": point colour, then trend-line colour.

title, subtitle

Plot title and subtitle. NULL (default) uses the built-in title; NA or "" removes it.

base_size

Base font size passed to theme.

theme

A ggplot2 theme function such as ggplot2::theme_bw() (called with base_size), or a complete theme object.

wrap

Wrap long category labels at this many characters; NULL to disable wrapping.

...

Unused.

Value

A ggplot object.

Examples


probes <- c(
  "cg05575921", "cg00240195", "cg16419584", "cg11903855", "cg21566642",
  "cg23771366", "cg19859270", "cg00382138", "cg25648203", "cg01940273",
  "cg23576855", "cg00401753", "cg00300637", "cg12803068", "cg09935388",
  "cg01899089", "cg04180046", "cg00050873", "cg02228185", "cg18147296"
)
eq <- ewas_eqtm(probes, background = "850K")
autoplot(eq, type = "heatmap")
autoplot(eq, type = "volcano", theme = ggplot2::theme_bw, base_size = 14)
autoplot(eq, type = "scatter", probe = "cg05575921", gene = "AHRR", tissue = "brain")


Plot summary statistics for an EWAS Atlas query result

Description

All EWAScaller plots return ordinary ggplot objects, so they can be extended further with +. The arguments below cover the common adjustments and are shared by every autoplot() method in the package.

Usage

## S3 method for class 'ewas_result'
autoplot(
  object,
  type = c("traits", "chromosome", "direction"),
  top_n = 15L,
  colors = NULL,
  title = NULL,
  subtitle = NULL,
  base_size = 11,
  theme = ggplot2::theme_minimal,
  wrap = 40,
  ...
)

Arguments

object

An ewas_result object.

type

One of "traits" (top trait frequency), "chromosome" (probes per chromosome), or "direction" (hyper-/hypomethylation balance).

top_n

Number of categories to show for type = "traits".

colors

Colours to use. For single-colour plots the first colour is used. For type = "direction", a vector named pos and neg (or two unnamed colours in that order).

title, subtitle

Plot title and subtitle. NULL (default) uses the built-in title; NA or "" removes it.

base_size

Base font size passed to theme.

theme

A ggplot2 theme function such as ggplot2::theme_bw() (called with base_size), or a complete theme object.

wrap

Wrap long category labels at this many characters; NULL to disable wrapping.

...

Unused.

Value

A ggplot object.


Per-sample methylation and expression values for one eQTM pair

Description

Downloads the matched DNA methylation (beta value) and gene expression (TPM) measurements behind one CpG-gene-tissue correlation reported by ewas_eqtm().

Usage

eqtm_samples(probe, gene, tissue)

Arguments

probe

CpG probe identifier, e.g. "cg05575921" (EPIC v2 names such as "cg05575921_BC21" are accepted).

gene

Ensembl gene identifier, e.g. "ENSG00000063438" (the gene_id column of an ewas_eqtm() result).

tissue

Tissue name as reported in the tissue column, e.g. "colon".

Value

A data frame with one row per sample and columns methylation and expression.

Examples


s <- eqtm_samples("cg05575921", "ENSG00000063438", "brain")
head(s)



Run EWAS Atlas enrichment analysis on a set of CpG probes

Description

Submits a probe set to the EWAS Atlas toolkit and retrieves one or more enrichment analyses run against it: EWAS trait-term enrichment, genomic location enrichment, Gene Ontology enrichment, KEGG pathway enrichment, tissue-specificity enrichment, and gene-expression correlation.

Usage

ewas_enrichment(
  probes,
  background = c("450K", "850K"),
  types = "trait",
  poll_interval = 5,
  timeout = 300,
  progress = interactive()
)

Arguments

probes

Character vector of probe identifiers (20-5000) from the 450K, EPIC (850K), or EPIC v2 array. EPIC v2 names such as "cg05575921_BC21" are converted to their 450K/EPIC v1 names, and replicate probes are merged.

background

The array the probes were selected from: "450K" (the default), "850K" (EPIC v1), "EPICv2", or a character vector of probe identifiers to use as a custom background set.

EWAS Atlas has no EPIC v2 background, so "EPICv2" uses the EPIC/850K background. Because the toolkit rejects a job containing any probe outside its background, probes that are not on both EPIC v1 and EPIC v2 (mainly the ~200,000 probes new on EPIC v2, which have no EWAS Atlas data) are dropped before submission, with a message; they are listed in the result's excluded element. Genomic location, GO, and KEGG p-values are approximate with "EPICv2" because the 850K background also contains EPIC v1 probes that are not on EPIC v2; trait enrichment does not depend on the background. Input probes that are missing from a custom background are dropped in the same way.

types

Character vector of analyses to run: any of "trait" (EWAS Atlas trait-term enrichment), "genomic_location" (enrichment across gene/CpG-island-relative locations), "gene_ontology" (GO term enrichment), or "kegg" (KEGG pathway enrichment). Defaults to "trait".

poll_interval

Seconds between job-status polls.

timeout

Maximum seconds to wait for each analysis to finish.

progress

Logical; print progress messages while polling.

Details

The EWAS Atlas toolkit requires between 20 and 5000 probes per submission and computes results asynchronously; this function submits the job and polls for completion.

Value

An ewas_enrichment object.

Examples


probes <- c(
  "cg05575921", "cg00240195", "cg16419584", "cg11903855", "cg21566642",
  "cg23771366", "cg19859270", "cg00382138", "cg25648203", "cg01940273",
  "cg23576855", "cg00401753", "cg00300637", "cg12803068", "cg09935388",
  "cg01899089", "cg04180046", "cg00050873", "cg02228185", "cg18147296"
)
enr <- ewas_enrichment(probes, background = "850K", types = "trait")
top_traits(enr)



EWAS Atlas enrichment result

Description

An ewas_enrichment bundles the analyses run by ewas_enrichment().

Usage

## S3 method for class 'ewas_enrichment'
summary(object, top_n = 10L, ...)

## S3 method for class 'ewas_enrichment'
as.data.frame(x, row.names = NULL, optional = FALSE, type = "trait", ...)

Arguments

object

An ewas_enrichment object.

top_n

Number of top rows to report per analysis type.

...

Unused.

x

An ewas_enrichment object.

row.names, optional

Unused; present for S3 consistency.

type

Which analysis result to extract (default "trait").

Value

An object of class ewas_enrichment: a named list with the results, job, probes, background, failed, and excluded elements described above. summary.ewas_enrichment() invisibly returns the object it was called on (after printing a summary), and as.data.frame.ewas_enrichment() returns the requested analysis's result data frame on its own.

Fields

results

Named list of data frames, one per requested analysis type (e.g. results$trait).

job

The EWAS Atlas toolkit job identifier.

probes

The probe identifiers submitted.

background

The background set used ("450K", "850K", "EPICv2 (approximated by 850K)", or "other").

failed

Named list of analysis types that could not be retrieved, with an explanatory message.

excluded

Input probes dropped because they are not in the background (see the background argument of ewas_enrichment()).


Find expression quantitative trait methylation (eQTM) pairs for CpG probes

Description

Runs the EWAS Atlas toolkit's "Expression Regulation" analysis, which reports CpG-gene pairs whose DNA methylation is correlated with gene expression (expression quantitative trait methylation, eQTM). The correlations were computed by EWAS Atlas from matched methylation and RNA-seq data from The Cancer Genome Atlas (TCGA) across several tissues.

Usage

ewas_eqtm(
  probes,
  background = c("450K", "850K"),
  poll_interval = 5,
  timeout = 300,
  progress = interactive()
)

Arguments

probes

Character vector of CpG probe identifiers (20-5000).

background

The array the probes were selected from: "450K" (the default), "850K" (EPIC v1), "EPICv2", or a character vector of probe identifiers to use as a custom background set.

EWAS Atlas has no EPIC v2 background, so "EPICv2" uses the EPIC/850K background. Because the toolkit rejects a job containing any probe outside its background, probes that are not on both EPIC v1 and EPIC v2 (mainly the ~200,000 probes new on EPIC v2, which have no EWAS Atlas data) are dropped before submission, with a message; they are listed in the result's excluded element. Genomic location, GO, and KEGG p-values are approximate with "EPICv2" because the 850K background also contains EPIC v1 probes that are not on EPIC v2; trait enrichment does not depend on the background. Input probes that are missing from a custom background are dropped in the same way.

poll_interval

Seconds between job-status polls.

timeout

Maximum seconds to wait for each analysis to finish.

progress

Logical; print progress messages while polling.

Details

Like ewas_enrichment(), the analysis runs as an asynchronous toolkit job and requires between 20 and 5000 probes. A probe set that has already been submitted (for example by an earlier ewas_enrichment() call with the same background) reuses the existing job.

Value

An ewas_eqtm object whose pairs element is a data frame with one row per CpG-gene-tissue correlation and columns probeId, gene_symbol, gene_id (Ensembl), location (position of the CpG relative to the gene), cor (Pearson correlation), p, tissue, and source (TCGA project(s)).

See Also

eqtm_samples() for the per-sample data behind one pair, and autoplot.ewas_eqtm() for plots.

Examples


probes <- c(
  "cg05575921", "cg00240195", "cg16419584", "cg11903855", "cg21566642",
  "cg23771366", "cg19859270", "cg00382138", "cg25648203", "cg01940273",
  "cg23576855", "cg00401753", "cg00300637", "cg12803068", "cg09935388",
  "cg01899089", "cg04180046", "cg00050873", "cg02228185", "cg18147296"
)
eq <- ewas_eqtm(probes, background = "850K")
summary(eq)
head(as.data.frame(eq))



EWAS Atlas eQTM result

Description

An ewas_eqtm holds the CpG-gene expression correlations returned by ewas_eqtm().

Usage

## S3 method for class 'ewas_eqtm'
summary(object, top_n = 10L, ...)

## S3 method for class 'ewas_eqtm'
as.data.frame(x, row.names = NULL, optional = FALSE, ...)

Arguments

object

An ewas_eqtm object.

top_n

Number of strongest pairs to list.

...

Unused.

x

An ewas_eqtm object.

row.names, optional

Unused; present for S3 consistency.

Value

An object of class ewas_eqtm: a named list with the pairs, job, probes, background, and excluded elements described above. summary.ewas_eqtm() invisibly returns a list of summary tables (after printing them), and as.data.frame.ewas_eqtm() returns the pairs data frame.

Fields

pairs

Data frame of CpG-gene-tissue correlations, sorted by p; see ewas_eqtm() for its columns.

job

The EWAS Atlas toolkit job identifier.

probes

The probe identifiers submitted.

background

The background set used ("450K", "850K", "EPICv2 (approximated by 850K)", or "other").

excluded

Input probes dropped because they are not in the background (see the background argument of ewas_enrichment()).


EWAS Atlas query result

Description

An ewas_result bundles the tables returned by query_cpg(), query_gene(), or query_region().

Usage

## S3 method for class 'ewas_result'
as.data.frame(x, row.names = NULL, optional = FALSE, ...)

Arguments

row.names, optional

Passed on for S3 consistency; unused.

Value

An object of class ewas_result: a named list with the associations, probes, failed, query_type, and n_queries elements described above. as.data.frame.ewas_result() returns the associations data frame on its own.

Fields

associations

One row per probe-trait association, with columns probeId, studyId, trait, correlation, rank, pmid, and query (the input term that returned this row).

probes

One row per unique probe, with columns probeId, chrHg19, posHg19, cpgIsland, gene, and query.

failed

Input terms that could not be resolved, with an error message column.

query_type

One of "cpg", "gene", "region".

n_queries

Number of input terms submitted.


Example CpG probe list

Description

A small example dataset of Illumina CpG probe identifiers, useful for trying out query_cpg() without needing to supply your own probe list. It contains only 3 distinct probes (with repeats), so it is too small for ewas_enrichment(), which requires 20-5000 distinct probes.

Usage

example_cpgs

Format

A data frame with 30 rows and 1 variable:

query_cpg

Character. CpG probe identifier.

Source

Illustrative subset of probes with known EWAS Atlas trait associations.

Examples

data(example_cpgs)
head(example_cpgs)

Word cloud of EWAS Atlas terms

Description

Draws a word cloud of trait terms sized by association frequency (for ewas_result objects) or by enrichment significance (for ewas_enrichment objects), or of eQTM genes sized by their strongest association (for ewas_eqtm objects).

Usage

plot_wordcloud(x, max_words = 75L, colors = NULL, ...)

## S3 method for class 'ewas_result'
plot_wordcloud(x, max_words = 75L, colors = NULL, ...)

## S3 method for class 'ewas_enrichment'
plot_wordcloud(
  x,
  max_words = 75L,
  colors = NULL,
  type = "trait",
  weight = c("neglog10p", "count"),
  ...
)

## S3 method for class 'ewas_eqtm'
plot_wordcloud(x, max_words = 75L, colors = NULL, ...)

Arguments

x

An ewas_result, ewas_enrichment, or ewas_eqtm object.

max_words

Maximum number of terms to display.

colors

A vector of colours to cycle through.

...

Passed to methods. All methods also accept title, subtitle, base_size, theme (see autoplot.ewas_result()), max_size (largest font size; by default 16, scaled up to 40 when there are only a few words), and seed (word layout seed, default 1).

type

Which enrichment analysis to plot the word cloud for (default "trait").

weight

Weighting statistic: "neglog10p" (default, significance) or "count" (differentially methylated CpG/gene count for the term).

Value

A ggplot object.


Query the EWAS Atlas by CpG probe identifier

Description

Retrieves trait associations and annotation for one or more Illumina CpG probe identifiers (e.g. "cg05575921") from the EWAS Atlas.

Usage

query_cpg(cpgs, workers = 2L, delay = 1, progress = interactive())

Arguments

cpgs

Character vector of probe identifiers from the 450K, EPIC (850K), or EPIC v2 array. EPIC v2 names such as "cg05575921_BC21" are converted to their 450K/EPIC v1 names ("cg05575921"), which is what EWAS Atlas uses. Duplicates and missing values are dropped before querying.

workers

Integer; maximum number of concurrent requests. Defaults to 2, a conservative value intended to avoid overloading the remote service.

delay

Numeric; seconds to pause between batches of workers requests.

progress

Logical; print a simple progress message as batches complete.

Value

An ewas_result object.

Examples


res <- query_cpg(c("cg05575921", "cg11903855"), workers = 1, delay = 1)
summary(res)



Query the EWAS Atlas by gene symbol

Description

Retrieves probes and trait associations linked to one or more gene symbols (e.g. "AHRR") from the EWAS Atlas.

Usage

query_gene(genes, workers = 2L, delay = 1, progress = interactive())

Arguments

genes

Character vector of gene symbols.

workers

Integer; maximum number of concurrent requests. Defaults to 2, a conservative value intended to avoid overloading the remote service.

delay

Numeric; seconds to pause between batches of workers requests.

progress

Logical; print a simple progress message as batches complete.

Value

An ewas_result object.

Examples


res <- query_gene("AHRR", workers = 1, delay = 1)
summary(res)



Query the EWAS Atlas by genomic region

Description

Retrieves probes and trait associations located within one or more genomic intervals (hg19 coordinates) from the EWAS Atlas.

Usage

query_region(
  chr,
  start = NULL,
  end = NULL,
  workers = 2L,
  delay = 1,
  progress = interactive()
)

Arguments

chr

Chromosome (e.g. "1", "X"), or a data frame with columns chr, start, end giving one or more regions, in which case start and end are ignored.

start

Start position (hg19, 1-based).

end

End position (hg19, 1-based).

workers

Integer; maximum number of concurrent requests. Defaults to 2, a conservative value intended to avoid overloading the remote service.

delay

Numeric; seconds to pause between batches of workers requests.

progress

Logical; print a simple progress message as batches complete.

Value

An ewas_result object.

Examples


res <- query_region(chr = "5", start = 373000, end = 374000, workers = 1)
summary(res)



Objects exported from other packages

Description

These objects are imported from other packages. Follow the links below to see their documentation.

ggplot2

autoplot()


Summarise an EWAS Atlas query result

Description

Summarise an EWAS Atlas query result

Usage

## S3 method for class 'ewas_result'
summary(object, top_n = 10L, ...)

Arguments

object

An ewas_result object.

top_n

Number of top traits to report.

...

Unused.

Value

Invisibly, a list with summary statistics; also printed.


Rank traits by association frequency

Description

Rank traits by association frequency

Usage

## S3 method for class 'ewas_enrichment'
top_traits(x, n = 10L, ...)

top_traits(x, n = 10L, ...)

## S3 method for class 'ewas_result'
top_traits(x, n = 10L, ...)

Arguments

x

An ewas_result or ewas_enrichment object.

n

Number of top traits to return.

...

Passed to methods.

Value

A data frame with columns trait and n (or p/OR for enrichment results), ordered from most to least significant/frequent.