Links between assays within a QFeatures object are handled by an
AssayLinks object. It is composed by a list of AssayLink
instances.
Usage
# S4 method for class 'AssayLink'
show(object)
# S4 method for class 'AssayLinks'
updateObject(object, ..., verbose = FALSE)
# S4 method for class 'AssayLink'
updateObject(object, ..., verbose = FALSE)
AssayLink(name, from = NA_character_, fcol = NA_character_, hits = Hits())
AssayLinks(..., names = NULL)
assayLink(x, i)
assayLinks(x, i)
# S4 method for class 'AssayLink,character,ANY,ANY'
x[i, j, ..., drop = TRUE]
# S4 method for class 'AssayLinks,list,ANY,ANY'
x[i, j, ..., drop = TRUE]
addAssayLink(object, from, to, varFrom, varTo)
addAssayLinkOneToOne(object, from, to)Arguments
- object
An
AssayLinkobject to show.- ...
A set of
AssayLinkobjects or a list thereof.- verbose
logical (default FALSE) whether to print extra messages
- name
A mandatory name of the assay(s).
- from
A
character()orinteger()indicating which assay(s) to link from inobject- fcol
The feature variable of the parent assay used to generate the current assay (used in
aggregateFeatures).NA_character_, if not applicable.- hits
An object of class S4Vectors::Hits matching the features of two assays.
- names
A
character()ofAssayLinknames. If provided,...are ignored, andnamesis used to create anAssayLinksobject withAssayLinkinstances with namesnames.- x
An instance of class QFeatures.
- i
The index or name of the assay whose
AssayLinkand parentsAssayLinkinstances are to be returned. For[, the feature names to filter on.- j
ignored.
- drop
ignored.
- to
A
character(1)orinteger(1)indicating which assay to link to inobject- varFrom
A
character()indicating the feature variable(s) to use to match thefromassay(s) to thetoassay.varFrommust have the same length asfromand is assumed to be ordered asfrom.- varTo
A
character(1)indicating the feature variable to use to match thetoassay to thefromassay(s).
Value
assayLink returns an instance of class AssayLink.
assayLinks returns an instance of class AssayLinks.
Methods and functions
assayLink(x, i)accesses the AssayLink at positionior with nameiin the QFeatures objectx.parentAssayLinks(x, i, recursive = FALSE)accesses the parent(s)AssayLinksor assay with index or namei.
Creating links between assays
addAssayLinktakes a parent assay and a child assay contained in the QFeatures object and creates a link given a matching feature variable in each assay'srowData.addAssayLinkalso allows to link an assay from multiple parent assays (see examples below).addAssayLinkOneToOnelinks two assays contained in the QFeatures object. The parent assay and the child assay must have the same size and contain the same rownames (a different ordering is allowed). The matching is performed based on the row names of the assays, instead of a supplied variable name inrowData. Providing multiple parents is not supported.
Examples
##-----------------------------
## Creating an AssayLink object
##-----------------------------
al1 <- AssayLink(name = "assay1")
al1
#> AssayLink for assay <assay1>
#> [from:NA|fcol:NA|hits:0]
##------------------------------
## Creating an AssayLinks object
##------------------------------
AssayLinks(al1)
#> AssayLinks of length 1
#> names(1): assay1
al2 <- AssayLinks(names = c("Assay1", "Assay2"))
al2
#> AssayLinks of length 2
#> names(2): Assay1 Assay2
##---------------------------------------
## Adding an AssayLink between two assays
##---------------------------------------
## create a QFeatures object with 2 (identical) assays
## see also '?QFeatures'
se <- SummarizedExperiment(matrix(runif(20), ncol = 2,
dimnames = list(LETTERS[1:10],
letters[1:2])),
rowData = DataFrame(ID = 1:10))
ft <- QFeatures(list(assay1 = se, assay2 = se))
## assay1 and assay2 are not linked
assayLink(ft, "assay2") ## 'from' is NA
#> AssayLink for assay <assay2>
#> [from:NA|fcol:NA|hits:0]
assayLink(ft, "assay1") ## 'from' is NA
#> AssayLink for assay <assay1>
#> [from:NA|fcol:NA|hits:0]
## Suppose assay2 was generated from assay1 and the feature variable
## 'ID' keeps track of the relationship between the two assays
ftLinked <- addAssayLink(ft, from = "assay1", to = "assay2",
varFrom = "ID", varTo = "ID")
assayLink(ftLinked, "assay2")
#> AssayLink for assay <assay2>
#> [from:assay1|fcol:ID|hits:10]
## For one-to-one relationships, you can also use
ftLinked <- addAssayLinkOneToOne(ft, from = "assay1", to = "assay2")
assayLink(ftLinked, "assay2")
#> AssayLink for assay <assay2>
#> [from:assay1|fcol:._oneToOne|hits:10]
##----------------------------------------
## Adding an AssayLink between more assays
##----------------------------------------
## An assay can also be linked to multiple parent assays
## Create a QFeatures object with 2 parent assays and 1 child assay
ft <- QFeatures(list(parent1 = se[1:6, ], parent2 = se[4:10, ], child = se))
ft <- addAssayLink(ft, from = c("parent1", "parent2"), to = "child",
varFrom = c("ID", "ID"), varTo = "ID")
assayLink(ft, "child")
#> AssayLink for assay <child>
#> [from:parent1,parent2|fcol:ID,ID|hits:6,7]
