Difference between revisions of "GGB-correlation-snippet.R"

From Organic Design wiki
m
 
m (# {{R}})
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
kcorrelation <- rgamma(2*nDE, shape=k, rate=k) # p49 2001 NEWTON paper
+
# {{R}}
DEscales <- rep(rgamma(nDE, shape=a0.shape, rate=scale), each=2)
+
# p (genes) by n (slides) matrix
DEscales <- DEscales * kcorrelation
+
# m=p keeping fdr notation
  
kcorrelation <- rgamma(m0, shape=k, rate=k)
+
m <- <- 1000
EEscales <- rgamma(nEE , shape=a0.shape, rate=scale)
+
nreps <- 5
EEscales <- EEscales / kcorrelation
 
scales  <- c(rep(DEscales, each=nreps), rep(EEscales, each=2*nreps))
 
  
X <- rgamma(ngenes*pcols, a.shape, rate=scales)
+
n  <- nreps * 2
dim(X) <- c(pcols, ngenes)
+
pi0 <- 0.95
X <- t(X) # Data already on raw scale
+
 
 +
m1 <- round(m * (1-pi0))
 +
m0 <- p - m1
 +
 
 +
params <- c(2.74886, 1.36546, 4.12844) # "IPTG-a parameters"
 +
k <- 1000
 +
 
 +
a.shape  <- params[1]
 +
a0.shape <- params[2]
 +
scale    <- params[3]
 +
 
 +
kDE <- rgamma(2*m1, shape=k, rate=k) # p49 2001 NEWTON paper
 +
DEscales <- rgamma(2*m1, shape=a0.shape, rate=scale)
 +
DEscales <- DEscales * kDE
 +
 
 +
kEE <- rgamma(m0, shape=k, rate=k)
 +
EEscales <- rgamma(m0 , shape=a0.shape, rate=scale)
 +
EEscales <- EEscales / kEE
 +
 
 +
scales  <- c(rep(DEscales, each=nreps), rep(EEscales, each=2*nreps))     
 +
X <- rgamma(n* p, a.shape, rate=scales)  
 +
dim(X) <- c(n,p)
 +
 
 +
X <- t(X)
 +
 
 +
# Graphical check
 +
hist(kDE, prob=TRUE)
 +
lines(density(kDE))
 +
 
 +
hist(kEE, prob=TRUE)
 +
lines(density(kEE))
 +
 
 +
Xbar <- rowMeans(log2(X))
 +
hist(Xbar, breaks=30, prob=TRUE)
 +
lines(density(Xbar))
 +
pairs(log2(X))

Latest revision as of 00:37, 6 June 2007

Code snipits and programs written in R, S or S-PLUS

  1. p (genes) by n (slides) matrix
  2. m=p keeping fdr notation

m <- p <- 1000 nreps <- 5

n <- nreps * 2 pi0 <- 0.95

m1 <- round(m * (1-pi0)) m0 <- p - m1

params <- c(2.74886, 1.36546, 4.12844) # "IPTG-a parameters" k <- 1000

a.shape <- params[1] a0.shape <- params[2] scale <- params[3]

kDE <- rgamma(2*m1, shape=k, rate=k) # p49 2001 NEWTON paper DEscales <- rgamma(2*m1, shape=a0.shape, rate=scale) DEscales <- DEscales * kDE

kEE <- rgamma(m0, shape=k, rate=k) EEscales <- rgamma(m0 , shape=a0.shape, rate=scale) EEscales <- EEscales / kEE

scales <- c(rep(DEscales, each=nreps), rep(EEscales, each=2*nreps)) X <- rgamma(n* p, a.shape, rate=scales) dim(X) <- c(n,p)

X <- t(X)

  1. Graphical check

hist(kDE, prob=TRUE) lines(density(kDE))

hist(kEE, prob=TRUE) lines(density(kEE))

Xbar <- rowMeans(log2(X)) hist(Xbar, breaks=30, prob=TRUE) lines(density(Xbar)) pairs(log2(X))