AssayLinks: Links between Assays

View source: R/AssayLinks.R

AssayLinksR Documentation

Links between Assays


Links between assays within a QFeatures object are handled by an AssayLinks object. It is composed by a list of AssayLink instances.


## S4 method for signature 'AssayLink'

## S4 method for signature 'AssayLinks'
updateObject(object, ..., verbose = FALSE)

## S4 method for signature '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 signature 'AssayLink,character,ANY,ANY'
x[i, j, ..., drop = TRUE]

## S4 method for signature 'AssayLinks,list,ANY,ANY'
x[i, j, ..., drop = TRUE]

addAssayLink(object, from, to, varFrom, varTo)

addAssayLinkOneToOne(object, from, to)



An AssayLink object to show.


A set of AssayLink objects or a list thereof.


logical (default FALSE) whether to print extra messages


A mandatory name of the assay(s).


A character() or integer() indicating which assay(s) to link from in object


The feature variable of the parent assay used to generate the current assay (used in aggregateFeatures). NA_character_, if not applicable.


An object of class S4Vectors::Hits matching the features of two assays.


A character() of AssayLink names. If provided, ... are ignored, and names is used to create an AssayLinks object with AssayLink instances with names names.


An instance of class QFeatures.


The index or name of the assay whose AssayLink and parents AssayLink instances are to be returned. For [, the feature names to filter on.






A character(1) or integer(1) indicating which assay to link to in object


A character() indicating the feature variable(s) to use to match the from assay(s) to the to assay. varFrom must have the same length as from and is assumed to be ordered as from.


A character(1) indicating the feature variable to use to match the to assay to the from assay(s).


assayLink returns an instance of class AssayLink.

assayLinks returns an instance of class AssayLinks.


Object can be created with the AssayLink() and AssayLinks() constructors.

Methods and functions

  • assayLink(x, i) accesses the AssayLink at position i or with name i in the QFeatures object x.

  • parentAssayLinks(x, i, recursive = FALSE) accesses the parent(s) AssayLinks or assay with index or name i.

Creating links between assays

  • addAssayLink takes a parent assay and a child assay contained in the QFeatures object and creates a link given a matching feature variable in each assay's rowData. addAssayLink also allows to link an assay from multiple parent assays (see examples below).

  • addAssayLinkOneToOne links 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 in rowData. Providing multiple parents is not supported.


## Creating an AssayLink object

al1 <- AssayLink(name = "assay1")

## Creating an AssayLinks object


al2 <- AssayLinks(names = c("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],
                           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(ft, "assay1") ## 'from' is NA

## 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")

## For one-to-one relationships, you can also use
ftLinked <- addAssayLinkOneToOne(ft, from = "assay1", to = "assay2")
assayLink(ftLinked, "assay2")

## 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")

rformassspectrometry/QFeatures documentation built on March 26, 2023, 8:22 p.m.