[R] FOR loop with statistical analysis for microarray data

Seb seba.bat at gmail.com
Wed Oct 26 22:56:03 CEST 2011


hi all

i started recently using R and i found myself stuck when i try to
analyze microarray data.

i use the "affy" package to obtain  the intensities of the probes, i
have two CTRs and two treated.

 HG.U133A.Experiment1.CEL HG.U133A.Experiment2.CEL
HG.U133A_Control1.CEL HG.U133A_Control2.CEL
1007_s_at               2156.23115                467.75615
 364.60615             362.11865
1053_at                   88.76368                 93.58436
 438.49365             357.75615
117_at                   144.00743                101.26120
  95.11117             107.01623
121_at                   551.36865                639.45615
 456.66865             435.95615
1255_g_at                 65.33164                 18.39570
  14.22565              20.74632
1294_at                  106.19083                169.69369
  78.15722              81.14689

i divided the first two columns in two data.frames to divide Experim and CTRs

then, i created a FOR loop to create a vector per each row containing
a vector with two values per each gene and i wanted to do a
Wilcox.test to obtain the significant genes..BUT i get a list of NULL
like you can see here
..the first row works but then i get NULL down till the end of the array...

                fc        pv
[1,] "1007_s_at" -20.248   0.4664612
[2,] "1053_at"   -344.7132 NULL
[3,] "117_at"    NULL      NULL
[4,] "121_at"    NULL      NULL
[5,] "1255_g_at" NULL      NULL
[6,] "1294_at"   NULL      NULL

the script i used is:
===================
fc=0
pv=0
for (i in 1:nrow(data))
{
	v1= c(y1[i,1], y1[i,2])	
	v2= c(y2[i,1], y2[1,2])
	fc=v1-v2
	w=t.test(v1,v2)
	pv=w$p.value
	fc[i]= w[1]
	pv[i]= w[2]
}

results = cbind(row.names(y1), fc, pv)

head(results)

================

what did i do wrong? i can't find a way around this!!!

thanks so much!!!

Seb



More information about the R-help mailing list