TxpResult-class {toxpiR}R Documentation

ToxPi Result

Description

S4 class to store ToxPi results

Usage

## S4 method for signature 'TxpResult'
txpScores(x)

## S4 method for signature 'TxpResult'
txpSliceScores(x, adjusted = TRUE)

## S4 method for signature 'TxpResult'
txpRanks(x)

## S4 method for signature 'TxpResult'
txpResultParam(x)

## S4 method for signature 'TxpResult'
txpModel(x)

## S4 method for signature 'TxpResult'
txpIDs(x)

## S4 replacement method for signature 'TxpResult'
txpIDs(x) <- value

## S4 method for signature 'TxpResult'
txpWeights(x, adjusted = FALSE)

## S4 method for signature 'TxpResult'
txpSlices(x)

## S4 method for signature 'TxpResult'
txpTransFuncs(x, level, simplify = FALSE)

## S4 method for signature 'TxpResult'
txpValueNames(x, simplify = FALSE)

## S4 method for signature 'TxpResult,logical,missing'
x[i, j, ..., drop = FALSE]

## S4 method for signature 'TxpResult,integer,missing'
x[i, j, ..., drop = FALSE]

## S4 method for signature 'TxpResult,numeric,missing'
x[i, j, ..., drop = FALSE]

## S4 method for signature 'TxpResult,character,missing'
x[i, j, ..., drop = FALSE]

## S4 method for signature 'TxpResult'
length(x)

## S4 method for signature 'TxpResult'
sort(x, decreasing = TRUE, na.last = TRUE, ...)

## S4 method for signature 'TxpResult'
names(x)

## S4 replacement method for signature 'TxpResult'
names(x) <- value

## S4 method for signature 'TxpResult'
as.data.frame(
  x,
  row.names = NULL,
  optional = FALSE,
  ...,
  id.name = "id",
  score.name = "score",
  rank.name = "rank",
  adjusted = FALSE
)

Arguments

x

TxpResult object

adjusted

Logical scalar, when TRUE the weights are adjusted to sum to 1 or the slice scores are scaled to their respective weight

value

Replacement value

level

c('model', 'slices'); indicates whether to retrieve txpTransFuncs slot from the model or underlying slices

simplify

Logical scalar, flatten txpValueNames or txpTransFunc slots when retrieving slice-level information

i

Subsetting index

j, drop, optional

Not currently implemented

...

Passed to base::data.frame in as.data.frame or base::sort in sort

decreasing, na.last

Passed to base::sort

row.names

Passed to base::data.frame

id.name, score.name, rank.name

Character scalar; when coercing to base::data.frame, the name for the txpIDs, txpScores, and txpRanks columns, respectively

Functions

Slots

txpScores

⁠vector(<numeric>)⁠ of model scores

txpSliceScores

⁠matrix(<numeric>)⁠, sample by slice matrix with individual slice scores

txpRanks

⁠vector(<numeric>)⁠ with rank of scores

txpModel

TxpModel object

txpIDs

⁠vector(<character>)⁠ of observation IDs

txpResultParam

TxpResultParam object

See Also

txpCalculateScores, plot, TxpResultList

Examples

## Load example dataset & model; see ?TxpModel for building model objects
data(txp_example_input, package = "toxpiR")
data(txp_example_model, package = "toxpiR")

## Calculate scores for single model; returns TxpResult object
res <- txpCalculateScores(model = txp_example_model, 
                          input = txp_example_input, 
                          id.var = "name")

## Accessors
txpScores(res)

txpSliceScores(res) ## adjusted for weight, by default
apply(txpSliceScores(res), 2, max, na.rm = TRUE)

txpSliceScores(res, adjusted = FALSE) ## each score should have maximum of 1
apply(txpSliceScores(res, adjusted = FALSE), 2, max, na.rm = TRUE)

txpRanks(res)

txpModel(res)
identical(txpModel(res), txp_example_model)

txpIDs(res)
names(res) ## identical to txpIDs(res)
identical(txpIDs(res), names(res))

# Can access TxpModel slots directly
txpWeights(res)
txpWeights(res, adjusted = TRUE)
txpSlices(res)
# When retrieving transform functions, must specify level because both 
# models and slices have transform functions
txpTransFuncs(res, level = "model")

# Can access TxpSliceList slots directly
txpValueNames(res)
txpValueNames(res, simplify = TRUE)
txpTransFuncs(res, level = "slices")
txpTransFuncs(res, level = "slices", simplify = TRUE)

## Subsetting
res[1]
res[c("chem01", "chem09")]
res[grepl("4|6", txpIDs(res))]
## Not run: 
res[c(TRUE, FALSE)] ## gets recycled with warning

## End(Not run)

## length -- returns number of observations
length(res)
length(res[1:5])

## sort
names(res)
names(sort(res))

txpScores(res)
txpScores(sort(res))
txpScores(sort(res, decreasing = FALSE))

## as.data.frame
as.data.frame(res)
as.data.frame(res, id.name = "nm", score.name = "scr", rank.name = "rnk")

[Package toxpiR version 1.2.1 Index]