scaleBioassaySet {bioassayR} | R Documentation

## Centers and standardizes the numeric activity scores for a `bioassaySet` object (creates Z-scores)

### Description

Converts the numeric activity scores for a `bioassaySet` object into per-assay Z-scores. Untested '0' values are not considered in computing the value, only actives and inactives. In essence, this is a special version of the R base `scale` function, which ignores missing entries in a sparse matrix instead of using them as zeros. A primary purpose of this function is to pass scaled results to `perTargetMatrix`, in order to compute a numeric Z-score compound vs. target matrix.

### Usage

    scaleBioassaySet(bioassaySet, center=TRUE, scale=TRUE)

### Arguments

`bioassaySet` | A `bioassaySet` object with data from multiple assays. This should be created with `getAssays` rather than `getBioassaySetByCids`, as the former includes the full assay data whereas the latter omits scores for compounds other than those specified, and therefore will not compute a coherent Z-score.
`center` | A logical value. If center is TRUE then centering is done by subtracting the assay means (omitting inconclusive NAs) from their corresponding scores, and if center is FALSE, no centering is done.
`scale` | A logical value. Scaling is done by dividing the (centered) per-assay scores by their standard deviations if center is TRUE, and the root mean square otherwise. If scale is FALSE, no scaling is done.

### Value

A `bioassaySet` object with standardized numeric scores, that can be accessed with `scores(bioassaySet)`.

### Author(s)

Tyler William H Backman

### See Also

Functions: `getAssays`, `perTargetMatrix`

### Examples

    ## connect to a test database
    extdata_dir <- system.file("extdata", package="bioassayR")
    sampleDatabasePath <- file.path(extdata_dir, "sampleDatabase.sqlite")
    sampleDB <- connectBioassayDB(sampleDatabasePath)

    ## retrieve three assays
    assays <- getAssays(sampleDB, c("347221","53211","624349"))

    ## disconnect from sample database
    disconnectBioassayDB(sampleDB)

    ## compute and return standardized scores
    scaledAssays <- scaleBioassaySet(assays)

    ## inspect scaled and unscaled scores
    scores(assays)
    scores(scaledAssays)

    ## NOTE: this example only returns non-NA Z-scores if tried with
    ## real data, not the test database used here

[Package bioassayR version 1.30.0 Index]