QFeatures-longForm: Reshape into a long data format

longForm,QFeatures-methodR Documentation

Reshape into a long data format

Description

The longForm() method transform a QFeatures or SummarizedExperiment instance into a long tidy DataFrame that contains the assay data, where each quantitative value is reported on a separate line. colData and rowData varibales can also be added. This function is an extension of the longForm() method in the MultiAssayExperiment::MultiAssayExperiment.

Note that the previous longFormat implementation is not defunct.

Usage

## S4 method for signature 'QFeatures'
longForm(object, colvars = NULL, rowvars = NULL, i = 1L)

## S4 method for signature 'SummarizedExperiment'
longForm(object, colvars = NULL, rowvars = NULL, i = seq_along(assays(object)))

Arguments

object

An instance of class QFeatures or SummarizedExperiment.

colvars

A character() that selects column(s) in the colData.

rowvars

A character() with the names of the rowData variables (columns) to retain in any assay.

i

When object is an instance of class QFeatures, a numeric(1) indicating what assay within each SummarizedExperiment object to return. Default is 1L. If object is a SummarizedExperiment, a numeric() indicating what assays to pull and convert. Default is to use all assays.

Value

A DataFrame instance.

Examples


data(feat2)

longForm(feat2)

## add a colData variable and use it in longFrom
colData(feat2)$colvar <- paste0("Var", 1:12)
colData(feat2)
longForm(feat2, colvars = "colvar")

## use a rowData variable in longFrom
rowDataNames(feat2)
longForm(feat2, rowvar = "Prot")

## use both col/rowData
longForm(feat2, colvar = "colvar", rowvar = "Prot")

## also works on a single SE
se <- getWithColData(feat2, 1)
longForm(se)
longForm(se, colvar = "colvar")
longForm(se, rowvar = "Prot")
longForm(se, colvar = "colvar", rowvar = "Prot")

rformassspectrometry/Features documentation built on July 4, 2025, 12:13 p.m.