Get started by trying out MultiAssayExperiment
using a subset of the TCGA adrenocortical carcinoma (ACC) dataset provided with the package. This dataset provides five assays on 92 patients, although all five assays were not performed for every patient:
suppressPackageStartupMessages({
library(MultiAssayExperiment)
library(S4Vectors)
})
data(miniACC)
miniACC
## A MultiAssayExperiment object of 5 listed
## experiments with user-defined names and respective classes.
## Containing an ExperimentList class object of length 5:
## [1] RNASeq2GeneNorm: ExpressionSet with 198 rows and 79 columns
## [2] gistict: SummarizedExperiment with 198 rows and 90 columns
## [3] RPPAArray: ExpressionSet with 33 rows and 46 columns
## [4] Mutations: matrix with 97 rows and 90 columns
## [5] miRNASeqGene: ExpressionSet with 471 rows and 80 columns
## Features:
## experiments() - obtain the ExperimentList instance
## colData() - the primary/phenotype DataFrame
## sampleMap() - the sample availability DataFrame
## `$`, `[`, `[[` - extract colData columns, subset, or experiment
## *Format() - convert into a long or wide DataFrame
## assays() - convert ExperimentList to a SimpleList of matrices
This slot is a DataFrame
describing the characteristics of biological units, for example clinical data for patients. In the prepared datasets from The Cancer Genome Atlas, each row is one patient and each column is a clinical, pathological, subtype, or other variable. The $
function provides a shortcut for accessing or setting colData
columns.
colData(miniACC)[1:4, 1:4]
## DataFrame with 4 rows and 4 columns
## patientID years_to_birth vital_status days_to_death
## <character> <integer> <integer> <integer>
## TCGA-OR-A5J1 TCGA-OR-A5J1 58 1 1355
## TCGA-OR-A5J2 TCGA-OR-A5J2 44 1 1677
## TCGA-OR-A5J3 TCGA-OR-A5J3 23 0 NA
## TCGA-OR-A5J4 TCGA-OR-A5J4 23 1 423
table(miniACC$race)
##
## asian black or african american
## 2 1
## white
## 78
Key points:
ExperimentList
, below.A base list
or ExperimentList
object containing the experimental datasets for the set of samples collected. This gets converted into a class ExperimentList
during construction.
experiments(miniACC)
## ExperimentList class object of length 5:
## [1] RNASeq2GeneNorm: ExpressionSet with 198 rows and 79 columns
## [2] gistict: SummarizedExperiment with 198 rows and 90 columns
## [3] RPPAArray: ExpressionSet with 33 rows and 46 columns
## [4] Mutations: matrix with 97 rows and 90 columns
## [5] miRNASeqGene: ExpressionSet with 471 rows and 80 columns
Key points:
RaggedExperiment
package)colData
: in other words, you must know which patient or cell line the observation came from. However, multiple columns can come from the same patient, or there can be no data for that patient.ExperimentList
elements can be genomic range-based (e.g. SummarizedExperiment::RangedSummarizedExperiment-class
or RaggedExperiment::RaggedExperiment-class
) or ID-based data (e.g. SummarizedExperiment::SummarizedExperiment-class
, Biobase::eSet-class
base::matrix-class
, DelayedArray::DelayedArray-class
, and derived classes)ExperimentList
, as long as it supports: single-bracket subsetting ([
), dimnames
, and dim
. Most data classes defined in Bioconductor meet these requirements.sampleMap
is a graph representation of the relationship between biological units and experimental results. In simple cases where the column names of ExperimentList
data matrices match the row names of colData
, the user won’t need to specify or think about a sample map, it can be created automatically by the MultiAssayExperiment
constructor. sampleMap
is a simple three-column DataFrame
:
assay
column: the name of the assay, and found in the names of ExperimentList
list namesprimary
column: identifiers of patients or biological units, and found in the row names of colData
colname
column: identifiers of assay results, and found in the column names of ExperimentList
elements Helper functions are available for creating a map from a list. See ?listToMap
sampleMap(miniACC)
## DataFrame with 385 rows and 3 columns
## assay primary colname
## <factor> <character> <character>
## 1 RNASeq2GeneNorm TCGA-OR-A5J1 TCGA-OR-A5J1-01A-11R-A29S-07
## 2 RNASeq2GeneNorm TCGA-OR-A5J2 TCGA-OR-A5J2-01A-11R-A29S-07
## 3 RNASeq2GeneNorm TCGA-OR-A5J3 TCGA-OR-A5J3-01A-11R-A29S-07
## 4 RNASeq2GeneNorm TCGA-OR-A5J5 TCGA-OR-A5J5-01A-11R-A29S-07
## 5 RNASeq2GeneNorm TCGA-OR-A5J6 TCGA-OR-A5J6-01A-31R-A29S-07
## ... ... ... ...
## 381 miRNASeqGene TCGA-PA-A5YG TCGA-PA-A5YG-01A-11R-A29W-13
## 382 miRNASeqGene TCGA-PK-A5H8 TCGA-PK-A5H8-01A-11R-A29W-13
## 383 miRNASeqGene TCGA-PK-A5H9 TCGA-PK-A5H9-01A-11R-A29W-13
## 384 miRNASeqGene TCGA-PK-A5HA TCGA-PK-A5HA-01A-11R-A29W-13
## 385 miRNASeqGene TCGA-PK-A5HB TCGA-PK-A5HB-01A-11R-A29W-13
Key points:
colnames
) to colData
Metadata can be used to keep additional information about patients, assays performed on individuals or on the entire cohort, or features such as genes, proteins, and genomic ranges. There are many options available for storing metadata. First, MultiAssayExperiment
has its own metadata for describing the entire experiment:
metadata(miniACC)
## $title
## [1] "Comprehensive Pan-Genomic Characterization of Adrenocortical Carcinoma"
##
## $PMID
## [1] "27165744"
##
## $sourceURL
## [1] "http://s3.amazonaws.com/multiassayexperiments/accMAEO.rds"
##
## $RPPAfeatureDataURL
## [1] "http://genomeportal.stanford.edu/pan-tcga/show_target_selection_file?filename=Allprotein.txt"
##
## $colDataExtrasURL
## [1] "http://www.cell.com/cms/attachment/2062093088/2063584534/mmc3.xlsx"
Additionally, the DataFrame
class used by sampleMap
and colData
, as well as the ExperimentList
class, similarly support metadata. Finally, many experimental data objects that can be used in the ExperimentList
support metadata. These provide flexible options to users and to developers of derived classes.
[
In pseudo code below, the subsetting operations work on the rows of the following indices: 1. i experimental data rows 2. j the primary names or the column names (entered as a list
or List
) 3. k assay
multiassayexperiment[i = rownames, j = primary or colnames, k = assay]
Subsetting operations always return another MultiAssayExperiment
. For example, the following will return any rows named “MAPK14” or “IGFBP2”, and remove any assays where no rows match:
miniACC[c("MAPK14", "IGFBP2"), , ]
The following will keep only patients of pathological stage iv, and all their associated assays:
miniACC[, miniACC$pathologic_stage == "stage iv", ]
## harmonizing input:
## removing 311 sampleMap rows with 'colname' not in colnames of experiments
## removing 74 colData rownames not in sampleMap 'primary'
And the following will keep only the RNA-seq dataset, and only patients for which this assay is available:
miniACC[, , "RNASeq2GeneNorm"]
## harmonizing input:
## removing 13 colData rownames not in sampleMap 'primary'
If any ExperimentList objects have features represented by genomic ranges (e.g. RangedSummarizedExperiment
, RaggedExperiment
), then a GRanges
object in the first subsetting position will subset these objects as in GenomicRanges::findOverlaps()
.
[[
The “double bracket” method ([[
) is a convenience function for extracting a single element of the MultiAssayExperiment
ExperimentList
. It avoids the use of experiments(mae)[[1L]]
. For example, both of the following extract the ExpressionSet
object containing RNA-seq data:
miniACC[[1L]] #or equivalently, miniACC[["RNASeq2GeneNorm"]]
## ExpressionSet (storageMode: lockedEnvironment)
## assayData: 198 features, 79 samples
## element names: exprs
## protocolData: none
## phenoData: none
## featureData: none
## experimentData: use 'experimentData(object)'
## Annotation:
complete.cases()
shows which patients have complete data for all assays:
summary(complete.cases(miniACC))
## Mode FALSE TRUE
## logical 49 43
The above logical vector could be used for patient subsetting. More simply, intersectColumns()
will select complete cases and rearrange each ExperimentList
element so its columns correspond exactly to rows of colData
in the same order:
accmatched = intersectColumns(miniACC)
## harmonizing input:
## removing 170 sampleMap rows with 'colname' not in colnames of experiments
## removing 49 colData rownames not in sampleMap 'primary'
Note, the column names of the assays in accmatched
are not the same because of assay-specific identifiers, but they have been automatically re-arranged to correspond to the same patients. In these TCGA assays, the first three -
delimited positions correspond to patient, ie the first patient is TCGA-OR-A5J2:
colnames(accmatched)
## CharacterList of length 5
## [["RNASeq2GeneNorm"]] TCGA-OR-A5J2-01A-11R-A29S-07 ...
## [["gistict"]] TCGA-OR-A5J2-01A-11D-A29H-01 ...
## [["RPPAArray"]] TCGA-OR-A5J2-01A-21-A39K-20 ...
## [["Mutations"]] TCGA-OR-A5J2-01A-11D-A29I-10 ...
## [["miRNASeqGene"]] TCGA-OR-A5J2-01A-11R-A29W-13 ...
intersectRows()
keeps only rows that are common to each assay, and aligns them in identical order. For example, to keep only genes where data are available for RNA-seq, GISTIC copy number, and somatic mutations:
accmatched2 <- intersectRows(miniACC[, , c("RNASeq2GeneNorm", "gistict", "Mutations")])
rownames(accmatched2)
## CharacterList of length 3
## [["RNASeq2GeneNorm"]] DIRAS3 G6PD KDR ERBB3 ... RET CDKN2A MACC1 CHGA
## [["gistict"]] DIRAS3 G6PD KDR ERBB3 AKT1S1 ... PREX1 RET CDKN2A MACC1 CHGA
## [["Mutations"]] DIRAS3 G6PD KDR ERBB3 AKT1S1 ... RET CDKN2A MACC1 CHGA
The assay
and assays
methods follow SummarizedExperiment
convention. The assay
(singular) method will extract the first element of the ExperimentList
and will return a matrix
.
class(assay(miniACC))
## [1] "matrix"
The assays
(plural) method will return a SimpleList
of the data with each element being a matrix
.
assays(miniACC)
## List of length 5
## names(5): RNASeq2GeneNorm gistict RPPAArray Mutations miRNASeqGene
Key point:
[[
returned an assay as its original class, assay()
and assays()
convert the assay data to matrix form.Slot in the MultiAssayExperiment
can be accessed or set using their accessor functions:
Slot | Accessor |
---|---|
ExperimentList |
experiments() |
colData |
colData() and $ * |
sampleMap |
sampleMap() |
metadata |
metadata() |
__*__ The $
operator on a MultiAssayExperiment
returns a single column of the colData
.
The longFormat
or wideFormat
functions will “reshape” and combine experiments with each other and with colData
into one DataFrame
. These functions provide compatibility with most of the common R/Bioconductor functions for regression, machine learning, and visualization.
longFormat
In long format a single column provides all assay results, with additional optional colData
columns whose values are repeated as necessary. Here assay is the name of the ExperimentList element, primary is the patient identifier (rowname of colData), rowname is the assay rowname (in this case genes), colname is the assay-specific identifier (column name), value is the numeric measurement (gene expression, copy number, presence of a non-silent mutation, etc), and following these are the vital_status and days_to_death colData columns that have been added:
longFormat(miniACC[c("TP53", "CTNNB1"), , ],
colDataCols = c("vital_status", "days_to_death"))
## DataFrame with 518 rows and 7 columns
## assay primary rowname colname
## <Rle> <Rle> <character> <Rle>
## 1 RNASeq2GeneNorm TCGA-OR-A5J1 TP53 TCGA-OR-A5J1-01A-11R-A29S-07
## 2 RNASeq2GeneNorm TCGA-OR-A5J1 CTNNB1 TCGA-OR-A5J1-01A-11R-A29S-07
## 3 RNASeq2GeneNorm TCGA-OR-A5J2 TP53 TCGA-OR-A5J2-01A-11R-A29S-07
## 4 RNASeq2GeneNorm TCGA-OR-A5J2 CTNNB1 TCGA-OR-A5J2-01A-11R-A29S-07
## 5 RNASeq2GeneNorm TCGA-OR-A5J3 TP53 TCGA-OR-A5J3-01A-11R-A29S-07
## ... ... ... ... ...
## 514 Mutations TCGA-PK-A5HA CTNNB1 TCGA-PK-A5HA-01A-11D-A29I-10
## 515 Mutations TCGA-PK-A5HB TP53 TCGA-PK-A5HB-01A-11D-A29I-10
## 516 Mutations TCGA-PK-A5HB CTNNB1 TCGA-PK-A5HB-01A-11D-A29I-10
## 517 Mutations TCGA-PK-A5HC TP53 TCGA-PK-A5HC-01A-11D-A30A-10
## 518 Mutations TCGA-PK-A5HC CTNNB1 TCGA-PK-A5HC-01A-11D-A30A-10
## value vital_status days_to_death
## <numeric> <integer> <integer>
## 1 563.4006 1 1355
## 2 5634.4669 1 1355
## 3 165.4811 1 1677
## 4 62658.3913 1 1677
## 5 956.3028 0 NA
## ... ... ... ...
## 514 0 0 NA
## 515 0 0 NA
## 516 0 0 NA
## 517 0 0 NA
## 518 0 0 NA
wideFormat
In wide format, each feature from each assay goes in a separate column, with one row per primary identifier (patient). Here, each variable becomes a new column:
wideFormat(miniACC[c("TP53", "CTNNB1"), , ],
colDataCols = c("vital_status", "days_to_death"))
## DataFrame with 92 rows and 9 columns
## primary vital_status days_to_death Mutations_CTNNB1
## <factor> <integer> <integer> <numeric>
## 1 TCGA-OR-A5J1 1 1355 0
## 2 TCGA-OR-A5J2 1 1677 1
## 3 TCGA-OR-A5J3 0 NA 0
## 4 TCGA-OR-A5J4 1 423 0
## 5 TCGA-OR-A5J5 1 365 0
## ... ... ... ... ...
## 88 TCGA-PK-A5H8 0 NA 0
## 89 TCGA-PK-A5H9 0 NA 0
## 90 TCGA-PK-A5HA 0 NA 0
## 91 TCGA-PK-A5HB 0 NA 0
## 92 TCGA-PK-A5HC 0 NA 0
## Mutations_TP53 RNASeq2GeneNorm_CTNNB1 RNASeq2GeneNorm_TP53
## <numeric> <numeric> <numeric>
## 1 0 5634.467 563.4006
## 2 1 62658.391 165.4811
## 3 0 6337.426 956.3028
## 4 0 NA NA
## 5 0 5979.055 1169.6359
## ... ... ... ...
## 88 0 3033.648 737.6640
## 89 0 5258.986 890.8663
## 90 0 8120.165 683.5722
## 91 0 5257.815 237.3697
## 92 0 NA NA
## gistict_CTNNB1 gistict_TP53
## <numeric> <numeric>
## 1 0 0
## 2 1 0
## 3 0 0
## 4 0 1
## 5 0 0
## ... ... ...
## 88 NA NA
## 89 0 0
## 90 0 -1
## 91 -1 -1
## 92 1 1
The MultiAssayExperiment
constructor function can take three arguments:
experiments
- An ExperimentList
or list
of datacolData
- A DataFrame
describing the patients (or cell lines, or other biological units)sampleMap
- A DataFrame
of assay
, primary
, and colname
identifiersThe miniACC object can be reconstructed as follows:
MultiAssayExperiment(experiments=experiments(miniACC),
colData=colData(miniACC),
sampleMap=sampleMap(miniACC),
metadata=metadata(miniACC))
## A MultiAssayExperiment object of 5 listed
## experiments with user-defined names and respective classes.
## Containing an ExperimentList class object of length 5:
## [1] RNASeq2GeneNorm: ExpressionSet with 198 rows and 79 columns
## [2] gistict: SummarizedExperiment with 198 rows and 90 columns
## [3] RPPAArray: ExpressionSet with 33 rows and 46 columns
## [4] Mutations: matrix with 97 rows and 90 columns
## [5] miRNASeqGene: ExpressionSet with 471 rows and 80 columns
## Features:
## experiments() - obtain the ExperimentList instance
## colData() - the primary/phenotype DataFrame
## sampleMap() - the sample availability DataFrame
## `$`, `[`, `[[` - extract colData columns, subset, or experiment
## *Format() - convert into a long or wide DataFrame
## assays() - convert ExperimentList to a SimpleList of matrices
prepMultiAssay
- Constructor function helperThe prepMultiAssay
function allows the user to diagnose typical problems when creating a MultiAssayExperiment
object. See ?prepMultiAssay
for more details.
c
- concatenate to MultiAssayExperimentThe c
function allows the user to concatenate an additional experiment to an existing MultiAssayExperiment
. The optional sampleMap
argument allows concatenating an assay whose column names do not match the row names of colData
. For convenience, the mapFrom argument allows the user to map from a particular experiment provided that the order of the colnames is in the same. A warning
will be issued to make the user aware of this assumption. For example, to concatenate a matrix of log2-transformed RNA-seq results:
miniACC2 <- c(miniACC, log2rnaseq = log2(assays(miniACC)$RNASeq2GeneNorm), mapFrom=1L)
## Warning in .local(x, ...): Assuming column order in the data provided
## matches the order in 'mapFrom' experiment(s) colnames
experiments(miniACC2)
## ExperimentList class object of length 6:
## [1] RNASeq2GeneNorm: ExpressionSet with 198 rows and 79 columns
## [2] gistict: SummarizedExperiment with 198 rows and 90 columns
## [3] RPPAArray: ExpressionSet with 33 rows and 46 columns
## [4] Mutations: matrix with 97 rows and 90 columns
## [5] miRNASeqGene: ExpressionSet with 471 rows and 80 columns
## [6] log2rnaseq: matrix with 198 rows and 79 columns
Solution
The built-in upsetSamples
creates an “upset” Venn diagram to answer this question:
upsetSamples(miniACC)
## Loading required namespace: UpSetR
In this dataset only 43 samples have all 5 assays, 32 are missing reverse-phase protein (RPPAArray), 2 are missing Mutations, 1 is missing gistict, 12 have only mutations and gistict, etc.
Create a Kaplan-meier plot, using pathology_N_stage as a stratifying variable.
Solution
The colData provides clinical data for things like a Kaplan-Meier plot for overall survival stratified by nodal stage.
suppressPackageStartupMessages({
library(survival)
library(survminer)
})
Surv(miniACC$days_to_death, miniACC$vital_status)
## [1] 1355 1677 NA+ 423 365 NA+ 490 579 NA+ 922 551
## [12] 1750 NA+ 2105 NA+ 541 NA+ NA+ 490 NA+ NA+ 562
## [23] NA+ NA+ NA+ NA+ NA+ NA+ 289 NA+ NA+ NA+ 552
## [34] NA+ NA+ NA+ 994 NA+ NA+ 498 NA+ NA+ 344 NA+
## [45] NA+ NA+ NA+ NA+ NA+ NA+ NA+ NA+ NA+ 391 125
## [56] NA+ 1852 NA+ NA+ NA+ NA+ NA+ NA+ NA+ 1204 159
## [67] 1197 662 445 NA+ 2385 436 1105 NA+ 1613 NA+ NA+
## [78] 2405 NA+ NA+ NA+ NA+ NA+ 207 0 NA+ NA+ NA+
## [89] NA+ NA+ NA+ 383
And remove any patients missing overall survival information:
miniACCsurv <- miniACC[, complete.cases(miniACC$days_to_death, miniACC$vital_status), ]
## harmonizing input:
## removing 248 sampleMap rows with 'colname' not in colnames of experiments
## removing 58 colData rownames not in sampleMap 'primary'
fit <- survfit(Surv(days_to_death, vital_status) ~ pathology_N_stage, data = colData(miniACCsurv))
ggsurvplot(fit, data = colData(miniACCsurv), risk.table = TRUE)
Choose the EZH2 gene for demonstration. This subsetting will drop assays with no row named EZH2:
wideacc = wideFormat(miniACC["EZH2", , ],
colDataCols=c("vital_status", "days_to_death", "pathology_N_stage"))
wideacc$y = Surv(wideacc$days_to_death, wideacc$vital_status)
head(wideacc)
## DataFrame with 6 rows and 7 columns
## primary vital_status days_to_death pathology_N_stage
## <factor> <integer> <integer> <character>
## 1 TCGA-OR-A5J1 1 1355 n0
## 2 TCGA-OR-A5J2 1 1677 n0
## 3 TCGA-OR-A5J3 0 NA n0
## 4 TCGA-OR-A5J4 1 423 n1
## 5 TCGA-OR-A5J5 1 365 n0
## 6 TCGA-OR-A5J6 0 NA n0
## RNASeq2GeneNorm_EZH2 gistict_EZH2 y
## <numeric> <numeric> <Surv>
## 1 75.8886 0 1355:1
## 2 326.5332 1 1677:1
## 3 190.1940 1 NA:0
## 4 NA -2 423:1
## 5 366.3826 1 365:1
## 6 30.7371 1 NA:0
Perform a multivariate Cox regression with EZH2 copy number (gistict), log2-transformed EZH2 expression (RNASeq2GeneNorm), and nodal status (pathology_N_stage) as predictors:
coxph(Surv(days_to_death, vital_status) ~ gistict_EZH2 + log2(RNASeq2GeneNorm_EZH2) + pathology_N_stage,
data=wideacc)
## Call:
## coxph(formula = Surv(days_to_death, vital_status) ~ gistict_EZH2 +
## log2(RNASeq2GeneNorm_EZH2) + pathology_N_stage, data = wideacc)
##
## coef exp(coef) se(coef) z p
## gistict_EZH2 -0.0372 0.9635 0.2821 -0.13 0.89499
## log2(RNASeq2GeneNorm_EZH2) 0.9773 2.6573 0.2811 3.48 0.00051
## pathology_N_stagen1 0.3775 1.4586 0.5699 0.66 0.50774
##
## Likelihood ratio test=16.3 on 3 df, p=0.000994
## n= 26, number of events= 26
## (66 observations deleted due to missingness)
We see that EZH2 expression is significantly associated with overal survival (p < 0.001), but EZH2 copy number and nodal status are not. This analysis could easily be extended to the whole genome for discovery of prognostic features by repeated univariate regressions over columns, penalized multivariate regression, etc.
For further detail, see the main MultiAssayExperiment vignette.
Part 1
For all genes where there is both recurrent copy number (gistict assay) and RNA-seq, calculate the correlation between log2(RNAseq + 1) and copy number. Create a histogram of these correlations. Compare this with the histogram of correlations between all unmatched gene - copy number pairs.
Solution
First, narrow down miniACC
to only the assays needed:
subacc <- miniACC[, , c("RNASeq2GeneNorm", "gistict")]
Align the rows and columns, keeping only samples with both assays available:
subacc <- intersectColumns(subacc)
## harmonizing input:
## removing 15 sampleMap rows with 'colname' not in colnames of experiments
## removing 15 colData rownames not in sampleMap 'primary'
subacc <- intersectRows(subacc)
Create a list of numeric matrices:
subacc.list <- assays(subacc)
Log-transform the RNA-seq assay:
subacc.list[[1]] <- log2(subacc.list[[1]] + 1)
Transpose both, so genes are in columns:
subacc.list <- lapply(subacc.list, t)
Calculate the correlation between columns in the first matrix and columns in the second matrix:
corres <- cor(subacc.list[[1]], subacc.list[[2]])
And finally, create the histograms:
hist(diag(corres))
hist(corres[upper.tri(corres)])
Part 2
For the gene with highest correlation to copy number, make a box plot of log2 expression against copy number.
Solution
First, identify the gene with highest correlation between expression and copy number:
which.max(diag(corres))
## EIF4E
## 91
You could now make the plot by taking the EIF4E columns from each element of the list subacc.list list that was extracted from the subacc MultiAssayExperiment, but let’s do it by subsetting and extracting from the MultiAssayExperiment:
df <- wideFormat(subacc["EIF4E", , ])
head(df)
## DataFrame with 6 rows and 3 columns
## primary RNASeq2GeneNorm_EIF4E gistict_EIF4E
## <factor> <numeric> <numeric>
## 1 TCGA-OR-A5J1 460.6148 0
## 2 TCGA-OR-A5J2 371.2252 0
## 3 TCGA-OR-A5J3 516.0717 0
## 4 TCGA-OR-A5J5 1129.3571 1
## 5 TCGA-OR-A5J6 822.0782 0
## 6 TCGA-OR-A5J7 344.5648 -1
boxplot(RNASeq2GeneNorm_EIF4E ~ gistict_EIF4E,
data=df, varwidth=TRUE,
xlab="GISTIC Relative Copy Number Call",
ylab="RNA-seq counts")
Convert all the ExperimentList
elements in miniACC
to SummarizedExperiment
objects. Then use rowRanges
to annotate these objects with genomic ranges. For the microRNA assay, annotate instead with the genomic coordinates of predicted targets.
Solution
First, make a new object and convert its experiments to SummarizedExperiment objects:
suppressPackageStartupMessages(library(SummarizedExperiment))
seACC <- miniACC
experiments(seACC)
## ExperimentList class object of length 5:
## [1] RNASeq2GeneNorm: ExpressionSet with 198 rows and 79 columns
## [2] gistict: SummarizedExperiment with 198 rows and 90 columns
## [3] RPPAArray: ExpressionSet with 33 rows and 46 columns
## [4] Mutations: matrix with 97 rows and 90 columns
## [5] miRNASeqGene: ExpressionSet with 471 rows and 80 columns
seACC[[1]] <- SummarizedExperiment(exprs(seACC[[1]]))
seACC[[3]] <- SummarizedExperiment(exprs(seACC[[3]]))
seACC[[4]] <- SummarizedExperiment(seACC[[4]])
seACC[[5]] <- SummarizedExperiment(exprs(seACC[[5]]))
experiments(seACC)
## ExperimentList class object of length 5:
## [1] RNASeq2GeneNorm: SummarizedExperiment with 198 rows and 79 columns
## [2] gistict: SummarizedExperiment with 198 rows and 90 columns
## [3] RPPAArray: SummarizedExperiment with 33 rows and 46 columns
## [4] Mutations: SummarizedExperiment with 97 rows and 90 columns
## [5] miRNASeqGene: SummarizedExperiment with 471 rows and 80 columns
The following shortcut function takes a list of human gene symbols and uses AnnotationFilter
and EnsDb.Hsapiens.v86
to look up the ranges, and return these as a GRangesList which can be used to replace the rowRanges of the SummarizedExperiment objects:
getrr <- function(identifiers, EnsDbFilterFunc="SymbolFilter"){
suppressPackageStartupMessages({
library(AnnotationFilter)
library(EnsDb.Hsapiens.v86)
})
FUN <- get(EnsDbFilterFunc)
edb <- EnsDb.Hsapiens.v86
afl <- AnnotationFilterList(FUN(identifiers),
SeqNameFilter(c(1:21, "X", "Y")),
TxBiotypeFilter("protein_coding"))
gr <- genes(edb, filter=afl)
grl <- split(gr, factor(identifiers))
grl <- grl[match(identifiers, names(grl))]
stopifnot(identical(names(grl), identifiers))
return(grl)
}
For example:
getrr(rownames(seACC)[[1]])
## GRangesList object of length 198:
## $DIRAS3
## GRanges object with 1 range and 7 metadata columns:
## seqnames ranges strand | gene_id
## <Rle> <IRanges> <Rle> | <character>
## ENSG00000116288 1 [7954291, 7985505] + | ENSG00000116288
## gene_name gene_biotype seq_coord_system symbol
## <character> <character> <character> <character>
## ENSG00000116288 PARK7 protein_coding chromosome PARK7
## entrezid tx_biotype
## <list> <character>
## ENSG00000116288 11315 protein_coding
##
## $MAPK14
## GRanges object with 1 range and 7 metadata columns:
## seqnames ranges strand | gene_id
## ENSG00000116285 1 [8004404, 8026308] - | ENSG00000116285
## gene_name gene_biotype seq_coord_system symbol
## ENSG00000116285 ERRFI1 protein_coding chromosome ERRFI1
## entrezid tx_biotype
## ENSG00000116285 54206 protein_coding
##
## $YAP1
## GRanges object with 1 range and 7 metadata columns:
## seqnames ranges strand | gene_id
## ENSG00000198793 1 [11106535, 11262507] - | ENSG00000198793
## gene_name gene_biotype seq_coord_system symbol
## ENSG00000198793 MTOR protein_coding chromosome MTOR
## entrezid tx_biotype
## ENSG00000198793 2475 protein_coding
##
## ...
## <195 more elements>
## -------
## seqinfo: 22 sequences from GRCh38 genome
Use this to set the rowRanges of experiments 1-4 with these GRangesList objects
for (i in 1:4){
rowRanges(seACC[[i]]) <- getrr(rownames(seACC[[i]]))
}
Note that the class of experiments 1-4 is now RangedSummarizedExperiment
:
experiments(seACC)
## ExperimentList class object of length 5:
## [1] RNASeq2GeneNorm: RangedSummarizedExperiment with 198 rows and 79 columns
## [2] gistict: RangedSummarizedExperiment with 198 rows and 90 columns
## [3] RPPAArray: RangedSummarizedExperiment with 33 rows and 46 columns
## [4] Mutations: RangedSummarizedExperiment with 97 rows and 90 columns
## [5] miRNASeqGene: SummarizedExperiment with 471 rows and 80 columns
With ranged objects in the MultiAssayExperiment, you can then do subsetting by ranges. For example, select all genes on chromosome 1 for the four rangedSummarizedExperiment objects:
seACC[GRanges(seqnames="1:1-1e9"), , 1:4]
## A MultiAssayExperiment object of 4 listed
## experiments with user-defined names and respective classes.
## Containing an ExperimentList class object of length 4:
## [1] RNASeq2GeneNorm: RangedSummarizedExperiment with 22 rows and 79 columns
## [2] gistict: RangedSummarizedExperiment with 22 rows and 90 columns
## [3] RPPAArray: RangedSummarizedExperiment with 3 rows and 46 columns
## [4] Mutations: RangedSummarizedExperiment with 11 rows and 90 columns
## Features:
## experiments() - obtain the ExperimentList instance
## colData() - the primary/phenotype DataFrame
## sampleMap() - the sample availability DataFrame
## `$`, `[`, `[[` - extract colData columns, subset, or experiment
## *Format() - convert into a long or wide DataFrame
## assays() - convert ExperimentList to a SimpleList of matrices
Note about microRNA: You can set ranges for the microRNA assay according to the genomic location of those microRNA, or the locations of their predicted targets, but we don’t do it here. Assigning genomic ranges of microRNA targets would be an easy way to subset them according to their targets.
The maeView.R function defined in this workshop opens a Shiny app for similar TCGA objects, to identify and visualize relationships between RNA-seq expression, GISTIC copy number peaks, and microRNA expression. For a specified gene, you can view a boxplot of expression vs. copy number, and use limma to identify microRNA correlated to expression of that gene.
MultiAssayExperimentWorkshop::maeView(miniACC)
sessionInfo()
## R version 3.4.1 (2017-06-30)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 16.04.2 LTS
##
## Matrix products: default
## BLAS: /usr/local/lib/R/lib/libRblas.so
## LAPACK: /usr/local/lib/R/lib/libRlapack.so
##
## locale:
## [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
## [3] LC_TIME=en_US.UTF-8 LC_COLLATE=C
## [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
## [7] LC_PAPER=en_US.UTF-8 LC_NAME=C
## [9] LC_ADDRESS=C LC_TELEPHONE=C
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
##
## attached base packages:
## [1] parallel stats4 stats graphics grDevices utils datasets
## [8] methods base
##
## other attached packages:
## [1] EnsDb.Hsapiens.v86_2.99.0 ensembldb_2.1.10
## [3] GenomicFeatures_1.29.8 AnnotationDbi_1.39.2
## [5] AnnotationFilter_1.1.3 SummarizedExperiment_1.7.5
## [7] DelayedArray_0.3.17 matrixStats_0.52.2
## [9] Biobase_2.37.2 GenomicRanges_1.29.12
## [11] GenomeInfoDb_1.13.4 IRanges_2.11.12
## [13] survminer_0.4.0 ggpubr_0.1.4
## [15] magrittr_1.5 ggplot2_2.2.1
## [17] survival_2.41-3 S4Vectors_0.15.5
## [19] BiocGenerics_0.23.0 MultiAssayExperiment_1.3.20
## [21] BiocStyle_2.5.8
##
## loaded via a namespace (and not attached):
## [1] nlme_3.1-131 ProtGenerics_1.9.0
## [3] bitops_1.0-6 cmprsk_2.2-7
## [5] bit64_0.9-7 httr_1.2.1
## [7] progress_1.1.2 RColorBrewer_1.1-2
## [9] rprojroot_1.2 UpSetR_1.3.3
## [11] R.cache_0.12.0 tools_3.4.1
## [13] backports_1.1.0 R6_2.2.2
## [15] DBI_0.7 lazyeval_0.2.0
## [17] colorspace_1.3-2 prettyunits_1.0.2
## [19] gridExtra_2.2.1 mnormt_1.5-5
## [21] curl_2.8.1 bit_1.1-12
## [23] compiler_3.4.1 rtracklayer_1.37.3
## [25] labeling_0.3 scales_0.4.1
## [27] survMisc_0.5.4 psych_1.7.5
## [29] Rsamtools_1.29.0 stringr_1.2.0
## [31] digest_0.6.12 foreign_0.8-69
## [33] rmarkdown_1.6 R.utils_2.5.0
## [35] XVector_0.17.0 pkgconfig_2.0.1
## [37] htmltools_0.3.6 rlang_0.1.1
## [39] RSQLite_2.0 BiocInstaller_1.27.2
## [41] shiny_1.0.3 bindr_0.1
## [43] zoo_1.8-0 BiocParallel_1.11.4
## [45] dplyr_0.7.2 R.oo_1.21.0
## [47] RCurl_1.95-4.8 GenomeInfoDbData_0.99.1
## [49] Matrix_1.2-10 Rcpp_0.12.12
## [51] munsell_0.4.3 R.methodsS3_1.7.1
## [53] stringi_1.1.5 yaml_2.1.14
## [55] zlibbioc_1.23.0 AnnotationHub_2.9.5
## [57] plyr_1.8.4 grid_3.4.1
## [59] blob_1.1.0 shinydashboard_0.6.1
## [61] lattice_0.20-35 Biostrings_2.45.3
## [63] splines_3.4.1 knitr_1.16
## [65] biomaRt_2.33.3 reshape2_1.4.2
## [67] codetools_0.2-15 XML_3.98-1.9
## [69] glue_1.1.1 evaluate_0.10.1
## [71] data.table_1.10.4 httpuv_1.3.5
## [73] gtable_0.2.0 purrr_0.2.2.2
## [75] tidyr_0.6.3 km.ci_0.5-2
## [77] assertthat_0.2.0 mime_0.5
## [79] xtable_1.8-2 broom_0.4.2
## [81] tibble_1.3.3 pheatmap_1.0.8
## [83] GenomicAlignments_1.13.4 memoise_1.1.0
## [85] KMsurv_0.1-5 bindrcpp_0.2
## [87] interactiveDisplayBase_1.15.0 R.rsp_0.41.0