Dear Tania,
An option would be splitting  the data by marker and the perform the
chi-square test selecting both the statistics and p-value for each marker.
Here is an example:

# Dummy data set
mydata=read.table(textConnection("
Marker Treatment Genotype1 Genotype2 Genotype3
1        A         23        57        32
1        B         43        59        12
2        A         13        27        12
2        B         23        29        22"),header=TRUE)


# Chi-square
res=lapply(split(mydata,mydata$Marker),function(x){
res=chisq.test(x[,-c(1,2)]) # Deleting columns 1 and 2 of every list
res=c(res$statistic,res$p.value)
names(res)=c('statistic','pvalue')
res
}
)

# The output
res2=do.call(rbind,res)
rownames(res2)=paste('marker_',1:length(res),sep="")
res2
# statistic       pvalue
#marker_1 15.169487 0.0005081452
#marker_2  2.010403 0.3659709476


HTH,

Jorge



On Sun, Nov 9, 2008 at 4:14 PM, QUESADA,TANIA <[EMAIL PROTECTED]> wrote:

> Hi,
>
> I am new to R and I need to perform multiple chi-square tests.  I manage to
> perform one at a time, but is there a specific command to do multiple tests?
>
> For example, I have a table that looks like this:
>
> Marker Treatment Genotype1 Genotype2 Genotype3
> 1        A         23        57        32
> 1        B         43        59        12
> ...
> ...
> n        A         ##        ##        ##
> n        B         ##        ##        ##
>
> I can perform an individual chi-square test for marker 1, but if n is too
> large (i.e. 4000 markers), I would like to write the code to make it perform
> tests for each marker types and give me an output table with the p-values
> for each markers.
>
> I would appreciate any suggestions you may have.
>
> Thanks!
>
> Tania Quesada
>
>
>
> --
> QUESADA,TANIA
>
> ______________________________________________
> 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.
>

        [[alternative HTML version deleted]]

______________________________________________
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.

Reply via email to