Draws a circular (Circos) plot of transcription factor to target
links from a testEdges two-sample result. Genes are placed on
their genomic coordinates, links are coloured continuously by significance,
flagged as known or novel against an optional a priori network, and genes
belonging to supplied gene sets can be labelled around the circle.
circosEdges(
edgesDF,
species = "hsapiens_gene_ensembl",
geneCoords = NULL,
priorNet = NULL,
geneSets = NULL,
pAdjThreshold = 0.05,
log2FCThreshold = 0,
maxEdges = 500L,
colorBy = "log2FoldChange",
linkColors = c("#2166AC", "#F7F7F7", "#B2182B"),
lwdRange = c(0.5, 4),
nmaxTF = 20L,
nmaxTarget = 20L,
knownColor = "grey60",
novelColor = "#D95F02",
geneSetColors = NULL,
chromosomes = NULL,
mainChromosomesOnly = TRUE,
ensemblMirror = "www",
transparency = 0.5,
hRatio = 0.6,
fontFamily = "sans",
legend = TRUE
)Invisibly, a list with edges (the plotted links annotated with
coordinates and novelty) and coords (the gene coordinate table with
outDegree, inDegree and total degree columns, each the
sum of log2FoldChange over a gene's outgoing / incoming links). The
function is called for the side effect of drawing the plot.
A data.frame produced by testEdges (two-sample or
paired). Must contain the columns tf, target,
log2FoldChange and pAdj (pValue is used as a fallback
when pAdj is absent).
Ensembl dataset name passed to biomaRt when
geneCoords is NULL, e.g. "hsapiens_gene_ensembl" for
human or "mmusculus_gene_ensembl" for mouse. See
biomaRt::listDatasets() for the full multi-species list.
Optional data.frame supplying gene coordinates from any
source (overrides the biomaRt download). Must have columns
gene, chr, start and end.
Optional a priori TF-target network whose first two columns
are the TF and target. Links present here are labelled "known", all
others "novel". Accepts a data.frame or a matrix.
Optional gene-set annotation used to label genes around the circle: either a path to a GMT file or a named list of character vectors.
Numeric significance cutoff applied to pAdj
(or pValue when pAdj is missing). Default 0.05.
Numeric minimum absolute log2FoldChange required
to draw a link. Default 0.
Integer cap on the number of links drawn; when exceeded, the
most significant edges are kept. Default 500.
Name of the edgesDF column mapped to the link colour
ramp. Default "log2FoldChange", giving a continuous diverging colour
scale centred at zero. When the default is used but log2FoldChange is
absent (e.g. single-sample testEdges output), it falls back to
meanEdge.
Length-3 vector of colours for the low, mid and high ends of
colorBy. Default blue-white-red; a diverging ramp is used when
colorBy has negative values, otherwise a sequential low-to-high ramp.
Length-2 numeric giving the minimum and maximum link line
width; each link's thickness is scaled linearly within this range by its
-log10 adjusted p-value. Default c(0.5, 4).
Integers giving how many TFs and targets to label,
selected by the largest absolute out-degree and in-degree respectively.
Use NULL or Inf to label all. Defaults 20.
Border colours distinguishing known from novel links. Defaults grey and orange.
Optional named vector mapping gene-set names to colours.
When NULL, colours are generated automatically.
Optional character vector restricting and ordering the
chromosomes shown. When NULL, all chromosomes present are used.
Logical; when TRUE (the default) and
chromosomes is NULL, only the main chromosomes (numbered,
plus X, Y and MT) are kept and unplaced scaffolds/contigs are dropped.
biomaRt mirror to query: one of "www",
"useast" or "asia". Default "www".
Numeric link transparency in [0, 1] (0 is opaque).
Default 0.5.
Numeric in [0, 1] controlling how far link ribbons bend
toward the circle centre; smaller values give flatter, less tangled links.
Default 0.6.
Font family used for all plot text, e.g. "sans"
(Helvetica/Arial, the default) for a publication look.
Logical; whether to draw legends for effect size, novelty and
gene sets. Default TRUE.
Daniel Osorio <daniecos@uio.no>
Requires the circlize package, and biomaRt when gene
coordinates are downloaded automatically (geneCoords = NULL). Genes
without coordinates, and links whose TF or target lacks coordinates, are
dropped with a message.
testEdges, runSCORPION
if (FALSE) {
data(scorpionTest)
nets <- runSCORPION(
gexMatrix = scorpionTest$gex,
tfMotifs = scorpionTest$tf,
ppiNet = scorpionTest$ppi,
cellsMetadata = scorpionTest$metadata,
groupBy = c("donor", "region")
)
res <- testEdges(
networksDF = nets,
testType = "two.sample",
group1 = grep("--T$", colnames(nets), value = TRUE),
group2 = grep("--N$", colnames(nets), value = TRUE)
)
# Human coordinates auto-downloaded from Ensembl, known/novel vs a prior net
circosEdges(
edgesDF = res,
species = "hsapiens_gene_ensembl",
priorNet = scorpionTest$tf,
geneSets = "hallmark.gmt"
)
}
Run the code above in your browser using DataLab