se_to_rowcoldata: Get SE colData and rowData

se_to_rowcoldataR Documentation

Get SE colData and rowData

Description

Get SE colData and rowData consistently for SummarizedExperiment, SingleCellExperiment, Seurat data, and generic Biobase eSet compatible objects that provide featureData() and phenoData().

Usage

se_to_rowcoldata(se, verbose = FALSE, ...)

Arguments

se

recognized object:

  • SummarizedExperiment or any object that inherits from this class

  • SingleCellExperiment because it inherits from SummarizedExperiment

  • Seurat which is converted to SingleCellExperiment

  • ExpressionSet and any object that inherits from this class, using Biobase::featureData() and Biobase::phenoData().

  • NanoStringGeoMxSet which uses GeomxTools::sData() or NanoStringNCTools::sData() to define colData_se, otherwise is handled equivalent to ExpressionSet.

...

additional arguments are ignored

Details

This function provides a straightforward way to return the equivalent of data.frame(check.names=FALSE, rowData(se)) and data.frame(check.names=FALSE, colData(se)) for several types of object types.

  • It also defines rownames() and colnames() if either are missing.

  • When rowData has no annotation columns, it defines one column "rows" using rownames(se).

  • If slot name "rowRanges" exists, and "rowData" either does not exist or has zero columns, it will use rowRanges().

  • When colData has no annotation columns, it defines one column "columns" using colnames(se).

  • When input se class is "Seurat", it converts the object with Seurat::as.SingleCellExperiment()

  • Any other object uses Biobase::featureData() for "rowData_se", and Biobase::phenoData() for "colData_se".

To verify the logic used at each step, set verbose=TRUE.

For Class "NanoStringGeoMxSet" defined in GeomxTools, the colData_se is defined using GeomxTools::sData() in order to return the combined data.frame with protocolData() and pData() together. Accordingly, it is possible to have duplicated colnames, which becomes a problem for many downstream tools, so the second instance of any duplicated colnames have "_v1" added by using jamba::makeNames(x, renameFirst=FALSE). The first instance of each duplicated colname is not renamed. Use verbose=TRUE to confirm when duplicated columns are detected and renamed.

Value

list with two components:

  • "colData_se" as a data.frame with column metadata from se

  • "rowData_se" as a data.frame with row metadata from se

See Also

Other jamses SE utilities: make_se_test(), se_collapse_by_column(), se_collapse_by_row(), se_detected_rows(), se_normalize(), se_rbind()


jmw86069/jamses documentation built on Nov. 4, 2024, 9:25 p.m.