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
David Winsemius
2011-Oct-26 21:45 UTC
[R] FOR loop with statistical analysis for microarray data
"affy" is a bioconductor package. You should be asking this question on the bioc mailing list. -- David. On Oct 26, 2011, at 4:56 PM, Seb wrote:> 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 > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.David Winsemius, MD West Hartford, CT
Weidong Gu
2011-Oct-26 22:56 UTC
[R] FOR loop with statistical analysis for microarray data
If you provide an example data (y1 and y2 in the loop), you might have got specific helps already. A few things in your loop seem suspicious. fc and pv are vectors, and in each loop you redesigned the whole vectors and specific indices twice. That may cause your problems. Weidong Gu On Wed, Oct 26, 2011 at 4:56 PM, Seb <seba.bat at gmail.com> wrote:> 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 > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >
y1,y2 were designed as follow,from the original data file : y1=data[,1:2] y2=data[,3:4] ...I am a bit confused with what "redesign the whole vector again" and "specify indices twice " actually mean?...could u point it out in the script? Thanks so much I really appreciate it!! Sent from my -DROID- On Oct 26, 2011 6:56 PM, "Weidong Gu" wrote:> > If you provide an example data (y1 and y2 in the loop), you might have > got specific helps already. A few things in your loop seem suspicious. > fc and pv are vectors, and in each loop you redesigned the whole > vectors and specific indices twice. That may cause your problems. > > Weidong Gu > > > > On Wed, Oct 26, 2011 at 4:56 PM, Seb <seba.bat@gmail.com> wrote: > > 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 andCTRs> > > > 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 thearray...> > > > 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 > > > > ______________________________________________ > > R-help@r-project.org mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html> > and provide commented, minimal, self-contained, reproducible code. > >[[alternative HTML version deleted]]
Possibly Parallel Threads
- [Bug 437] New: restore can segfaults when restoring corrupt policy counters
- Hierarchical Bayesian Modeling in R
- how to name the column after converting a vector to a data frame
- Binding result of a function to a data frame
- C function is wrong under Windows 7