# The "Engine" Class

### Description

The `Engine`

class is a tool (i.e., an algorithm) used to simulate
vectors of gene expression from some underlying distribution.

### Usage

1 2 3 4 5 6 7 8 9 10 11 12 | ```
Engine(components)
nComponents(object)
## S4 method for signature 'Engine'
alterMean(object, TRANSFORM, ...)
## S4 method for signature 'Engine'
alterSD(object, TRANSFORM, ...)
## S4 method for signature 'Engine'
nrow(x)
## S4 method for signature 'Engine'
rand(object, n, ...)
## S4 method for signature 'Engine'
summary(object, ...)
``` |

### Arguments

`components` |
object of class |

`object, x` |
object of class |

`TRANSFORM` |
function takes as its input a vector of mean expression or standard deviation and returns a transformed vector that can be used to alter the appropriate slot of the object. |

`n` |
numeric scalar representing number of samples to be simulated |

`...` |
extra arguments for generic or plotting routines |

### Details

In most cases, an engine object is an instantiation of a more general family or class that we call an ABSTRACT ENGINE. Every abstract engine is an ordered list of components, which can also be thought of as an engine with parameters. We instantiate an engine by binding all the free parameters of an abstract engine to actual values. Note that partial binding (of a subset of the free parameters) produces another abstract engine.

For all practical purposes, a COMPONENT should be viewed as an irreducible abstract engine. Every component must have an IDENTIFIER that is unique within the context of its enclosing abstract engine. The identifer may be implicitly taken to be the position of the component in the ordered list.

We interpret an `Engine`

as the gene expression generator for a
homogenous population; effects of cancer on gene expression are modeled
at a higher level.

### Value

The `Engine`

generator returns an object of class `Engine`

.

The `alterMean`

method returns an object of class `Engine`

with
altered mean.

The `alterSD`

method returns an object of class `Engine`

with
altered standard deviation.

The `nrow`

method returns the number of genes (i.e, the length of the
vector) the `Engine`

object will generate.

The `rand`

method returns *nrow(Engine)*n* matrix representing the
expressions of `nrow(Engine)`

genes and `n`

samples.

The `summary`

method prints out the number of components included
in the `Engine`

object.

The `nComponents`

method returns the number of components in the
`Engine`

object.

### Objects from the Class

Objects can be created by calls of the form ```
new("Engine",
components=components)
```

, or use the `Engine`

generator function.
Every engine is an ordered list of components, which generates a contiguous
subvector of the total vector of gene expression.

### Methods

- alterMean(object, TRANSFORM, ...)
Takes an object of class

`Engine`

, loops over the components in the`Engine`

, alters the mean as defined by`TRANSFORM`

function, and returns a modified object of class`Engine`

.- alterSD(object, TRANSFORM, ...)
Takes an object of class

`Engine`

, loops over the components in the`Engine`

, alters the standard deviation as defined by`TRANSFORM`

function, and returns a modified object of class`Engine`

.- nrow(x)
Counts the total number of genes (i.e, the length of the vector the

`Engine`

will generate).- rand(object, n, ...)
Generates

*nrow(Engine)*n*matrix representing gene expressions of`n`

samples following the underlying distribution captured in the object of`Engine`

.- summary(object, ...)
Prints out the number of components included in the object of

`Engine`

.

### Author(s)

Kevin R. Coombes krc@silicovore.com, Jiexin Zhang jiexinzhang@mdanderson.org, P. Roebuck proebuck@mdanderson.org

### References

OOMPA

### See Also

`EngineWithActivity`

### Examples

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | ```
showClass("Engine")
nComp <- 10
nGenes <- 100
comp <- list()
for (i in 1:nComp) {
comp[[i]] <- IndependentNormal(rnorm(nGenes/nComp, 6, 1.5),
1/rgamma(nGenes/nComp, 44, 28))
}
myEngine <- Engine(comp)
nrow(myEngine)
nComponents(myEngine)
summary(myEngine)
myData <- rand(myEngine, 5)
dim(myData)
summary(myData)
OFFSET <- 2
myEngine.alterMean <- alterMean(myEngine, function(x){x+OFFSET})
myData.alterMean <- rand(myEngine.alterMean, 5)
summary(myData.alterMean)
SCALE <- 2
myEngine.alterSD <- alterSD(myEngine, function(x){x*SCALE})
myData.alterSD <- rand(myEngine.alterSD, 5)
summary(myData.alterSD)
``` |