sample.ind: Function to Sample Observations(gene expressions) from...

Description Usage Arguments Value Author(s) Examples

Description

Function to Sample Observations(gene expressions) from Independent Normal Distribution with Simulated sd

Usage

1
sample.ind(ngenes.ind, n, sd.ctrl, var.ratio, delta)

Arguments

ngenes.ind

an integer number for the number of observations (gene expression values) to simulate for genes coming from true alternative hypothesis

n

number of replicates for each group of control/treatment

sd.ctrl

vector of positive numbers for the sample length as ngenes.ind

var.ratio

ratio of variance between treatment/control

delta

effect size, absolute difference of the means between genes from true alternative and true null nypothesis groups

Value

returns a matrix with ngenes.null.ind(or ngenes.alt.ind) rows and 2*n columns with the first n columns being samples from control group and last n columns being from treatment group for each gene (row)

Author(s)

Peng Liu peng\_liu\@groton.pfizer.com

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

n.null.ind <- 50; n <- 500; var.ratio <- 1;

test.null.ind <- sample.null.ind(n.null.ind , n, var.ratio)

## Not run: 

ndim <- dim(test.null.ind);
ssd.ctrl<-rep(0, ndim[1])
var.r <- rep(0, ndim[1])
k <- ceiling(n.null.ind * runif(1,0,1))

for ( i in c(1:ndim[1]))
  { ssd.ctrl[i]  <- sd(test.null.ind[i,1:n])
    var.r[i] <- var(test.null.ind[i,(n+1):(2*n)]) / var(test.null.ind[i,1:n])}

cat("comparison between the desired sample and the generated sample: \n")

cat(" ------------------------------------------ \n",
    "number of genes (rows) :\t", n.null.ind, "\t", ndim[1], "\n",
    "number of obs for each group: \t", n, "\t", ndim[2]/2, "\n",
    "variance ratio (trt/ctrl) is: \t", var.ratio, "\t", mean(var.r), "\n",
    "variances for ctrl are generated randomly from inverse gamma distrn. \n",
    "please check histogram of sd.\n",
    "------------------------------------------ \n")

### Histogram of the standard deviations generated

hist(ssd.ctrl,n=20, col="cyan", border="blue", main="",
     xlab="Standard Deviation (for simulated data)")
dens <- density(ssd.ctrl)
lines(dens$x, dens$y*par("usr")[4]/max(dens$y),col="red",lwd=2)

title("Histogram of Standard Deviations for generated sample")

## End(Not run) 

warnes/exp.ssize documentation built on May 4, 2019, 12:59 a.m.