Learn R Programming

Umpire (version 2.0.11)

IndependentNormal-class: The "IndependentNormal" Class

Description

The IndependentNormal class is a tool used to generate gene expressions that follow independent normal distribution.

Usage

IndependentNormal(mu,sigma)
# S4 method for IndependentNormal
alterMean(object, TRANSFORM, ...)
# S4 method for IndependentNormal
alterSD(object, TRANSFORM, ...)
# S4 method for IndependentNormal
nrow(x)
# S4 method for IndependentNormal
rand(object, n, ...)
# S4 method for IndependentNormal
summary(object, ...)

Arguments

mu

numeric vector specifying the mean expression values

sigma

numeric vector specifying the standard deviation of the gene expression values

object, x

object of class IndependentNormal

TRANSFORM

function that takes 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 specifying number of samples to be simulated

...

extra arguments for generic or plotting routines

Objects from the Class

Objects can be created by using the IndependentNormal generator function. The object of class IndependentNormal contains the mean and standard deviation for the normal distribution

Slots

mu:

see corresponding argument above

sigma:

see corresponding argument above

Methods

alterMean(object, TRANSFORM, ...)

Takes an object of class IndependentNormal, loops over the mu slot, alters the mean as defined by TRANSFORM function, and returns an object of class IndependentNormal with altered mu.

alterSD(object, TRANSFORM, ...)

Takes an object of class IndependentNormal, loops over the sigma slot, alters the standard deviation as defined by TRANSFORM function, and returns an object of class IndependentNormal with altered sigma.

nrow(x)

Returns the number of genes (i.e, the length of the mu vector).

rand(object, n, ...)

Generates \(nrow(IndependentNormal)*n\) matrix representing gene expressions of n samples following the normal distribution captured in the object of IndependentNormal.

summary(object, ...)

Prints out the number of independent normal random variables in the object of IndependentNormal.

Author

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

Details

Note that we typically work on expression value with its logarithm to some appropriate base. That is, the independent normal should be used on the logarithmic scale in order to construct the engine.

See Also

Engine, IndependentLogNormal, MVN

Examples

Run this code
showClass("IndependentNormal")
nGenes <- 20
mu <- rnorm(nGenes, 6, 1)
sigma <- 1/rgamma(nGenes, rate=14, shape=6)
ind <- IndependentNormal(mu, sigma)
nrow(ind)
summary(ind)
if (any(mu - ind@mu)) {
  print('means do not match')
} else {
  print('means verified')
}
if (any(sigma - ind@sigma)) {
  print('standard deviations do not match')
} else {
  print('sd verified')
}
x <- rand(ind, 3)
print(dim(x))
print(summary(x))
print(paste("'ind' should be valid:", validObject(ind)))
ind@sigma <- 1:3 # now we break it
print(paste("'ind' should not be valid:", validObject(ind, test=TRUE)))
rm(nGenes, mu, sigma, ind, x)

Run the code above in your browser using DataLab