makePerFeatureDF {scuttle} | R Documentation

## Create a per-feature data.frame

### Description

Create a per-feature data.frame (i.e., where each row represents a feature) from a SingleCellExperiment, most typically for creating custom ggplot2 plots.

### Usage

    makePerFeatureDF(
      x,
      cells = NULL,
      assay.type = "logcounts",
      use.rowdata = TRUE,
      check.names = FALSE,
      exprs_values = NULL,
      check_names = NULL
    )

### Arguments

`x` | A SingleCellExperiment object. This is expected to have non-`NULL` row names.
`cells` | Character vector specifying the features for which to extract expression profiles across cells.
`assay.type` | String or integer scalar indicating the assay to use to obtain expression values. Must refer to a matrix-like object with integer or numeric values.
`use.rowdata` | Logical scalar indicating whether row metadata of `x` should be included. Alternatively, a character or integer vector specifying the row metadata fields to use.
`check.names` | Logical scalar indicating whether column names of the output should be made syntactically valid and unique.
`exprs_values, check_names` | Soft-deprecated equivalents to the arguments above.

### Details

This function enables us to conveniently create a per-feature data.frame from a SingleCellExperiment. Each row of the returned data.frame corresponds to a row in `x`, while each column of the data.frame corresponds to one aspect of the (meta)data in `x`.

Columns are provided in the following order:

1. Columns named according to the entries of `cells` represent the expression values across features for the specified cell in the `assay.type` assay.

2. Columns named according to the columns of `rowData(x)` represent the row metadata variables. This consists of all variables if `use.rowdata=TRUE`, no variables if `use.rowdata=FALSE`, and only the specified variables if `use.rowdata` is set to an integer or character vector.

By default, nothing is done to resolve syntactically invalid or duplicated column names. `check_names=TRUE`, this is resolved by passing the column names through `make.names`. Of course, as a result, some columns may not have the same names as the original fields in `x`.

### Value

A data.frame containing one field per aspect of data in `x` - see Details. Each row corresponds to a feature (i.e., row) of `x`.

### Author(s)

Aaron Lun

### See Also

`makePerCellDF`, for the cell-level equivalent.

### Examples

    example_sce <- mockSCE()
    example_sce <- logNormCounts(example_sce)
    rowData(example_sce)$Length <- runif(nrow(example_sce))

    df <- makePerFeatureDF(example_sce, cells="Cell_001")
    head(df)

[Package scuttle version 1.4.0 Index]