| Title: | End-to-End Analysis of Cancer Transcriptomes and Genomes |
|---|---|
| Description: | OncoSeq provides a unified, end-to-end workflow for cancer transcriptomic and genomic data analysis. A single container class couples bulk RNA-sequencing counts with somatic mutation calls, gene-level copy-number alterations and clinical follow-up for the same set of tumour samples. The package covers data import from the Genomic Data Commons, cBioPortal and local quantification files; quality control and filtering; normalisation; differential expression through DESeq2, edgeR or limma-voom behind one interface; gene-set enrichment and over-representation testing; Kaplan-Meier and Cox survival modelling including genome-wide survival screens; mutation and copy-number summarisation; integration of genomic alterations with expression; and publication-ready visualisation. Every analysis is recorded in the object so that a complete study can be reproduced from one object. |
| Authors: | Umar Ahmad [aut, cre] (ORCID: <https://orcid.org/0000-0002-3216-5171>) |
| Maintainer: | Umar Ahmad <[email protected]> |
| License: | GPL-3 |
| Version: | 0.99.1 |
| Built: | 2026-10-21 06:21:28 UTC |
| Source: | https://github.com/BiocStaging/OncoSeq |
Intersects the sample sets of the expression, mutation, copy-number and clinical layers so that downstream multi-omic analyses operate on a consistent cohort, and reports what was dropped.
alignLayers( object, require = c("mutation", "cnv"), timeColumn = "os_time", eventColumn = "os_event", verbose = TRUE )alignLayers( object, require = c("mutation", "cnv"), timeColumn = "os_time", eventColumn = "os_event", verbose = TRUE )
object |
|
require |
Layers that a sample must have data for. Any of '"mutation"', '"cnv"', '"survival"'. |
timeColumn, eventColumn
|
Columns checked when '"survival"' is required. |
verbose |
Report the number of samples retained. |
The subset OncoSeqExperiment.
ose <- exampleOncoSeq() alignLayers(ose, require = c("mutation", "survival"))ose <- exampleOncoSeq() alignLayers(ose, require = c("mutation", "survival"))
Wraps a SummarizedExperiment, a 'DESeqDataSet' or an 'edgeR' 'DGEList' in an OncoSeqExperiment so that it can enter the OncoSeq workflow, optionally attaching mutation and copy-number layers.
asOncoSeq(object, mutations = NULL, cnv = NULL)asOncoSeq(object, mutations = NULL, cnv = NULL)
object |
A SummarizedExperiment, 'DESeqDataSet' or 'DGEList'. |
mutations |
Optional variant table. |
cnv |
Optional gene-level copy-number matrix or SummarizedExperiment. |
se <- SummarizedExperiment::SummarizedExperiment( assays = list(counts = matrix(rpois(100, 30), nrow = 10, dimnames = list(paste0("G", 1:10), paste0("S", 1:10))))) asOncoSeq(se)se <- SummarizedExperiment::SummarizedExperiment( assays = list(counts = matrix(rpois(100, 30), nrow = 10, dimnames = list(paste0("G", 1:10), paste0("S", 1:10))))) asOncoSeq(se)
A real, trimmed TCGA bladder cancer cohort assembled from the cBioPortal PanCancer Atlas study 'blca_tcga_pan_can_atlas_2018' with [importCBioPortal()]. It carries mRNA expression, somatic mutations, discrete copy-number calls and clinical follow-up for the same 400 tumours, and is the dataset used throughout the vignette for the genomic and survival sections.
data(blcaExample)data(blcaExample)
An OncoSeqExperiment with 420 features and 400 samples:
RSEM-normalised mRNA abundance.
clinical attributes including 'AGE', 'SEX', 'AJCC_PATHOLOGIC_TUMOR_STAGE', 'SUBTYPE', 'TMB_NONSYNONYMOUS', 'ANEUPLOIDY_SCORE', and the harmonised 'os_time'/'os_event'.
14,337 somatic variants with 'sample', 'gene', 'variant_class', position and protein change.
discrete GISTIC gene-level copy-number calls.
Genes were restricted to a 420-gene panel: the 400 genes mutated in the largest number of samples in the study, plus a curated list of urothelial-carcinoma drivers and luminal/basal markers. Samples were restricted to the 400 tumours carrying expression, mutation, copy-number and overall-survival data simultaneously.
The 'expression' assay holds RSEM-normalised values, not raw counts, so count-based engines will refuse to model it; use 'engine = "limma"' with 'voom = FALSE', or [exampleOncoSeq()] when a count-scale demonstration is needed. Copy-number values are GISTIC calls in '-2:2'. Survival is harmonised into 'os_time' (months) and 'os_event' (1 = death).
cBioPortal study 'blca_tcga_pan_can_atlas_2018' (<https://www.cbioportal.org/study/summary?id=blca_tcga_pan_can_atlas_2018>), derived from the TCGA PanCancer Atlas. The build script is 'data-raw/make-blcaExample.R'.
[exampleOncoSeq()] for a simulated count-scale object.
data(blcaExample) blcaExample head(mutationFrequency(blcaExample, topN = 10))data(blcaExample) blcaExample head(mutationFrequency(blcaExample, topN = 10))
List the molecular profiles of a cBioPortal study
cbioProfiles(studyId, baseUrl = CBIOPORTAL_URL)cbioProfiles(studyId, baseUrl = CBIOPORTAL_URL)
studyId |
cBioPortal study identifier, for example '"blca_tcga_pan_can_atlas_2018"'. |
baseUrl |
Base URL of the cBioPortal API. |
A 'data.frame' of molecular profiles with their 'molecularProfileId', 'molecularAlterationType' and 'datatype'.
## Not run: cbioProfiles("blca_tcga_pan_can_atlas_2018")[, c("molecularProfileId", "molecularAlterationType")] ## End(Not run)## Not run: cbioProfiles("blca_tcga_pan_can_atlas_2018")[, c("molecularProfileId", "molecularAlterationType")] ## End(Not run)
Queries a cBioPortal instance for the studies it serves, optionally filtered by a keyword matched against the study identifier, name and cancer type.
cbioStudies(keyword = NULL, baseUrl = CBIOPORTAL_URL)cbioStudies(keyword = NULL, baseUrl = CBIOPORTAL_URL)
keyword |
Optional case-insensitive search term, for example '"bladder"'. |
baseUrl |
Base URL of the cBioPortal API. |
A 'data.frame' with one row per study, including 'studyId', 'name', 'cancerTypeId' and the sample counts.
[cbioProfiles()], [importCBioPortal()]
## Not run: bladder <- cbioStudies("bladder") head(bladder[, c("studyId", "name", "allSampleCount")]) ## End(Not run)## Not run: bladder <- cbioStudies("bladder") head(bladder[, c("studyId", "name", "allSampleCount")]) ## End(Not run)
Tests the dosage effect of copy-number alteration on transcript abundance gene by gene, over the samples that carry both layers. A positive correlation is the expected signature of a copy-number-driven expression change and is used to separate passenger from dosage-sensitive genes.
cnvExpressionCorrelation( object, genes = NULL, exprAssay = NULL, cnvAssay = 1L, method = "spearman", minSamples = 10L )cnvExpressionCorrelation( object, genes = NULL, exprAssay = NULL, cnvAssay = 1L, method = "spearman", minSamples = 10L )
object |
An OncoSeqExperiment with expression and copy-number layers. |
genes |
Genes to test; defaults to every gene present in both layers. |
exprAssay |
Expression assay to use; log-scale values are preferred and are derived from counts when necessary. |
cnvAssay |
Name or index of the copy-number assay. |
method |
Correlation method, passed to [stats::cor.test()]. |
minSamples |
Minimum number of complete pairs required to test a gene. |
A 'data.frame' with 'gene', 'n', 'estimate', 'pvalue' and 'padj', ordered by adjusted p-value.
ose <- exampleOncoSeq() head(cnvExpressionCorrelation(ose))ose <- exampleOncoSeq() head(cnvExpressionCorrelation(ose))
Per-gene frequency of gain and loss across the cohort, in the long format expected by [plotCNVFrequency()].
cnvFrequency( object, genes = NULL, topN = 20, ampThreshold = 2, delThreshold = -2, assay = 1L )cnvFrequency( object, genes = NULL, topN = 20, ampThreshold = 2, delThreshold = -2, assay = 1L )
object |
An OncoSeqExperiment with a copy-number layer. |
genes |
Optional character vector restricting the output. |
topN |
Keep the 'topN' genes with the highest alteration frequency. |
ampThreshold |
Values greater than or equal to this count as a gain. |
delThreshold |
Values less than or equal to this count as a loss. |
assay |
Name or index of the copy-number assay. |
A 'data.frame' with columns 'gene', 'alteration' ('"gain"' or '"loss"') and 'frequency'.
ose <- exampleOncoSeq() head(cnvFrequency(ose, topN = 5))ose <- exampleOncoSeq() head(cnvFrequency(ose, topN = 5))
Counts amplifications and deletions per gene and per sample from the discrete copy-number layer. Thresholds follow the GISTIC convention in which '2' and '-2' denote high-level amplification and deep deletion and '1'/'-1' denote single-copy gain and loss.
cnvSummary(object, ampThreshold = 2, delThreshold = -2, assay = 1L)cnvSummary(object, ampThreshold = 2, delThreshold = -2, assay = 1L)
object |
An OncoSeqExperiment with a copy-number layer. |
ampThreshold |
Values greater than or equal to this count as a gain. |
delThreshold |
Values less than or equal to this count as a loss. |
assay |
Name or index of the copy-number assay. |
A list with 'perGene' and 'perSample' 'data.frame's.
ose <- exampleOncoSeq() cs <- cnvSummary(ose) head(cs$perGene)ose <- exampleOncoSeq() cs <- cnvSummary(ose) head(cs$perGene)
Fits the same comparison with DESeq2, edgeR and limma-voom and returns the overlap of their significant calls together with a merged table of log fold changes. Concordance across engines is a practical check that a signature is not an artefact of one model's assumptions.
compareEngines( object, design, contrast = NULL, coef = NULL, engines = c("DESeq2", "edgeR", "limma"), alpha = 0.05, assay = NULL )compareEngines( object, design, contrast = NULL, coef = NULL, engines = c("DESeq2", "edgeR", "limma"), alpha = 0.05, assay = NULL )
object |
|
design |
A one-sided formula over 'colData()' columns, for example '~ condition' or '~ batch + condition'. |
contrast |
A character triple 'c(variable, numerator, denominator)' or a numeric contrast vector over the design-matrix columns. |
coef |
Name or index of a single design-matrix coefficient to test; an alternative to 'contrast'. |
engines |
Engines to run. |
alpha |
Adjusted-p-value threshold used for the overlap counts. |
assay |
Assay to model. Count engines default to 'counts'; 'limma' uses 'counts' with voom unless 'voom = FALSE'. |
A list with 'merged' (one row per feature, log2FC and padj from each engine), 'overlap' (a named integer vector of significant counts per engine and the size of their intersection) and 'consensus' (the features significant in every engine).
ose <- exampleOncoSeq() ose <- filterLowExpression(ose, group = "condition", verbose = FALSE) cmp <- compareEngines(ose, ~ condition, contrast = c("condition", "tumour", "normal")) cmp$overlapose <- exampleOncoSeq() ose <- filterLowExpression(ose, group = "condition", verbose = FALSE) cmp <- compareEngines(ose, ~ condition, contrast = c("condition", "tumour", "normal")) cmp$overlap
Fits [survival::coxph()] with covariates drawn from 'colData()', from expression (prefix a gene name with 'expr:') or from mutation status (prefix with 'mut:'), and returns a tidy table of hazard ratios.
coxModel( object, covariates, timeColumn = "os_time", eventColumn = "os_event", assay = NULL, name = "cox" )coxModel( object, covariates, timeColumn = "os_time", eventColumn = "os_event", assay = NULL, name = "cox" )
object |
|
covariates |
Character vector of terms, for example 'c("age", "stage", "expr:TP53", "mut:RB1")'. |
timeColumn, eventColumn
|
Follow-up and event columns in 'colData()'. |
assay |
Expression assay used for 'expr:' terms. |
name |
Name under which the result is stored in the registry; 'NULL' returns the table instead of the object. |
The object with the tidy table stored, or the table itself when 'name' is 'NULL'. Columns are 'term', 'coef', 'HR', 'ci_lower', 'ci_upper', 'se', 'z' and 'pvalue'. The fitted model is attached as the 'model' attribute.
ose <- exampleOncoSeq() coxModel(ose, c("expr:TP53", "mut:TP53"), name = NULL)ose <- exampleOncoSeq() coxModel(ose, c("expr:TP53", "mut:TP53"), name = NULL)
Identifies samples that sit far from the bulk of the data in two complementary ways: distance from the centroid in the space of the leading principal components, and low median correlation with all other samples. Both criteria are reported; nothing is removed.
detectOutliers( object, assay = NULL, nTopGenes = 500L, nPC = 2L, madThreshold = 3, corMethod = "spearman" )detectOutliers( object, assay = NULL, nTopGenes = 500L, nPC = 2L, madThreshold = 3, corMethod = "spearman" )
object |
|
assay |
Assay to use. When absent, log2 counts-per-million are computed from the counts. |
nTopGenes |
Number of most variable features used for the principal component analysis. |
nPC |
Number of principal components used for the distance. |
madThreshold |
A sample is flagged when its centroid distance exceeds the median distance by this many median absolute deviations. |
corMethod |
Correlation method for the second criterion. |
A DataFrame with one row per sample giving the centroid distance, the median inter-sample correlation and a logical 'outlier' column.
ose <- exampleOncoSeq() out <- detectOutliers(ose) sum(out$outlier)ose <- exampleOncoSeq() out <- detectOutliers(ose) sum(out$outlier)
Fits a differential-expression model with one of three engines behind a single interface and returns one harmonised result table. The engines are the standard implementations: [DESeq2::DESeq()] with a negative-binomial Wald test, [edgeR::glmQLFTest()] quasi-likelihood F tests, and [limma::eBayes()] on [limma::voom()] precision weights (or on an already transformed assay with 'limma-trend').
diffExpress( object, design, contrast = NULL, coef = NULL, engine = c("DESeq2", "edgeR", "limma"), assay = NULL, voom = NULL, shrink = FALSE, name = "de", alpha = 0.05, verbose = TRUE, ... )diffExpress( object, design, contrast = NULL, coef = NULL, engine = c("DESeq2", "edgeR", "limma"), assay = NULL, voom = NULL, shrink = FALSE, name = "de", alpha = 0.05, verbose = TRUE, ... )
object |
|
design |
A one-sided formula over 'colData()' columns, for example '~ condition' or '~ batch + condition'. |
contrast |
A character triple 'c(variable, numerator, denominator)' or a numeric contrast vector over the design-matrix columns. |
coef |
Name or index of a single design-matrix coefficient to test; an alternative to 'contrast'. |
engine |
One of '"DESeq2"', '"edgeR"' or '"limma"'. |
assay |
Assay to model. Count engines default to 'counts'; 'limma' uses 'counts' with voom unless 'voom = FALSE'. |
voom |
For 'engine = "limma"', apply [limma::voom()] to counts ('TRUE'), or fit 'limma-trend' to the supplied transformed assay ('FALSE'). 'NULL' chooses automatically from the assay. |
shrink |
For 'engine = "DESeq2"', apply [DESeq2::lfcShrink()] with 'apeglm'; requires the 'apeglm' package and a 'coef'. |
name |
Name under which the result is stored in the analysis registry. |
alpha |
Significance level used when reporting the number of differentially expressed features. |
verbose |
Print a one-line summary of the fit. |
... |
Further arguments passed to the engine's fitting function ([DESeq2::DESeq()], [edgeR::glmQLFit()] or [limma::eBayes()]). |
The contrast may be given in three ways:
a character triple 'c(variable, numerator, denominator)', which tests 'numerator - denominator' for that 'colData()' variable;
a coefficient name present in the design matrix, through 'coef';
a numeric vector over the columns of the design matrix.
Additional terms in 'design' are adjusted for. The same contrast specification gives the same comparison in all three engines, so results can be compared directly.
The OncoSeqExperiment with the result table stored in 'analyses(object)[[name]]'. Retrieve it with [getAnalysis()]. The table is a 'data.frame' with columns 'feature', 'baseMean', 'log2FC', 'lfcSE', 'stat', 'pvalue', 'padj' and 'engine', ordered by 'padj'.
[compareEngines()], [runGSEA()], [plotVolcano()]
ose <- exampleOncoSeq() ose <- filterLowExpression(ose, group = "condition", verbose = FALSE) ose <- diffExpress(ose, ~ condition, contrast = c("condition", "tumour", "normal"), engine = "edgeR", name = "de_edger") head(getAnalysis(ose, "de_edger"))ose <- exampleOncoSeq() ose <- filterLowExpression(ose, group = "condition", verbose = FALSE) ose <- diffExpress(ose, ~ condition, contrast = c("condition", "tumour", "normal"), engine = "edgeR", name = "de_edger") head(getAnalysis(ose, "de_edger"))
Returns [simExample], a compact OncoSeqExperiment with expression counts, somatic mutations, gene-level copy number and overall-survival follow-up, optionally trimmed to fewer features or samples. It is the object used by the examples and unit tests.
exampleOncoSeq(nGenes = NULL, nPerGroup = NULL)exampleOncoSeq(nGenes = NULL, nPerGroup = NULL)
nGenes |
Number of features to keep, taken from the start of the object so that the named driver genes are always present. 'NULL' keeps all 300. |
nPerGroup |
Number of tumour and of normal samples to keep. 'NULL' keeps all 20 of each. |
The data are simulated, not measured: a negative-binomial count model with a planted differential signal between tumour and normal, mutations planted at frequencies resembling those of urothelial carcinoma, and survival times from an exponential model whose rate depends on 'TP53' mutation status. Gene symbols are real so that gene sets and driver names behave sensibly in examples.
The object is built once, by 'data-raw/make-simExample.R', and shipped with the package. This function therefore draws no random numbers and leaves the caller's random stream untouched; repeated calls return identical objects.
An OncoSeqExperiment with a 'counts' assay, 'condition', 'age', 'stage', 'os_time' and 'os_event' in 'colData()', a mutation table and a copy-number layer.
[simExample] for the full object, [importCounts()] to build one from your own data.
ose <- exampleOncoSeq() ose table(SummarizedExperiment::colData(ose)$condition) dim(exampleOncoSeq(nGenes = 50, nPerGroup = 5))ose <- exampleOncoSeq() ose table(SummarizedExperiment::colData(ose)$condition) dim(exampleOncoSeq(nGenes = 50, nPerGroup = 5))
Drops features that carry too little signal to be tested. With a grouping variable the filter is [edgeR::filterByExpr()], the standard choice for count data, which keeps features with enough counts in a number of samples equal to the smallest group. Without a grouping variable a simple counts-per-million rule is applied.
filterLowExpression( object, group = NULL, assay = NULL, minCount = 10, minCPM = 1, minSamples = 2L, verbose = TRUE )filterLowExpression( object, group = NULL, assay = NULL, minCount = 10, minCPM = 1, minSamples = 2L, verbose = TRUE )
object |
|
group |
Name of a 'colData()' column giving the experimental groups, or a vector of the same length as the number of samples. 'NULL' applies the CPM rule. |
assay |
Name of the count assay; defaults to 'counts'. |
minCount |
Minimum count required, passed to [edgeR::filterByExpr()]. |
minCPM |
CPM threshold used when 'group' is 'NULL'. |
minSamples |
Number of samples that must exceed 'minCPM' when 'group' is 'NULL'; defaults to the size of the smallest conceivable group, 2. |
verbose |
Report how many features were removed. |
The filtered OncoSeqExperiment.
ose <- exampleOncoSeq() dim(ose) dim(filterLowExpression(ose, group = "condition"))ose <- exampleOncoSeq() dim(ose) dim(filterLowExpression(ose, group = "condition"))
Extract one result from the analysis registry of an OncoSeqExperiment, with an informative error when the name is not present.
getAnalysis(object, name)getAnalysis(object, name)
object |
|
name |
Name of the stored result. When missing, the available names are returned. |
The stored result object, or a character vector of available names when 'name' is missing.
ose <- exampleOncoSeq() getAnalysis(ose) ose <- diffExpress(ose, ~ condition, contrast = c("condition", "tumour", "normal"), engine = "edgeR", verbose = FALSE) head(getAnalysis(ose, "de"))ose <- exampleOncoSeq() getAnalysis(ose) ose <- diffExpress(ose, ~ condition, contrast = c("condition", "tumour", "normal"), engine = "edgeR", verbose = FALSE) head(getAnalysis(ose, "de"))
Assembles a curated cBioPortal study into an OncoSeqExperiment: an mRNA expression matrix, the somatic mutation table, discrete (GISTIC-style) gene-level copy-number calls and the clinical table, all restricted to samples shared by the requested layers.
importCBioPortal( studyId, genes = NULL, expressionProfile = NULL, mutationProfile = NULL, cnvProfile = NULL, mutations = TRUE, cnv = TRUE, clinical = TRUE, chunkSize = 500L, baseUrl = CBIOPORTAL_URL )importCBioPortal( studyId, genes = NULL, expressionProfile = NULL, mutationProfile = NULL, cnvProfile = NULL, mutations = TRUE, cnv = TRUE, clinical = TRUE, chunkSize = 500L, baseUrl = CBIOPORTAL_URL )
studyId |
cBioPortal study identifier; see [cbioStudies()]. |
genes |
Optional character vector of HUGO symbols to restrict the expression and copy-number layers to. 'NULL' fetches every gene in the profile, which for a whole study is a large download. |
expressionProfile |
Molecular profile identifier for expression. When 'NULL' the first continuous mRNA profile of the study is used. |
mutationProfile |
Molecular profile identifier for mutations, or ‘NULL' to use the study’s extended mutation profile. Set 'mutations' to 'FALSE' to skip. |
cnvProfile |
Molecular profile identifier for discrete copy number, or ‘NULL' to use the study’s GISTIC profile. Set 'cnv' to 'FALSE' to skip. |
mutations, cnv, clinical
|
Logical flags controlling which optional layers are retrieved. |
chunkSize |
Number of genes per API request. |
baseUrl |
Base URL of the cBioPortal API. |
cBioPortal serves processed expression values rather than raw counts: for TCGA PanCancer Atlas studies the default profile holds RSEM-normalised values. The resulting assay is therefore named 'expression', not 'counts', and count-based differential-expression engines will refuse to run on it; use 'engine = "limma"' on log-transformed values, or [importGDC()] when raw counts are required.
Clinical attributes arrive in long form and are pivoted to one column per attribute. Overall survival is harmonised into 'os_time' and 'os_event' when the study carries 'OS_MONTHS'/'OS_STATUS'.
An OncoSeqExperiment with an 'expression' assay.
[importGDC()], [cbioStudies()]
## Not run: ose <- importCBioPortal("blca_tcga_pan_can_atlas_2018", genes = c("TP53", "RB1", "FGFR3", "ERBB2")) ose ## End(Not run)## Not run: ose <- importCBioPortal("blca_tcga_pan_can_atlas_2018", genes = c("TP53", "RB1", "FGFR3", "ERBB2")) ose ## End(Not run)
Builds an OncoSeqExperiment from a gene-by-sample count matrix and a table of sample annotation held in memory or on disk. Optional somatic-variant and copy-number layers are attached and checked against the expression sample identifiers.
importCounts( counts, colData = NULL, rowData = NULL, mutations = NULL, cnv = NULL, sep = "\t", intersectSamples = TRUE )importCounts( counts, colData = NULL, rowData = NULL, mutations = NULL, cnv = NULL, sep = "\t", intersectSamples = TRUE )
counts |
A numeric matrix (genes in rows, samples in columns), a 'data.frame', or a path to a delimited text file whose first column holds feature identifiers. |
colData |
A 'data.frame'/DataFrame of sample annotation, or a path to a delimited file whose first column holds sample identifiers. Rows are matched to the columns of 'counts' by name when names are available, otherwise by position. |
rowData |
Optional feature annotation, as an object or a file path. |
mutations |
Optional variant table, as an object or a path to a MAF or delimited file (see [importMAF()]). |
cnv |
Optional gene-level copy-number matrix, as an object or a file path. |
sep |
Field separator used when reading files. |
intersectSamples |
When 'TRUE' (the default) the object is restricted to samples present in both 'counts' and 'colData'. When 'FALSE' a mismatch is an error. |
[importGDC()], [importCBioPortal()], [importTximport()]
counts <- matrix(rpois(300, 40), nrow = 30, dimnames = list(paste0("G", 1:30), paste0("S", 1:10))) meta <- data.frame(condition = rep(c("tumour", "normal"), each = 5), row.names = colnames(counts)) ose <- importCounts(counts, meta) osecounts <- matrix(rpois(300, 40), nrow = 30, dimnames = list(paste0("G", 1:30), paste0("S", 1:10))) meta <- data.frame(condition = rep(c("tumour", "normal"), each = 5), row.names = colnames(counts)) ose <- importCounts(counts, meta) ose
Downloads and assembles a Genomic Data Commons project into a single OncoSeqExperiment: STAR gene-expression counts, the indexed clinical table with harmonised overall-survival columns, and optionally simple somatic mutations and gene-level copy-number scores. Layers are keyed on the TCGA patient barcode so that expression, genomic and clinical data for one tumour line up.
importGDC( project = "TCGA-BLCA", sampleType = NULL, mutations = FALSE, cnv = FALSE, clinical = TRUE, directory = "GDCdata", files.per.chunk = 50L )importGDC( project = "TCGA-BLCA", sampleType = NULL, mutations = FALSE, cnv = FALSE, clinical = TRUE, directory = "GDCdata", files.per.chunk = 50L )
project |
GDC project identifier, for example '"TCGA-BLCA"' for bladder urothelial carcinoma. |
sampleType |
Character vector of sample types to keep, for example 'c("Primary Tumor", "Solid Tissue Normal")'. 'NULL' keeps all. |
mutations |
Logical; also download simple somatic mutations. |
cnv |
Logical; also download gene-level copy-number scores. |
clinical |
Logical; attach the indexed clinical table. |
directory |
Download cache directory passed to [TCGAbiolinks::GDCdownload()]. |
files.per.chunk |
Number of files per download chunk; lower this on unstable connections. |
The GDC retired the '"HTSeq - Counts"' workflow when it moved to Data Release 32; this function requests '"STAR - Counts"', which is the current gene-expression workflow. Downloaded files are cached by 'TCGAbiolinks' in 'directory', so repeating a call is inexpensive.
Sample barcodes are truncated to the 12-character patient barcode so that expression, mutation, copy-number and clinical layers share identifiers. When a patient contributes more than one aliquot the first is retained and a message reports how many were dropped.
An OncoSeqExperiment with a 'counts' assay (plus 'tpm_unstrand' and 'fpkm_unstrand' when the GDC supplies them), clinical columns in 'colData', and the mutation and copy-number layers when requested.
Needs the 'TCGAbiolinks' package and network access to 'api.gdc.cancer.gov'.
[importCBioPortal()] for a lighter, API-based alternative.
# Downloads several hundred megabytes; not run during package checks. ## Not run: blca <- importGDC("TCGA-BLCA", sampleType = "Primary Tumor", mutations = TRUE, cnv = TRUE) blca ## End(Not run)# Downloads several hundred megabytes; not run during package checks. ## Not run: blca <- importGDC("TCGA-BLCA", sampleType = "Primary Tumor", mutations = TRUE, cnv = TRUE) blca ## End(Not run)
Reads a Mutation Annotation Format file (optionally gzip-compressed) and harmonises its column names to the OncoSeq vocabulary, keeping all original columns.
importMAF(file, sep = "\t", comment = "#")importMAF(file, sep = "\t", comment = "#")
file |
Path to a MAF or MAF-like delimited file. |
sep |
Field separator. |
comment |
Lines beginning with this character are skipped; MAF files from the GDC begin with a version header. |
A DataFrame with at least 'sample', 'gene' and, when present, 'variant_class'.
[mutationFrequency()], [oncoplotData()]
maf <- system.file("extdata", "example_mutations.maf", package = "OncoSeq") head(importMAF(maf))maf <- system.file("extdata", "example_mutations.maf", package = "OncoSeq") head(importMAF(maf))
Summarises transcript-level abundance files produced by salmon, kallisto, RSEM or similar to the gene level with [tximport::tximport()] and returns an OncoSeqExperiment holding the gene-level counts, the average transcript lengths and the TPM estimates.
importTximport( files, tx2gene, type = "salmon", colData = NULL, countsFromAbundance = "lengthScaledTPM", ... )importTximport( files, tx2gene, type = "salmon", colData = NULL, countsFromAbundance = "lengthScaledTPM", ... )
files |
Named character vector of quantification files; the names become sample identifiers. |
tx2gene |
A two-column 'data.frame' mapping transcript to gene identifiers. |
type |
Quantification tool, passed to [tximport::tximport()]. |
colData |
Optional sample annotation, matched to 'names(files)'. |
countsFromAbundance |
Passed to [tximport::tximport()]; the default '"lengthScaledTPM"' yields counts suitable for direct use in differential expression. |
... |
Further arguments passed to [tximport::tximport()]. |
An OncoSeqExperiment with assays 'counts', 'abundance' and 'length'.
# Requires the tximport package and quantification files on disk: if (requireNamespace("tximport", quietly = TRUE)) { # files <- c(S1 = "S1/quant.sf", S2 = "S2/quant.sf") # ose <- importTximport(files, tx2gene = t2g, type = "salmon") }# Requires the tximport package and quantification files on disk: if (requireNamespace("tximport", quietly = TRUE)) { # files <- c(S1 = "S1/quant.sf", S2 = "S2/quant.sf") # ose <- importTximport(files, tx2gene = t2g, type = "salmon") }
Adds the mutation status of a driver gene to 'colData()' and runs [diffExpress()] comparing mutant with wild-type samples, optionally adjusting for clinical covariates. This is the standard way to ask what transcriptional programme accompanies an alteration.
integrateMutationExpression( object, gene, covariates = NULL, engine = "edgeR", nonsynonymousOnly = TRUE, minGroupSize = 3L, name = paste0("de_", gene), ... )integrateMutationExpression( object, gene, covariates = NULL, engine = "edgeR", nonsynonymousOnly = TRUE, minGroupSize = 3L, name = paste0("de_", gene), ... )
object |
An OncoSeqExperiment with expression and mutation layers. |
gene |
Driver gene whose status defines the comparison. |
covariates |
Optional 'colData()' columns to adjust for. |
engine |
Differential-expression engine; see [diffExpress()]. |
nonsynonymousOnly |
Count only protein-altering variants. |
minGroupSize |
Refuse to run when either group is smaller than this. |
name |
Name under which the result is stored. |
... |
Passed to [diffExpress()]. |
The object with the result stored in the registry and a '<gene>_status' column added to 'colData()'.
[diffExpress()], [mutationStatus()]
ose <- exampleOncoSeq() ose <- filterLowExpression(ose, group = "condition", verbose = FALSE) ose <- integrateMutationExpression(ose, "TP53", engine = "edgeR") head(getAnalysis(ose, "de_TP53"))ose <- exampleOncoSeq() ose <- filterLowExpression(ose, group = "condition", verbose = FALSE) ose <- integrateMutationExpression(ose, "TP53", engine = "edgeR") head(getAnalysis(ose, "de_TP53"))
Convenience wrapper that converts an MSigDB collection obtained with the 'msigdbr' package into the named-list format used by OncoSeq.
msigdbrSets(species = "Homo sapiens", collection = "H", subcollection = NULL)msigdbrSets(species = "Homo sapiens", collection = "H", subcollection = NULL)
species |
Species name accepted by [msigdbr::msigdbr()], for example '"Homo sapiens"'. |
collection |
Collection identifier, for example '"H"' for the hallmark sets or '"C2"' for curated sets. |
subcollection |
Optional sub-collection, for example '"CP:REACTOME"'. |
A named list of gene symbols.
Needs the 'msigdbr' package, which is not a hard dependency of OncoSeq.
## Not run: hallmark <- msigdbrSets("Homo sapiens", "H") ## End(Not run)## Not run: hallmark <- msigdbrSets("Homo sapiens", "H") ## End(Not run)
For each gene, the proportion of samples carrying at least one mutation, with an exact binomial (Clopper-Pearson) confidence interval. The denominator is the number of samples in the object, so genes absent from the mutation table are correctly treated as unmutated.
mutationFrequency( object, genes = NULL, topN = 20, nonsynonymousOnly = TRUE, conf.level = 0.95 )mutationFrequency( object, genes = NULL, topN = 20, nonsynonymousOnly = TRUE, conf.level = 0.95 )
object |
|
genes |
Optional character vector restricting the output. |
topN |
Return only the 'topN' most frequently mutated genes; 'Inf' returns all. |
nonsynonymousOnly |
Restrict to protein-altering variants. |
conf.level |
Confidence level for the interval. |
A 'data.frame' with 'gene', 'n_mutated', 'n_samples', 'frequency', 'ci_lower' and 'ci_upper', ordered by frequency.
ose <- exampleOncoSeq() mutationFrequency(ose, topN = 5)ose <- exampleOncoSeq() mutationFrequency(ose, topN = 5)
Returns a two-level factor giving, for every sample in the object, whether the gene carries a somatic mutation. Samples absent from the mutation table are treated as wild-type, which is correct when the whole cohort was sequenced; check this assumption for cohorts with partial sequencing.
mutationStatus(object, gene, nonsynonymousOnly = TRUE)mutationStatus(object, gene, nonsynonymousOnly = TRUE)
object |
|
gene |
Gene symbol. |
nonsynonymousOnly |
Count only protein-altering variants. |
A factor with levels 'wild-type' and 'mutant', named by sample.
ose <- exampleOncoSeq() table(mutationStatus(ose, "TP53"))ose <- exampleOncoSeq() table(mutationStatus(ose, "TP53"))
Produces per-sample and per-gene summaries of the mutation table: the number of variants, the number of distinct genes or samples affected, and the breakdown by variant classification.
mutationSummary(object, nonsynonymousOnly = TRUE)mutationSummary(object, nonsynonymousOnly = TRUE)
object |
|
nonsynonymousOnly |
Restrict to protein-altering variants. |
A list with elements 'perSample', 'perGene' and 'byClass', each a 'data.frame'.
ose <- exampleOncoSeq() s <- mutationSummary(ose) head(s$perGene)ose <- exampleOncoSeq() s <- mutationSummary(ose) head(s$perGene)
Computes a normalised expression assay and adds it to the object, leaving the raw counts untouched. Count-scale methods wrap the standard implementations in 'edgeR' and 'DESeq2'.
normalizeCounts( object, method = c("logcpm", "cpm", "tmm", "upperquartile", "rle", "vst", "rlog", "log2tpm"), assay = NULL, name = NULL, priorCount = 1, lengthColumn = NULL, blind = TRUE )normalizeCounts( object, method = c("logcpm", "cpm", "tmm", "upperquartile", "rle", "vst", "rlog", "log2tpm"), assay = NULL, name = NULL, priorCount = 1, lengthColumn = NULL, blind = TRUE )
object |
|
method |
Normalisation method; see Details. |
assay |
Name of the count assay to transform. |
name |
Name under which the new assay is stored; defaults to the method name. |
priorCount |
Prior count for the log transformations. |
lengthColumn |
Name of a 'rowData()' column holding feature lengths in bases, required for 'method = "log2tpm"'. |
blind |
Passed to [DESeq2::vst()] / [DESeq2::rlog()]. |
Supported methods:
Counts per million.
log2 counts per million with a prior count.
log2 CPM after trimmed mean of M-values scaling ([edgeR::normLibSizes()]).
log2 CPM after the corresponding 'edgeR' scaling factors.
Variance-stabilising transformation ([DESeq2::vst()]); the standard choice for clustering and principal-component analysis of count data.
Regularised log ([DESeq2::rlog()]); better behaved than 'vst' for small experiments but much slower.
log2 transcripts per million, which requires a feature-length column.
The OncoSeqExperiment with an added assay.
ose <- exampleOncoSeq() ose <- normalizeCounts(ose, method = "logcpm") SummarizedExperiment::assayNames(ose)ose <- exampleOncoSeq() ose <- normalizeCounts(ose, method = "logcpm") SummarizedExperiment::assayNames(ose)
Returns a gene-by-sample character matrix whose entries are the variant classification carried by that gene in that sample, empty where the gene is not mutated. Samples carrying several variants in one gene are labelled '"Multi_Hit"', the convention used by oncoprint renderers.
oncoplotData( object, genes = NULL, topN = 20, nonsynonymousOnly = TRUE, sortSamples = TRUE )oncoplotData( object, genes = NULL, topN = 20, nonsynonymousOnly = TRUE, sortSamples = TRUE )
object |
|
genes |
Genes to include; defaults to the 'topN' most frequently mutated. |
topN |
Number of genes when 'genes' is 'NULL'. |
nonsynonymousOnly |
Restrict to protein-altering variants. |
sortSamples |
Order samples by mutation load, so the staircase pattern of an oncoprint emerges. |
A character matrix with genes in rows and samples in columns, ready for [ComplexHeatmap::oncoPrint()] or [plotOncoprint()].
ose <- exampleOncoSeq() m <- oncoplotData(ose, topN = 5) m[, 1:4]ose <- exampleOncoSeq() m <- oncoplotData(ose, topN = 5) m[, 1:4]
Generic functions defining the OncoSeq accessor interface. Methods are documented with the OncoSeqExperiment class.
mutations(x, ...) mutations(x) <- value cnv(x, ...) cnv(x) <- value analyses(x, ...) analyses(x) <- value provenance(x, ...) provenance(x) <- valuemutations(x, ...) mutations(x) <- value cnv(x, ...) cnv(x) <- value analyses(x, ...) analyses(x) <- value provenance(x, ...) provenance(x) <- value
x |
An OncoSeqExperiment object. |
... |
Further arguments passed to methods. |
value |
Replacement value. |
Accessors return the corresponding layer; replacement functions return the modified object.
ose <- exampleOncoSeq() head(mutations(ose)) cnv(ose) analyses(ose) names(provenance(ose))ose <- exampleOncoSeq() head(mutations(ose)) cnv(ose) analyses(ose) names(provenance(ose))
Builds an OncoSeqExperiment from an expression matrix or an existing SummarizedExperiment, optionally attaching somatic mutations, gene-level copy number and clinical data for the same samples.
OncoSeqExperiment( assays, colData = NULL, rowData = NULL, mutations = NULL, cnv = NULL, provenance = list(), ... )OncoSeqExperiment( assays, colData = NULL, rowData = NULL, mutations = NULL, cnv = NULL, provenance = list(), ... )
assays |
A named list of matrices with genes in rows and samples in columns, or a SummarizedExperiment. When a plain list is given the first element is treated as raw counts and should be named 'counts'. |
colData |
A 'data.frame' or DataFrame of sample annotation whose rows correspond to the columns of 'assays'. Ignored when 'assays' is a SummarizedExperiment. |
rowData |
Optional feature annotation. |
mutations |
Optional somatic variant table in long format with columns 'sample' and 'gene' (see the class documentation). |
cnv |
Optional gene-level copy-number data: a matrix or SummarizedExperiment with samples in columns. |
provenance |
Optional named list describing the data source. |
... |
Further arguments passed to [SummarizedExperiment::SummarizedExperiment()]. |
counts <- matrix(rpois(200, 50), nrow = 20, dimnames = list(paste0("G", 1:20), paste0("S", 1:10))) meta <- data.frame(group = rep(c("tumour", "normal"), each = 5), row.names = colnames(counts)) muts <- data.frame(sample = c("S1", "S2"), gene = c("TP53", "RB1"), variant_class = c("Missense_Mutation", "Nonsense_Mutation")) ose <- OncoSeqExperiment(list(counts = counts), colData = meta, mutations = muts) osecounts <- matrix(rpois(200, 50), nrow = 20, dimnames = list(paste0("G", 1:20), paste0("S", 1:10))) meta <- data.frame(group = rep(c("tumour", "normal"), each = 5), row.names = colnames(counts)) muts <- data.frame(sample = c("S1", "S2"), gene = c("TP53", "RB1"), variant_class = c("Missense_Mutation", "Nonsense_Mutation")) ose <- OncoSeqExperiment(list(counts = counts), colData = meta, mutations = muts) ose
'OncoSeqExperiment' extends SummarizedExperiment so that bulk expression data, somatic mutations, gene-level copy-number alterations, clinical follow-up and the results of every analysis performed on them live in a single object. All layers are keyed on the same sample identifiers, which are the column names of the object; validity checking enforces this.
mutationsA DataFrame of somatic variants in long format, one row per variant per sample. Must contain at least the columns 'sample' and 'gene'; 'variant_class' is used by the summarisation functions when present. Sample identifiers must be a subset of 'colnames(object)'.
cnvA SummarizedExperiment of gene-level copy-number calls (genes in rows, samples in columns), or 'NULL'. The first assay is taken to hold discrete GISTIC-style calls in '-2:2'. Column names must be a subset of 'colnames(object)'.
analysesA SimpleList registry of analysis results. Each element is named and carries an 'analysis' attribute describing how it was produced.
provenanceA list recording the import source and every processing step applied to the object.
'mutations()', 'cnv()', 'analyses()' and 'provenance()' return the corresponding slot; each has a replacement counterpart. All SummarizedExperiment accessors ('assay()', 'colData()', 'rowData()', 'rowRanges()') work unchanged.
'x[i, j]' subsets genes and samples. Subsetting samples also filters the mutation table and the copy-number layer to the retained samples, so the object stays internally consistent.
[OncoSeqExperiment()] to construct an object, [importCounts()] and [importGDC()] to build one from data.
Accessors, replacement methods, subsetting and display for OncoSeqExperiment.
## S4 method for signature 'OncoSeqExperiment' mutations(x, ...) ## S4 replacement method for signature 'OncoSeqExperiment' mutations(x) <- value ## S4 method for signature 'OncoSeqExperiment' cnv(x, ...) ## S4 replacement method for signature 'OncoSeqExperiment' cnv(x) <- value ## S4 method for signature 'OncoSeqExperiment' analyses(x, ...) ## S4 replacement method for signature 'OncoSeqExperiment' analyses(x) <- value ## S4 method for signature 'OncoSeqExperiment' provenance(x, ...) ## S4 replacement method for signature 'OncoSeqExperiment' provenance(x) <- value ## S4 method for signature 'OncoSeqExperiment,ANY,ANY,ANY' x[i, j, ..., drop = FALSE] ## S4 method for signature 'OncoSeqExperiment' show(object)## S4 method for signature 'OncoSeqExperiment' mutations(x, ...) ## S4 replacement method for signature 'OncoSeqExperiment' mutations(x) <- value ## S4 method for signature 'OncoSeqExperiment' cnv(x, ...) ## S4 replacement method for signature 'OncoSeqExperiment' cnv(x) <- value ## S4 method for signature 'OncoSeqExperiment' analyses(x, ...) ## S4 replacement method for signature 'OncoSeqExperiment' analyses(x) <- value ## S4 method for signature 'OncoSeqExperiment' provenance(x, ...) ## S4 replacement method for signature 'OncoSeqExperiment' provenance(x) <- value ## S4 method for signature 'OncoSeqExperiment,ANY,ANY,ANY' x[i, j, ..., drop = FALSE] ## S4 method for signature 'OncoSeqExperiment' show(object)
x, object
|
|
... |
Further arguments, currently unused. |
value |
Replacement value. |
i, j
|
Row (feature) and column (sample) subscripts. |
drop |
Ignored; retained for signature compatibility. |
'mutations()' a DataFrame; 'cnv()' a SummarizedExperiment or 'NULL'; 'analyses()' a SimpleList; 'provenance()' a list; '[' an OncoSeqExperiment; 'show()' is called for its side effect.
ose <- exampleOncoSeq() head(mutations(ose)) cnv(ose) ose[1:5, 1:4]ose <- exampleOncoSeq() head(mutations(ose)) cnv(ose) ose[1:5, 1:4]
Copy-number alteration frequency plot
plotCNVFrequency( object, genes = NULL, topN = 20L, ampThreshold = 2, delThreshold = -2 )plotCNVFrequency( object, genes = NULL, topN = 20L, ampThreshold = 2, delThreshold = -2 )
object |
An OncoSeqExperiment with a copy-number layer. |
genes |
Optional genes to show. |
topN |
Number of genes with the highest alteration frequency. |
ampThreshold, delThreshold
|
Discrete thresholds for gain and loss. |
A 'ggplot' object.
ose <- exampleOncoSeq() plotCNVFrequency(ose, topN = 10)ose <- exampleOncoSeq() plotCNVFrequency(ose, topN = 10)
Bar chart of enrichment results
plotEnrichmentBar(object, name = "gsea", topN = 15L, alpha = NULL)plotEnrichmentBar(object, name = "gsea", topN = 15L, alpha = NULL)
object |
|
name |
Name of a stored [runGSEA()] or [runORA()] result. |
topN |
Number of gene sets to show. |
alpha |
Only sets with an adjusted p-value below this are shown; 'NULL' shows the top sets regardless. |
A 'ggplot' object.
ose <- exampleOncoSeq() ose <- diffExpress(ose, ~ condition, contrast = c("condition", "tumour", "normal"), engine = "edgeR", verbose = FALSE) sets <- readGMT(system.file("extdata", "example_sets.gmt", package = "OncoSeq")) ose <- runGSEA(ose, sets) plotEnrichmentBar(ose, "gsea")ose <- exampleOncoSeq() ose <- diffExpress(ose, ~ condition, contrast = c("condition", "tumour", "normal"), engine = "edgeR", verbose = FALSE) sets <- readGMT(system.file("extdata", "example_sets.gmt", package = "OncoSeq")) ose <- runGSEA(ose, sets) plotEnrichmentBar(ose, "gsea")
Draws a per-feature standardised (z-scored) heatmap of the most variable or explicitly chosen features, with optional sample annotation shown as a strip above the matrix.
plotExpressionHeatmap( object, features = NULL, nTopGenes = 50L, assay = NULL, annotationColumn = NULL, scale = TRUE, clusterSamples = TRUE )plotExpressionHeatmap( object, features = NULL, nTopGenes = 50L, assay = NULL, annotationColumn = NULL, scale = TRUE, clusterSamples = TRUE )
object |
|
features |
Features to draw; defaults to the 'nTopGenes' most variable. |
nTopGenes |
Number of features when 'features' is 'NULL'. |
assay |
Assay to use. |
annotationColumn |
Optional 'colData()' column used to order and annotate samples. |
scale |
Standardise each feature across samples. |
clusterSamples |
Order samples by hierarchical clustering within annotation groups. |
A 'ggplot' object.
ose <- exampleOncoSeq() plotExpressionHeatmap(ose, nTopGenes = 20, annotationColumn = "condition")ose <- exampleOncoSeq() plotExpressionHeatmap(ose, nTopGenes = 20, annotationColumn = "condition")
Draws the survival curves from a [survivalFit()] result, annotated with the log-rank p-value and the number at risk in each group.
plotKM(fit, showPValue = TRUE, palette = NULL, timeLabel = "Time")plotKM(fit, showPValue = TRUE, palette = NULL, timeLabel = "Time")
fit |
An object returned by [survivalFit()]. |
showPValue |
Annotate the panel with the log-rank p-value. |
palette |
Optional vector of colours, one per group. |
timeLabel |
Axis label for follow-up time. |
A 'ggplot' object.
ose <- exampleOncoSeq() plotKM(survivalFit(ose, "TP53", by = "mutation"))ose <- exampleOncoSeq() plotKM(survivalFit(ose, "TP53", by = "mutation"))
Mean-difference (MA) plot of a differential-expression result
plotMAplot(object, deName = "de", alpha = 0.05, lfcThreshold = 0)plotMAplot(object, deName = "de", alpha = 0.05, lfcThreshold = 0)
object |
|
deName |
Name of the stored differential-expression result. |
alpha |
Adjusted-p-value threshold for calling a feature significant. |
lfcThreshold |
Absolute log2 fold-change threshold. |
A 'ggplot' object.
ose <- exampleOncoSeq() ose <- diffExpress(ose, ~ condition, contrast = c("condition", "tumour", "normal"), engine = "edgeR", verbose = FALSE) plotMAplot(ose)ose <- exampleOncoSeq() ose <- diffExpress(ose, ~ condition, contrast = c("condition", "tumour", "normal"), engine = "edgeR", verbose = FALSE) plotMAplot(ose)
Mutation frequency plot with confidence intervals
plotMutationFrequency(object, topN = 20L, nonsynonymousOnly = TRUE)plotMutationFrequency(object, topN = 20L, nonsynonymousOnly = TRUE)
object |
|
topN |
Number of genes to show. |
nonsynonymousOnly |
Restrict to protein-altering variants. |
A 'ggplot' object.
ose <- exampleOncoSeq() plotMutationFrequency(ose, topN = 8)ose <- exampleOncoSeq() plotMutationFrequency(ose, topN = 8)
Tile plot of the matrix returned by [oncoplotData()]: genes in rows, samples in columns, coloured by variant classification, with the per-gene mutation frequency on the right.
plotOncoprint(object, genes = NULL, topN = 20L, nonsynonymousOnly = TRUE)plotOncoprint(object, genes = NULL, topN = 20L, nonsynonymousOnly = TRUE)
object |
|
genes |
Genes to show; defaults to the 'topN' most frequently mutated. |
topN |
Number of genes when 'genes' is 'NULL'. |
nonsynonymousOnly |
Restrict to protein-altering variants. |
A 'ggplot' object.
ose <- exampleOncoSeq() plotOncoprint(ose, topN = 8)ose <- exampleOncoSeq() plotOncoprint(ose, topN = 8)
Projects samples onto their leading principal components, computed from the most variable features of a log-scale assay, and colours them by a sample annotation.
plotSamplePCA( object, colourBy = NULL, shapeBy = NULL, assay = NULL, nTopGenes = 500L, components = c(1L, 2L), label = FALSE )plotSamplePCA( object, colourBy = NULL, shapeBy = NULL, assay = NULL, nTopGenes = 500L, components = c(1L, 2L), label = FALSE )
object |
|
colourBy |
'colData()' column used for point colour. |
shapeBy |
Optional 'colData()' column used for point shape. |
assay |
Assay to use; log2 counts-per-million are derived from counts when no transformed assay is present. |
nTopGenes |
Number of most variable features used. |
components |
Length-two integer vector giving which components to draw. |
label |
Draw sample names next to the points. |
A 'ggplot' object.
ose <- exampleOncoSeq() plotSamplePCA(ose, colourBy = "condition")ose <- exampleOncoSeq() plotSamplePCA(ose, colourBy = "condition")
Volcano plot of a differential-expression result
plotVolcano( object, deName = "de", alpha = 0.05, lfcThreshold = 1, nLabel = 10L, labelGenes = NULL )plotVolcano( object, deName = "de", alpha = 0.05, lfcThreshold = 1, nLabel = 10L, labelGenes = NULL )
object |
|
deName |
Name of the stored differential-expression result. |
alpha |
Adjusted-p-value threshold for calling a feature significant. |
lfcThreshold |
Absolute log2 fold-change threshold. |
nLabel |
Number of top features to label, by adjusted p-value. |
labelGenes |
Explicit features to label, overriding 'nLabel'. |
A 'ggplot' object.
ose <- exampleOncoSeq() ose <- diffExpress(ose, ~ condition, contrast = c("condition", "tumour", "normal"), engine = "edgeR", verbose = FALSE) plotVolcano(ose)ose <- exampleOncoSeq() ose <- diffExpress(ose, ~ condition, contrast = c("condition", "tumour", "normal"), engine = "edgeR", verbose = FALSE) plotVolcano(ose)
Summarises sequencing depth, detection and expression distribution for every sample and, optionally, the fraction of reads assigned to mitochondrial and ribosomal genes. Metrics are written into 'colData()' so that they can be used as covariates or filters downstream.
qcMetrics( object, assay = NULL, detectionThreshold = 0, mitoPattern = "^MT-", riboPattern = "^RP[SL]", store = TRUE )qcMetrics( object, assay = NULL, detectionThreshold = 0, mitoPattern = "^MT-", riboPattern = "^RP[SL]", store = TRUE )
object |
|
assay |
Name of the assay to summarise; defaults to 'counts'. |
detectionThreshold |
A feature counts as detected in a sample when its value exceeds this threshold. |
mitoPattern |
Regular expression identifying mitochondrial genes in the row names. |
riboPattern |
Regular expression identifying ribosomal protein genes. |
store |
When 'TRUE' the metrics are added to 'colData()' and the object is returned; when 'FALSE' the metric table is returned. |
An OncoSeqExperiment with QC columns in 'colData()', or a DataFrame of metrics when 'store = FALSE'.
[filterLowExpression()], [detectOutliers()]
ose <- exampleOncoSeq() ose <- qcMetrics(ose) head(SummarizedExperiment::colData(ose)[, c("library_size", "detected_genes")])ose <- exampleOncoSeq() ose <- qcMetrics(ose) head(SummarizedExperiment::colData(ose)[, c("library_size", "detected_genes")])
Parses a Broad-style GMT file into a named list of character vectors, the format expected by [runGSEA()] and [runORA()].
readGMT(file, minSize = 1L, maxSize = Inf)readGMT(file, minSize = 1L, maxSize = Inf)
file |
Path to a '.gmt' file. |
minSize, maxSize
|
Discard sets outside this size range. |
A named list of gene identifiers.
[msigdbrSets()]
gmt <- system.file("extdata", "example_sets.gmt", package = "OncoSeq") sets <- readGMT(gmt) lengths(sets)gmt <- system.file("extdata", "example_sets.gmt", package = "OncoSeq") sets <- readGMT(gmt) lengths(sets)
Runs [fgsea::fgseaMultilevel()] on features ranked by a statistic taken from a stored differential-expression table. The multilevel algorithm is the current fgsea default and gives accurate p-values far into the tail.
runGSEA( object, geneSets, deName = "de", rankBy = c("signed_log_p", "stat", "log2FC"), minSize = 5L, maxSize = 500L, name = "gsea", BPPARAM = BiocParallel::SerialParam(), ... )runGSEA( object, geneSets, deName = "de", rankBy = c("signed_log_p", "stat", "log2FC"), minSize = 5L, maxSize = 500L, name = "gsea", BPPARAM = BiocParallel::SerialParam(), ... )
object |
An OncoSeqExperiment holding a differential-expression result. |
geneSets |
A named list of gene identifiers; see [readGMT()]. |
deName |
Name of the stored differential-expression result. |
rankBy |
Statistic used to rank features. '"signed_log_p"' is 'sign(log2FC) * -log10(pvalue)', which separates direction from magnitude better than the fold change alone; '"log2FC"' and '"stat"' are also available. |
minSize, maxSize
|
Gene-set size limits. |
name |
Name under which the result is stored. |
BPPARAM |
A BiocParallelParam instance controlling parallelisation. The default is serial evaluation, which is reproducible and avoids the socket set-up that fails in sandboxed environments; pass [BiocParallel::MulticoreParam()] to use several cores. |
... |
Further arguments passed to [fgsea::fgseaMultilevel()]. |
The object with a result table stored in the registry, carrying columns 'set', 'size', 'ES', 'NES', 'pvalue', 'padj', 'leadingEdge' and 'method', ordered by adjusted p-value.
[runORA()], [plotEnrichment()]
ose <- exampleOncoSeq() ose <- diffExpress(ose, ~ condition, contrast = c("condition", "tumour", "normal"), engine = "edgeR", verbose = FALSE) sets <- readGMT(system.file("extdata", "example_sets.gmt", package = "OncoSeq")) ose <- runGSEA(ose, sets) head(getAnalysis(ose, "gsea")[, c("set", "NES", "padj")])ose <- exampleOncoSeq() ose <- diffExpress(ose, ~ condition, contrast = c("condition", "tumour", "normal"), engine = "edgeR", verbose = FALSE) sets <- readGMT(system.file("extdata", "example_sets.gmt", package = "OncoSeq")) ose <- runGSEA(ose, sets) head(getAnalysis(ose, "gsea")[, c("set", "NES", "padj")])
Executes the standard sequence of steps on an existing object: quality metrics, low-expression filtering, normalisation, differential expression, enrichment, mutation burden and a survival screen, storing every result in the analysis registry. Steps whose prerequisites are absent are skipped with a message rather than failing, so the same call works on expression-only and full multi-omic objects.
runOncoSeq( object, design, contrast = NULL, geneSets = NULL, engine = c("DESeq2", "edgeR", "limma"), normalisation = "vst", survivalGenes = NULL, timeColumn = "os_time", eventColumn = "os_event", alpha = 0.05, verbose = TRUE )runOncoSeq( object, design, contrast = NULL, geneSets = NULL, engine = c("DESeq2", "edgeR", "limma"), normalisation = "vst", survivalGenes = NULL, timeColumn = "os_time", eventColumn = "os_event", alpha = 0.05, verbose = TRUE )
object |
|
design |
A one-sided formula for the differential-expression model. |
contrast |
Contrast specification; see [diffExpress()]. |
geneSets |
Optional named list of gene sets enabling the enrichment step. |
engine |
Differential-expression engine. |
normalisation |
Normalisation method passed to [normalizeCounts()]. |
survivalGenes |
Genes to carry through [survivalScreen()]; 'NULL' screens every feature, which is slow on a full transcriptome. |
timeColumn, eventColumn
|
Survival columns in 'colData()'. |
alpha |
Significance threshold used throughout. |
verbose |
Report progress. |
The OncoSeqExperiment with results stored under the names 'de', 'gsea', 'ora' and 'survival_screen', QC columns in 'colData()' and the normalised assay added.
[diffExpress()], [runGSEA()], [survivalScreen()]
ose <- exampleOncoSeq() sets <- readGMT(system.file("extdata", "example_sets.gmt", package = "OncoSeq")) res <- runOncoSeq(ose, ~ condition, contrast = c("condition", "tumour", "normal"), geneSets = sets, engine = "edgeR", verbose = FALSE) names(analyses(res))ose <- exampleOncoSeq() sets <- readGMT(system.file("extdata", "example_sets.gmt", package = "OncoSeq")) res <- runOncoSeq(ose, ~ condition, contrast = c("condition", "tumour", "normal"), geneSets = sets, engine = "edgeR", verbose = FALSE) names(analyses(res))
Tests whether each gene set is over-represented among the significant features of a stored differential-expression result, using the hypergeometric distribution with the tested features as the universe and Benjamini-Hochberg correction across sets.
runORA( object, geneSets, deName = "de", alpha = 0.05, lfcThreshold = 0, direction = c("both", "up", "down"), universe = NULL, minSize = 5L, maxSize = 500L, name = "ora" )runORA( object, geneSets, deName = "de", alpha = 0.05, lfcThreshold = 0, direction = c("both", "up", "down"), universe = NULL, minSize = 5L, maxSize = 500L, name = "ora" )
object |
|
geneSets |
A named list of gene identifiers. |
deName |
Name of the stored differential-expression result. |
alpha |
Adjusted-p-value cut-off defining the significant list. |
lfcThreshold |
Minimum absolute log2 fold change for inclusion. |
direction |
Restrict the list to '"up"', '"down"' or '"both"'. |
universe |
Character vector of background features; defaults to all features in the differential-expression table, which is the correct universe because only those were testable. |
minSize, maxSize
|
Gene-set size limits, applied after intersecting each set with the universe. |
name |
Name under which the result is stored. |
The object with a result table in the registry, carrying 'set', 'size', 'overlap', 'expected', 'foldEnrichment', 'pvalue', 'padj', 'genes' and 'method'.
[runGSEA()]
ose <- exampleOncoSeq() ose <- diffExpress(ose, ~ condition, contrast = c("condition", "tumour", "normal"), engine = "edgeR", verbose = FALSE) sets <- readGMT(system.file("extdata", "example_sets.gmt", package = "OncoSeq")) ose <- runORA(ose, sets, alpha = 0.1) head(getAnalysis(ose, "ora")[, c("set", "overlap", "padj")])ose <- exampleOncoSeq() ose <- diffExpress(ose, ~ condition, contrast = c("condition", "tumour", "normal"), engine = "edgeR", verbose = FALSE) sets <- readGMT(system.file("extdata", "example_sets.gmt", package = "OncoSeq")) ose <- runORA(ose, sets, alpha = 0.1) head(getAnalysis(ose, "ora")[, c("set", "overlap", "padj")])
The object returned by [exampleOncoSeq()]: 300 features by 40 samples, 20 simulated tumours and 20 simulated normals, with counts, somatic mutations, gene-level copy number and overall survival. The values are simulated; see [exampleOncoSeq()] for the generative model and 'data-raw/make-simExample.R' for the code that produced it.
data(simExample)data(simExample)
An OncoSeqExperiment with 300 features and 40 samples.
Simulated by 'data-raw/make-simExample.R'.
[blcaExample] for a real cohort.
data(simExample) simExampledata(simExample) simExample
Splits samples into groups by expression, mutation status, copy-number state or a clinical variable, fits Kaplan-Meier curves and tests them with the log-rank statistic, and reports the hazard ratio from the corresponding Cox model.
survivalFit( object, feature, by = c("auto", "expression", "mutation", "cnv", "clinical"), split = c("median", "tertile", "quartile", "optimal"), timeColumn = "os_time", eventColumn = "os_event", assay = NULL, minGroupSize = 5L )survivalFit( object, feature, by = c("auto", "expression", "mutation", "cnv", "clinical"), split = c("median", "tertile", "quartile", "optimal"), timeColumn = "os_time", eventColumn = "os_event", assay = NULL, minGroupSize = 5L )
object |
|
feature |
Gene identifier or 'colData()' column name to stratify on. |
by |
Layer the feature belongs to: '"expression"', '"mutation"', '"cnv"', '"clinical"', or '"auto"' to search them in that order. |
split |
Grouping rule for continuous features: '"median"', '"tertile"', '"quartile"' or '"optimal"'. |
timeColumn, eventColumn
|
'colData()' columns holding follow-up time and the event indicator (1 = event, 0 = censored). |
assay |
Expression assay to use; log-scale values are derived from counts when needed. |
minGroupSize |
Refuse to test when a group is smaller than this. |
For expression the split may be at the median, by tertiles, by quartiles (comparing the outer two), or at an optimal cut-point. The optimal cut-point scans candidate thresholds between the 25th and 75th percentiles and keeps the one maximising the log-rank statistic. That search inflates significance, so the reported 'p_logrank_adjusted' applies the Altman approximation; the unadjusted value is reported alongside it and should not be quoted on its own.
A list of class 'oncoseq_survival' with the 'survfit' object, the grouping factor, the log-rank test, the Cox hazard ratio with confidence interval, and the cut-point when one was chosen.
[coxModel()], [survivalScreen()], [plotKM()]
ose <- exampleOncoSeq() fit <- survivalFit(ose, "TP53", by = "mutation") fit$p_logrankose <- exampleOncoSeq() fit <- survivalFit(ose, "TP53", by = "mutation") fit$p_logrank
Fits a Cox proportional-hazards model for every gene, with expression as a continuous covariate and optional clinical adjustment, and corrects the resulting p-values across genes with Benjamini-Hochberg.
survivalScreen( object, genes = NULL, covariates = NULL, timeColumn = "os_time", eventColumn = "os_event", assay = NULL, scale = TRUE, minVariance = 0, name = "survival_screen" )survivalScreen( object, genes = NULL, covariates = NULL, timeColumn = "os_time", eventColumn = "os_event", assay = NULL, scale = TRUE, minVariance = 0, name = "survival_screen" )
object |
|
genes |
Genes to test; defaults to all features. |
covariates |
Optional clinical covariates to adjust for. |
timeColumn, eventColumn
|
Follow-up and event columns. |
assay |
Expression assay; log-scale values are derived from counts when needed. |
scale |
Standardise each gene before fitting, so that the hazard ratio refers to a one standard-deviation increase and is comparable across genes. |
minVariance |
Skip genes whose variance is at or below this value. |
name |
Name under which the result is stored; 'NULL' returns the table. |
The object with a table of 'gene', 'HR', 'ci_lower', 'ci_upper', 'z', 'pvalue' and 'padj', ordered by adjusted p-value.
ose <- exampleOncoSeq() res <- survivalScreen(ose, genes = rownames(ose)[1:50], name = NULL) head(res)ose <- exampleOncoSeq() res <- survivalScreen(ose, genes = rownames(ose)[1:50], name = NULL) head(res)
Non-synonymous somatic variants per megabase of sequenced territory for every sample. The default capture size of 38 Mb is the figure conventionally used for whole-exome panels; supply the actual footprint of your assay when it is known.
tumourMutationBurden( object, captureSize = 38, nonsynonymousOnly = TRUE, store = TRUE )tumourMutationBurden( object, captureSize = 38, nonsynonymousOnly = TRUE, store = TRUE )
object |
|
captureSize |
Size of the sequenced territory in megabases. |
nonsynonymousOnly |
Restrict to protein-altering variants. |
store |
Add a 'tmb' column to 'colData()' and return the object. |
The object with a 'tmb' column, or a 'data.frame' of burdens when 'store = FALSE'.
ose <- exampleOncoSeq() tmb <- tumourMutationBurden(ose, store = FALSE) summary(tmb$tmb)ose <- exampleOncoSeq() tmb <- tumourMutationBurden(ose, store = FALSE) summary(tmb$tmb)