Re: [R] Calculating the t-test for each row
Using t.test() in this case will likely be very slow. A faster alternative would be to use rowttests() from the genefilter package of Bioconductor. Best, Jim Henrique Dallazuanna wrote: > You can try this: > > cbind(data.sub, p.value=apply(data.sub, 1, function(x)t.test(x)$p.value)) > > On 03/03/2008, Keizer_71 <[EMAIL PROTECTED]> wrote: >> Hi Everyone, >> >> I need some simple help. >> >> Here are my codes >> >> ##will give me 1 probesets >> data.sub = data.matrix[order(variableprobe,decreasing=TRUE),][1:1,] >> dim(data.sub) >> data_output<-write.table(data.sub, file = "c://data_output.csv", sep = ",", >> col.names = NA) >> >> When i export to excel, it shows me this. This is just a short version. >> There are 1000 rows and 140 columns >> >> Sample_1_D Sample_1_C Sample_2_D Sample_2_C >> 1 2.425509867 11.34031409 11.46868531 11.75741478 >> >> >> Here is my question: How do create a new row and calculate the t-test so >> that it will give me the p-value >> >> Here is what i am looking for. The p-value is not correct but just an >> example. It needs to calculate the entire each row. There are 1 rows and >> 140 columns. >> >> thanks >> Kei >> >> Sample_1_D Sample_1_C Sample_2_D Sample_2_Cp-value >> 1 2.425509867 11.34031409 11.46868531 11.75741478 >> .0034 >> >> I tried something like this. >> >> t.test(data.sub,mu=0) >> >> I am pretty new to R. I think it is showing me the entire p-value. >> >> >> >> -- >> View this message in context: >> http://www.nabble.com/Calculating-the-t-test-for-each-row-tp15808716p15808716.html >> Sent from the R help mailing list archive at Nabble.com. >> >> __ >> R-help@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. >> > > -- James W. MacDonald, M.S. Biostatistician Affymetrix and cDNA Microarray Core University of Michigan Cancer Center 1500 E. Medical Center Drive 7410 CCGC Ann Arbor MI 48109 734-647-5623 __ R-help@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.
Re: [R] Calculating the t-test for each row
apparently you want to check the genefilter package... it defines functions like: rowttests colttests rowFtests colFtests rowVars rowSds moreover, a quick look at Biobase is recommended... that would save you lots of time as you wouldn't have to reinvent the wheel. b On Mar 3, 2008, at 12:42 PM, Henrique Dallazuanna wrote: You can try this: cbind(data.sub, p.value=apply(data.sub, 1, function(x)t.test(x) $p.value)) On 03/03/2008, Keizer_71 <[EMAIL PROTECTED]> wrote: Hi Everyone, I need some simple help. Here are my codes ##will give me 1 probesets data.sub = data.matrix[order(variableprobe,decreasing=TRUE),] [1:1,] dim(data.sub) data_output<-write.table(data.sub, file = "c://data_output.csv", sep = ",", col.names = NA) When i export to excel, it shows me this. This is just a short version. There are 1000 rows and 140 columns Sample_1_D Sample_1_C Sample_2_D Sample_2_C 1 2.425509867 11.34031409 11.46868531 11.75741478 Here is my question: How do create a new row and calculate the t- test so that it will give me the p-value Here is what i am looking for. The p-value is not correct but just an example. It needs to calculate the entire each row. There are 1 rows and 140 columns. thanks Kei Sample_1_D Sample_1_C Sample_2_D Sample_2_Cp-value 1 2.425509867 11.34031409 11.46868531 11.75741478 .0034 I tried something like this. t.test(data.sub,mu=0) I am pretty new to R. I think it is showing me the entire p-value. -- View this message in context: http://www.nabble.com/Calculating-the-t-test-for-each-row-tp15808716p15808716.html Sent from the R help mailing list archive at Nabble.com. __ R-help@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. -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O __ R-help@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. __ R-help@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.
Re: [R] Calculating the t-test for each row
If I understand you correctly what you want to do is do t-test (mu=0) for each column of the data. Treating the data as a data.frame rather than a matrix you can do something like this and then pick out the p-values but with 140 t-tests I don't know what you'll get in terms of anything meaninful. == aa <- data.frame(a=rnorm(25, 5, 2), b=rnorm(1:25, 0,1)) mytea <- apply(aa, 2, t.test) tresults <- lapply(mytea, function(.tres) { data.frame(t.value=.tres[1],dfs=.tres[2],conf.int1=.tres$conf.int[1],conf.int2= .tres$conf.int[2],p.value=.tres[3]) }) finalresults <- do.call(rbind, tresults) = (Thanks to Mark Leeds for the lapply approach) --- Keizer_71 <[EMAIL PROTECTED]> wrote: > > Hi Everyone, > > I need some simple help. > > Here are my codes > > ##will give me 1 > probesets > data.sub = > data.matrix[order(variableprobe,decreasing=TRUE),][1:1,] > dim(data.sub) > data_output<-write.table(data.sub, file = > "c://data_output.csv", sep = ",", > col.names = NA) > > When i export to excel, it shows me this. This is > just a short version. > There are 1000 rows and 140 columns > > Sample_1_D Sample_1_C Sample_2_D Sample_2_C > 1 2.425509867 11.34031409 11.46868531 11.75741478 > > > Here is my question: How do create a new row and > calculate the t-test so > that it will give me the p-value > > Here is what i am looking for. The p-value is not > correct but just an > example. It needs to calculate the entire each row. > There are 1 rows and > 140 columns. > > thanks > Kei > > Sample_1_D Sample_1_C Sample_2_D Sample_2_C > p-value > 1 2.425509867 11.34031409 11.46868531 11.75741478 > .0034 > > I tried something like this. > > t.test(data.sub,mu=0) > > I am pretty new to R. I think it is showing me the > entire p-value. > > > > -- > View this message in context: > http://www.nabble.com/Calculating-the-t-test-for-each-row-tp15808716p15808716.html > Sent from the R help mailing list archive at > Nabble.com. > > __ > R-help@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. > __ R-help@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.
Re: [R] Calculating the t-test for each row
You can try this: cbind(data.sub, p.value=apply(data.sub, 1, function(x)t.test(x)$p.value)) On 03/03/2008, Keizer_71 <[EMAIL PROTECTED]> wrote: > > Hi Everyone, > > I need some simple help. > > Here are my codes > > ##will give me 1 probesets > data.sub = data.matrix[order(variableprobe,decreasing=TRUE),][1:1,] > dim(data.sub) > data_output<-write.table(data.sub, file = "c://data_output.csv", sep = ",", > col.names = NA) > > When i export to excel, it shows me this. This is just a short version. > There are 1000 rows and 140 columns > > Sample_1_D Sample_1_C Sample_2_D Sample_2_C > 1 2.425509867 11.34031409 11.46868531 11.75741478 > > > Here is my question: How do create a new row and calculate the t-test so > that it will give me the p-value > > Here is what i am looking for. The p-value is not correct but just an > example. It needs to calculate the entire each row. There are 1 rows and > 140 columns. > > thanks > Kei > > Sample_1_D Sample_1_C Sample_2_D Sample_2_Cp-value > 1 2.425509867 11.34031409 11.46868531 11.75741478 > .0034 > > I tried something like this. > > t.test(data.sub,mu=0) > > I am pretty new to R. I think it is showing me the entire p-value. > > > > -- > View this message in context: > http://www.nabble.com/Calculating-the-t-test-for-each-row-tp15808716p15808716.html > Sent from the R help mailing list archive at Nabble.com. > > __ > R-help@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. > -- Henrique Dallazuanna Curitiba-Paraná-Brasil 25° 25' 40" S 49° 16' 22" O __ R-help@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.
[R] Calculating the t-test for each row
Hi Everyone, I need some simple help. Here are my codes ##will give me 1 probesets data.sub = data.matrix[order(variableprobe,decreasing=TRUE),][1:1,] dim(data.sub) data_output<-write.table(data.sub, file = "c://data_output.csv", sep = ",", col.names = NA) When i export to excel, it shows me this. This is just a short version. There are 1000 rows and 140 columns Sample_1_D Sample_1_C Sample_2_D Sample_2_C 1 2.425509867 11.34031409 11.46868531 11.75741478 Here is my question: How do create a new row and calculate the t-test so that it will give me the p-value Here is what i am looking for. The p-value is not correct but just an example. It needs to calculate the entire each row. There are 1 rows and 140 columns. thanks Kei Sample_1_D Sample_1_C Sample_2_D Sample_2_Cp-value 1 2.425509867 11.34031409 11.46868531 11.75741478 .0034 I tried something like this. t.test(data.sub,mu=0) I am pretty new to R. I think it is showing me the entire p-value. -- View this message in context: http://www.nabble.com/Calculating-the-t-test-for-each-row-tp15808716p15808716.html Sent from the R help mailing list archive at Nabble.com. __ R-help@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.