| Title: | Match Transcriptomics Signatures to Single-Gene Perturbation References |
|---|---|
| Description: | Matches a query transcriptomics signature against a reference database of single-gene perturbation signatures, ranking the perturbations whose expression response most resembles the query and so nominating the regulators most likely to drive the observed change. Query signatures derived from a differential expression result are scored using cosine, GSEA and signed-Jaccard similarity metrics. Reference databases are supplied as HDF5-backed SummarizedExperiment objects for memory-efficient handling of large perturbation collections, and helper functions rank and visualise the best-matching regulators. |
| Authors: | Jamie Soul [aut, cre] (ORCID: <https://orcid.org/0000-0003-2255-6459>), Versus Arthritis [fnd] |
| Maintainer: | Jamie Soul <[email protected]> |
| License: | GPL-3 |
| Version: | 0.99.1 |
| Built: | 2026-10-13 13:47:40 UTC |
| Source: | https://github.com/BiocStaging/perturbMatch |
Returns the background gene set recorded in metadata() when the
object was built by calcEnrichment. This is the universe of genes
against which enrichment was scored.
background(object)background(object)
object |
A |
A character vector of gene identifiers, or NULL if unset.
pm <- methods::new( "PerturbMatch", SummarizedExperiment::SummarizedExperiment( assays = list( enrichment = matrix(0.5, dimnames = list("SIG1", "score")) ), metadata = list(background = c("GENE1", "GENE2", "GENE3")))) background(pm)pm <- methods::new( "PerturbMatch", SummarizedExperiment::SummarizedExperiment( assays = list( enrichment = matrix(0.5, dimnames = list("SIG1", "score")) ), metadata = list(background = c("GENE1", "GENE2", "GENE3")))) background(pm)
Calculates the enrichment of a regulator expression signature in the query expression signature. This measure is used to prioritise which upstream regulators are driving the observed gene expression changes.
calcEnrichment( object, expressionMatrix = NULL, upRegulated = NULL, downRegulated = NULL, background = NULL, method = c("SignedJaccard", "GSEA", "cosine", "cosineExtreme"), refMetric = NULL, threshold = NULL, topN = 250L, topSig = 250L, BPPARAM = BiocParallel::SerialParam(progressbar = TRUE), chunkSize = NULL )calcEnrichment( object, expressionMatrix = NULL, upRegulated = NULL, downRegulated = NULL, background = NULL, method = c("SignedJaccard", "GSEA", "cosine", "cosineExtreme"), refMetric = NULL, threshold = NULL, topN = 250L, topSig = 250L, BPPARAM = BiocParallel::SerialParam(progressbar = TRUE), chunkSize = NULL )
object |
A |
expressionMatrix |
Optional data frame with gene IDs in column 1 and
score values in column 2. Required for |
upRegulated |
Character vector of upregulated genes in the experiment.
Only used when |
downRegulated |
Character vector of downregulated genes in the
experiment. Only used when |
background |
Character vector of all genes expressed/measured in the
experiment. Only used when |
method |
Enrichment method to use. One of |
refMetric |
Reference metric to score against, one of
|
threshold |
Optional numeric threshold applied to reference metric
values to define reference gene sets ( |
topN |
Number of top and bottom genes per reference signature to use,
ranked by the reference metric. Used only when |
topSig |
Number of top/bottom genes from the query signature to use
when deriving gene sets from |
BPPARAM |
A |
chunkSize |
Number of reference signatures (columns) per processing
block. When |
A PerturbMatch object containing the enrichment scores.
Two input formats are supported:
Ranked list: supply expressionMatrix (a data frame
of gene IDs and score values). upRegulated,
downRegulated, and background are ignored.
Gene sets: supply upRegulated,
downRegulated, and background as character vectors.
expressionMatrix should be NULL.
If both are provided, expressionMatrix takes precedence.
Two metadata slots record which metrics a reference supports:
metadata(object)$ref_metric: the available metrics, each
naming a stored assay. limma references hold c("pi", "log2fc")
and chrdir references hold "chrdir".
metadata(object)$default_metric: the metric used when
refMetric = NULL.
# Load the small bundled demo reference database se <- getReferenceDatabase(demo = TRUE) # Score a query gene set against every reference signature. Here we just # use a handful of reference genes to stand in for a real up/down # signature. result <- calcEnrichment( se, upRegulated = rownames(se)[seq_len(3)], downRegulated = rownames(se)[seq(4, 5)], background = rownames(se), method = "SignedJaccard", BPPARAM = BiocParallel::SerialParam(progressbar = FALSE) ) cols <- c("pert_symbol", "pert_type", "score", "zscore") topRegulators(result, n = 3)[, cols]# Load the small bundled demo reference database se <- getReferenceDatabase(demo = TRUE) # Score a query gene set against every reference signature. Here we just # use a handful of reference genes to stand in for a real up/down # signature. result <- calcEnrichment( se, upRegulated = rownames(se)[seq_len(3)], downRegulated = rownames(se)[seq(4, 5)], background = rownames(se), method = "SignedJaccard", BPPARAM = BiocParallel::SerialParam(progressbar = FALSE) ) cols <- c("pert_symbol", "pert_type", "score", "zscore") topRegulators(result, n = 3)[, cols]
Returns the down-regulated gene set recorded in metadata() when the
object was built by calcEnrichment.
downRegulated(object)downRegulated(object)
object |
A |
A character vector of gene identifiers, or NULL if unset.
pm <- methods::new( "PerturbMatch", SummarizedExperiment::SummarizedExperiment( assays = list( enrichment = matrix(0.5, dimnames = list("SIG1", "score")) ), metadata = list(down_regulated = c("GENE3", "GENE4"), background = c("GENE3", "GENE4")))) downRegulated(pm)pm <- methods::new( "PerturbMatch", SummarizedExperiment::SummarizedExperiment( assays = list( enrichment = matrix(0.5, dimnames = list("SIG1", "score")) ), metadata = list(down_regulated = c("GENE3", "GENE4"), background = c("GENE3", "GENE4")))) downRegulated(pm)
Returns the matrix stored in the "enrichment" assay.
enrichment(object)enrichment(object)
object |
A |
A matrix of enrichment scores (rows = features, columns = signatures).
mat <- matrix(runif(3), nrow = 3, dimnames = list( c("GENE1", "GENE2", "GENE3"), "score" )) se <- SummarizedExperiment::SummarizedExperiment( assays = list(enrichment = mat) ) S4Vectors::metadata(se) <- list( up_regulated = "GENE1", down_regulated = "GENE3", background = c("GENE1", "GENE2", "GENE3") ) pm <- new("PerturbMatch", se) enrichment(pm)mat <- matrix(runif(3), nrow = 3, dimnames = list( c("GENE1", "GENE2", "GENE3"), "score" )) se <- SummarizedExperiment::SummarizedExperiment( assays = list(enrichment = mat) ) S4Vectors::metadata(se) <- list( up_regulated = "GENE1", down_regulated = "GENE3", background = c("GENE1", "GENE2", "GENE3") ) pm <- new("PerturbMatch", se) enrichment(pm)
Retrieve a perturbMatch reference expression database as a [SummarizedExperiment::SummarizedExperiment-class] object.
getReferenceDatabase( demo = FALSE, type = c("chrdir", "limma"), batchCorrection = FALSE, source = c("auto", "experimenthub", "zenodo"), cacheDir = tools::R_user_dir("perturbMatch", "cache"), ask = interactive() )getReferenceDatabase( demo = FALSE, type = c("chrdir", "limma"), batchCorrection = FALSE, source = c("auto", "experimenthub", "zenodo"), cacheDir = tools::R_user_dir("perturbMatch", "cache"), ask = interactive() )
demo |
Logical scalar indicating whether to load the small bundled
demonstration dataset instead of a full reference. Defaults to
|
type |
Character scalar specifying which reference database to load.
One of |
batchCorrection |
Logical scalar selecting the batch-corrected variant
of a reference. Available for both |
source |
Character scalar selecting where the full reference is
retrieved from. |
cacheDir |
Directory holding the BiocFileCache cache of
downloaded reference files. Defaults to a per-user cache directory
( |
ask |
Logical scalar controlling whether BiocFileCache asks
before creating |
Each reference is hosted as three files: an HDF5 file of the assay matrices
(0.7 GB for chrdir_sva up to 3.1 GB for limma), a serialised
colData of the signature annotation, and one gene annotation shared
by all four references. They are fetched once, cached, and reassembled into
a SummarizedExperiment whose assays are read from disk on demand.
The resources are registered on ExperimentHub, and documented by the perturbMatchData package, which does not need to be installed to use them. The signatures are derived from public NCBI GEO RNA-seq series and released under CC-BY-4.0, doi:10.5281/zenodo.21792179.
The bundled demo mirrors the structure of the full databases so the package
can be used offline. It is a 21-signature subset tailored to the
vignette examples. The rankings it produces are
illustrative only. Any real analysis needs a full reference
(demo = FALSE, the default).
A [SummarizedExperiment::SummarizedExperiment-class] object with
assay(s) stored as HDF5-backed delayed arrays. The object carries
metadata(object)$ref_metric, which tells
calcEnrichment how to compute the scoring matrix from
the assay(s):
"chrdir"Single assay named "chrdir", used
directly.
"log2fc"Assay named "log2fc", used directly.
"pi"Combined
score stored alongside the "log2fc" and "padj" assays.
ref_metric is fixed when the reference database is built, travels
with the data, and does not need to be set or modified by the user.
Alongside it are method, batch_correction,
default_metric and the build_version and source_doi
of the deposit the reference came from.
metadata(object)$source records how it was retrieved
("experimenthub", "zenodo" or "bundled"), and
metadata(object)$demo whether it is the bundled demo database.
All are carried through to the
PerturbMatch object returned by
calcEnrichment.
# Load the bundled demonstration database (no download required) se <- getReferenceDatabase(demo = TRUE) se S4Vectors::metadata(se)$ref_metric # A full reference is a multi-gigabyte one-time download, so it is fetched # only in an interactive session if (interactive()) { seChrdir <- getReferenceDatabase(type = "chrdir") # chrdir reference, with batch-effect correction seChrdirBc <- getReferenceDatabase( type = "chrdir", batchCorrection = TRUE ) # limma reference, without batch-effect correction seLimma <- getReferenceDatabase(type = "limma", batchCorrection = FALSE) }# Load the bundled demonstration database (no download required) se <- getReferenceDatabase(demo = TRUE) se S4Vectors::metadata(se)$ref_metric # A full reference is a multi-gigabyte one-time download, so it is fetched # only in an interactive session if (interactive()) { seChrdir <- getReferenceDatabase(type = "chrdir") # chrdir reference, with batch-effect correction seChrdirBc <- getReferenceDatabase( type = "chrdir", batchCorrection = TRUE ) # limma reference, without batch-effect correction seLimma <- getReferenceDatabase(type = "limma", batchCorrection = FALSE) }
An S4 class extending
SummarizedExperiment that holds the
enrichment scores produced by calcEnrichment. Scores are
available through enrichment(), or as a tidy table through
regulatorTable(). The usual SummarizedExperiment
accessors also work.
Details of analysis are stored in metadata() when
the object is built. The query gene sets have accessors of their own
(upRegulated, downRegulated,
background). The scoring parameters are read straight from
metadata() and are printed by show(). The reference gene sets
come from either threshold or topN.
The class contains an "enrichment"
assay of numeric scores, gene sets held as character vectors, and a
score_column entry. Objects
failing any of these are rejected by validObject.
object |
A |
enrichment: matrix of enrichment scores.
regulatorTable: tidy data.frame of scores plus row
metadata.
Draws a dot plot of the GO terms returned by
regulatorGSEA. Terms are placed by normalised enrichment
score, so those enriched among mimicking regulators (positive NES)
sit to the right of zero and those enriched among reversing regulators
(negative NES) to the left. Point size shows the GO set size and
colour the adjusted p-value.
plotRegulatorGSEA( x, n = 15L, pvalueCutoff = 0.1, wrapWidth = 40, fontSize = 12 )plotRegulatorGSEA( x, n = 15L, pvalueCutoff = 0.1, wrapWidth = 40, fontSize = 12 )
x |
A |
n |
Maximum number of terms to show. Taken by largest |
pvalueCutoff |
Only terms with |
wrapWidth |
Wrap long GO term labels to this many characters per
line. |
fontSize |
Base font size passed to
|
A ggplot object.
se <- getReferenceDatabase(demo = TRUE) res <- calcEnrichment( se, upRegulated = rownames(se)[seq_len(5)], downRegulated = rownames(se)[seq(6, 10)], background = rownames(se), BPPARAM = BiocParallel::SerialParam(progressbar = FALSE) ) go <- regulatorGSEA(res, minSize = 1) if (any(go$padj <= 0.5)) plotRegulatorGSEA(go, pvalueCutoff = 0.5)se <- getReferenceDatabase(demo = TRUE) res <- calcEnrichment( se, upRegulated = rownames(se)[seq_len(5)], downRegulated = rownames(se)[seq(6, 10)], background = rownames(se), BPPARAM = BiocParallel::SerialParam(progressbar = FALSE) ) go <- regulatorGSEA(res, minSize = 1) if (any(go$padj <= 0.5)) plotRegulatorGSEA(go, pvalueCutoff = 0.5)
Draws the top positive and top negative signatures as a lollipop plot.
plotSimilarity(object, topN = 10, inferActivity = FALSE)plotSimilarity(object, topN = 10, inferActivity = FALSE)
object |
A |
topN |
Integer. Number of top positive and top negative hits to show. |
inferActivity |
Logical. If |
A ggplot object.
# A PerturbMatch object as returned by calcEnrichment(): one row per # reference signature, scores in the 'enrichment' assay and the signature # annotation in rowData(). enr <- cbind( score = c(0.9, -0.7, -0.4, 0.5, -0.2), zscore = c(1.6, -1.1, -0.6, 0.8, -0.3) ) rownames(enr) <- paste0("SIG", seq_len(5)) se <- SummarizedExperiment::SummarizedExperiment( assays = list(enrichment = enr), rowData = S4Vectors::DataFrame( pert_symbol = c("GENE_A", "GENE_B", "GENE_C", "GENE_D", "GENE_E"), pert_type = c("OE", "KD", "KO", "OE", "KD") ) ) pm <- methods::new("PerturbMatch", se) plotSimilarity(pm, topN = 3) plotSimilarity(pm, topN = 3, inferActivity = TRUE)# A PerturbMatch object as returned by calcEnrichment(): one row per # reference signature, scores in the 'enrichment' assay and the signature # annotation in rowData(). enr <- cbind( score = c(0.9, -0.7, -0.4, 0.5, -0.2), zscore = c(1.6, -1.1, -0.6, 0.8, -0.3) ) rownames(enr) <- paste0("SIG", seq_len(5)) se <- SummarizedExperiment::SummarizedExperiment( assays = list(enrichment = enr), rowData = S4Vectors::DataFrame( pert_symbol = c("GENE_A", "GENE_B", "GENE_C", "GENE_D", "GENE_E"), pert_type = c("OE", "KD", "KO", "OE", "KD") ) ) pm <- methods::new("PerturbMatch", se) plotSimilarity(pm, topN = 3) plotSimilarity(pm, topN = 3, inferActivity = TRUE)
Extracts effect size and p-value assays for a given signature from a
SummarizedExperiment and delegates to volcanoPlot.
plotVolcano( object, signature, effectAssay = "logFC", pvalueAssay = "padj", numberPoints = 5, selectedPoints = NULL, logFCThreshold = log2(1.5), fdrThreshold = 0.05, pointSize = 2, labSize = 4, truncateInfPvalue = TRUE )plotVolcano( object, signature, effectAssay = "logFC", pvalueAssay = "padj", numberPoints = 5, selectedPoints = NULL, logFCThreshold = log2(1.5), fdrThreshold = 0.05, pointSize = 2, labSize = 4, truncateInfPvalue = TRUE )
object |
A |
signature |
A single character string matching one of
|
effectAssay |
Character string giving the name of the assay that holds
log2 fold-change values. Default: |
pvalueAssay |
Character string giving the name of the assay that holds
adjusted p-values (FDR). Default: |
numberPoints |
Integer. Number of top up- and down-regulated genes to
label automatically (ranked by p-value, then |logFC|). Set to |
selectedPoints |
Character vector of gene IDs to label regardless of
significance. Combined with |
logFCThreshold |
Numeric. Absolute log2 fold-change cut-off used to
classify genes as regulated. Default: |
fdrThreshold |
Numeric. Adjusted p-value cut-off. Default: |
pointSize |
Numeric. Size of plotted points passed to
|
labSize |
Numeric. Text size for gene labels passed to
|
truncateInfPvalue |
Logical. If |
A ggplot object.
set.seed(1) n <- 30 se <- SummarizedExperiment::SummarizedExperiment( assays = list( logFC = matrix(rnorm(n * 2), nrow = n, dimnames = list(paste0("Gene", seq_len(n)), c("A", "B"))), padj = matrix(runif(n * 2), nrow = n, dimnames = list(paste0("Gene", seq_len(n)), c("A", "B"))) ) ) plotVolcano(se, signature = "A") plotVolcano(se, signature = "A", selectedPoints = c("Gene1", "Gene2"))set.seed(1) n <- 30 se <- SummarizedExperiment::SummarizedExperiment( assays = list( logFC = matrix(rnorm(n * 2), nrow = n, dimnames = list(paste0("Gene", seq_len(n)), c("A", "B"))), padj = matrix(runif(n * 2), nrow = n, dimnames = list(paste0("Gene", seq_len(n)), c("A", "B"))) ) ) plotVolcano(se, signature = "A") plotVolcano(se, signature = "A", selectedPoints = c("Gene1", "Gene2"))
Extracts gene identifiers and log2 fold changes from a differential
expression result, maps the identifiers to the Entrez gene IDs used by
the perturbMatch reference databases, and reports the fraction
of the query that was successfully mapped. The returned data frame can be
passed directly to calcEnrichment as expressionMatrix.
prepareQuery( object, orgDb = "org.Hs.eg.db", keytype = NULL, reference = NULL, minMappedFraction = 0.5, dropLowExpressed = TRUE )prepareQuery( object, orgDb = "org.Hs.eg.db", keytype = NULL, reference = NULL, minMappedFraction = 0.5, dropLowExpressed = TRUE )
object |
A differential expression result. One of:
Columns are matched by name, not position, and any further columns are
ignored. Only adjusted p-values are recognised, so a
Gene identifiers are taken from the row names when those are real names,
as in |
orgDb |
An AnnotationDbi |
keytype |
The type of the query gene identifiers (e.g.
|
reference |
Optional reference database (a
|
minMappedFraction |
Numeric in |
dropLowExpressed |
Logical. When the input carries an adjusted p-value
column, tools such as DESeq2 set it to |
A data.frame with a gene column (Entrez IDs) and a
log2FC column, plus a padj column when one was available
in object. Rows with a missing fold change or an unmapped
identifier are dropped, and identifiers mapping to the same Entrez ID
are collapsed to the one with the largest absolute fold change.
# A limma topTable-style data frame (gene IDs in the row names) tt <- data.frame( logFC = c(2.5, -1.8, 0.3), adj.P.Val = c(0.001, 0.02, 0.4), row.names = c("100", "1000", "10000") ) # IDs are already Entrez, so no OrgDb is needed prepareQuery(tt)# A limma topTable-style data frame (gene IDs in the row names) tt <- data.frame( logFC = c(2.5, -1.8, 0.3), adj.P.Val = c(0.001, 0.02, 0.4), row.names = c("100", "1000", "10000") ) # IDs are already Entrez, so no OrgDb is needed prepareQuery(tt)
Runs gene set enrichment analysis (fgsea) over Gene Ontology terms using the reference regulators ranked by their perturbMatch similarity score. This asks which biological processes are enriched among the regulators whose perturbation signatures most closely mimic the query (positive enrichment) or most strongly reverse it (negative enrichment).
regulatorGSEA( object, ontology = c("BP", "MF", "CC"), aggregate = c("extreme", "mean"), inferActivity = TRUE, orgDb = "org.Hs.eg.db", minSize = 15L, maxSize = 500L, ... )regulatorGSEA( object, ontology = c("BP", "MF", "CC"), aggregate = c("extreme", "mean"), inferActivity = TRUE, orgDb = "org.Hs.eg.db", minSize = 15L, maxSize = 500L, ... )
object |
A PerturbMatch object from
|
ontology |
GO ontology to test: one of |
aggregate |
How to collapse the multiple signatures of a regulator into
one ranking statistic. |
inferActivity |
Logical. When |
orgDb |
An AnnotationDbi |
minSize, maxSize
|
Minimum and maximum GO gene-set sizes to test, passed
to |
... |
Further arguments passed to |
A reference database usually holds several signatures per regulator gene (different cell lines, and knockdown versus overexpression). These are collapsed to a single ranking statistic per gene before scoring:
scores are put on a consistent inferred-activity scale by flipping
the sign of the z-score for KD/KO perturbations (as in
plotSimilarity(inferActivity = TRUE)), controlled by
inferActivity.
the per-signature scores of each gene are aggregated with
aggregate (the single "extreme" value with the largest
magnitude, or the "mean" of the activity z-scores).
The resulting one-value-per-gene ranking is scored against GO gene sets, so
the positive end of the ranking (mimicking regulators) and the negative end
(reversing regulators) are tested together and separated by the sign of each
term's normalised enrichment score (NES).
Gene sets are built from orgDb (using the ancestor-propagated
GOALL mapping restricted to ontology), which also supplies
the regulator symbol-to-Entrez mapping. Human-readable term names are added
from GO.db when it is installed. Otherwise term falls back to
the GO accession.
A data.frame, one row per GO term ordered by adjusted
p-value, with columns ID (GO accession), term, NES
(positive = enriched among mimicking regulators, negative = among
reversing regulators), pval, padj, size and
leadingEdge (comma-separated regulator gene symbols).
plotRegulatorGSEA, calcEnrichment
se <- getReferenceDatabase(demo = TRUE) res <- calcEnrichment( se, upRegulated = rownames(se)[seq_len(5)], downRegulated = rownames(se)[seq(6, 10)], background = rownames(se), BPPARAM = BiocParallel::SerialParam(progressbar = FALSE) ) # minSize is lowered because the demo database is tiny. Keep the default # on a full reference. go <- regulatorGSEA(res, minSize = 1) head(go)se <- getReferenceDatabase(demo = TRUE) res <- calcEnrichment( se, upRegulated = rownames(se)[seq_len(5)], downRegulated = rownames(se)[seq(6, 10)], background = rownames(se), BPPARAM = BiocParallel::SerialParam(progressbar = FALSE) ) # minSize is lowered because the demo database is tiny. Keep the default # on a full reference. go <- regulatorGSEA(res, minSize = 1) head(go)
Combines rowData with the enrichment scores into a single
data.frame, one row per reference signature.
regulatorTable(object)regulatorTable(object)
object |
A |
The name deliberately avoids result/results, which would sit
one letter from results in a script that uses both.
A data.frame with one row per feature holding every
rowData column plus a score column.
mat <- matrix(runif(3), nrow = 3, dimnames = list( c("GENE1", "GENE2", "GENE3"), "score" )) se <- SummarizedExperiment::SummarizedExperiment( assays = list(enrichment = mat) ) S4Vectors::metadata(se) <- list( up_regulated = "GENE1", down_regulated = "GENE3", background = c("GENE1", "GENE2", "GENE3") ) pm <- new("PerturbMatch", se) regulatorTable(pm)mat <- matrix(runif(3), nrow = 3, dimnames = list( c("GENE1", "GENE2", "GENE3"), "score" )) se <- SummarizedExperiment::SummarizedExperiment( assays = list(enrichment = mat) ) S4Vectors::metadata(se) <- list( up_regulated = "GENE1", down_regulated = "GENE3", background = c("GENE1", "GENE2", "GENE3") ) pm <- new("PerturbMatch", se) regulatorTable(pm)
Prints the inherited SummarizedExperiment summary followed by the
gene sets and parameters recorded when the object was built.
## S4 method for signature 'PerturbMatch' show(object)## S4 method for signature 'PerturbMatch' show(object)
object |
A |
Invisibly returns NULL. Called for its printing side effect.
pm <- methods::new( "PerturbMatch", SummarizedExperiment::SummarizedExperiment( assays = list( enrichment = matrix(0.5, dimnames = list("SIG1", "score")) ), metadata = list( up_regulated = c("GENE1", "GENE2"), down_regulated = "GENE3", background = c("GENE1", "GENE2", "GENE3"), threshold = 0.5, topN = 250L, topSig = 100L ) ) ) show(pm)pm <- methods::new( "PerturbMatch", SummarizedExperiment::SummarizedExperiment( assays = list( enrichment = matrix(0.5, dimnames = list("SIG1", "score")) ), metadata = list( up_regulated = c("GENE1", "GENE2"), down_regulated = "GENE3", background = c("GENE1", "GENE2", "GENE3"), threshold = 0.5, topN = 250L, topSig = 100L ) ) ) show(pm)
Returns the n highest-scoring rows of regulatorTable,
ranked by
absolute enrichment score.
topRegulators(object, n = 5, ...)topRegulators(object, n = 5, ...)
object |
A |
n |
Number of signatures to return, capped at |
... |
Additional arguments passed to methods. |
A data.frame with at most n rows, ordered by descending
absolute score.
mat <- matrix(runif(5), nrow = 5, dimnames = list( paste0("GENE", seq_len(5)), "score" )) se <- SummarizedExperiment::SummarizedExperiment( assays = list(enrichment = mat) ) S4Vectors::metadata(se) <- list( up_regulated = "GENE1", down_regulated = "GENE5", background = paste0("GENE", seq_len(5)) ) pm <- new("PerturbMatch", se) topRegulators(pm, n = 3)mat <- matrix(runif(5), nrow = 5, dimnames = list( paste0("GENE", seq_len(5)), "score" )) se <- SummarizedExperiment::SummarizedExperiment( assays = list(enrichment = mat) ) S4Vectors::metadata(se) <- list( up_regulated = "GENE1", down_regulated = "GENE5", background = paste0("GENE", seq_len(5)) ) pm <- new("PerturbMatch", se) topRegulators(pm, n = 3)
Returns the up-regulated gene set recorded in metadata() when the
object was built by calcEnrichment.
upRegulated(object)upRegulated(object)
object |
A |
A character vector of gene identifiers, or NULL if unset.
pm <- methods::new( "PerturbMatch", SummarizedExperiment::SummarizedExperiment( assays = list( enrichment = matrix(0.5, dimnames = list("SIG1", "score")) ), metadata = list(up_regulated = c("GENE1", "GENE2"), background = c("GENE1", "GENE2")))) upRegulated(pm)pm <- methods::new( "PerturbMatch", SummarizedExperiment::SummarizedExperiment( assays = list( enrichment = matrix(0.5, dimnames = list("SIG1", "score")) ), metadata = list(up_regulated = c("GENE1", "GENE2"), background = c("GENE1", "GENE2")))) upRegulated(pm)
Renders a volcano plot of log2 fold-change against (FDR),
colouring genes as up-regulated, down-regulated, or unchanged relative to
supplied thresholds. The most significant genes at each tail are labelled
automatically, and arbitrary genes can be highlighted via
selectedPoints.
volcanoPlot( data, numberPoints = 5, selectedPoints = NULL, logFCThreshold = log2(1.5), fdrThreshold = 0.05, pointSize = 2, labSize = 4, truncateInfPvalue = TRUE )volcanoPlot( data, numberPoints = 5, selectedPoints = NULL, logFCThreshold = log2(1.5), fdrThreshold = 0.05, pointSize = 2, labSize = 4, truncateInfPvalue = TRUE )
data |
A data frame with at least three columns, in this order:
Additional columns are ignored. |
numberPoints |
Integer. Number of top up- and down-regulated genes to
label (ranked first by p-value, then by |
selectedPoints |
Character vector of gene identifiers to label
regardless of their statistics. Merged with automatic labels when
|
logFCThreshold |
Numeric. Minimum absolute log2 fold-change required
for a gene to be called regulated. Default: |
fdrThreshold |
Numeric. Maximum adjusted p-value for a gene to be
called regulated. Shown as a horizontal dashed line. Default: |
pointSize |
Numeric. Passed to |
labSize |
Numeric. Passed to |
truncateInfPvalue |
Logical. If |
Infinite p-values (arising from ) are, by
default, truncated to the largest finite value to keep the plot axis
bounded. See truncateInfPvalue to switch this off.
A ggplot object. Colour scale:
Up-regulated (logFC >= logFCThreshold and
padj <= fdrThreshold).
Down-regulated (logFC <= -logFCThreshold and
padj <= fdrThreshold).
Unchanged (all other genes).
set.seed(42) n <- 500 df <- data.frame( gene = paste0("Gene", seq_len(n)), logFC = rnorm(n, sd = 2), padj = rbeta(n, 0.5, 5) ) volcanoPlot(df) # Highlight specific genes volcanoPlot(df, selectedPoints = c("Gene1", "Gene42")) # Stricter thresholds, no automatic labels volcanoPlot(df, numberPoints = NULL, logFCThreshold = log2(2), fdrThreshold = 0.01)set.seed(42) n <- 500 df <- data.frame( gene = paste0("Gene", seq_len(n)), logFC = rnorm(n, sd = 2), padj = rbeta(n, 0.5, 5) ) volcanoPlot(df) # Highlight specific genes volcanoPlot(df, selectedPoints = c("Gene1", "Gene42")) # Stricter thresholds, no automatic labels volcanoPlot(df, numberPoints = NULL, logFCThreshold = log2(2), fdrThreshold = 0.01)