Re: [R] automating aov function

About this list Date view Thread view Subject view Author view Attachment view

From: Michael Morley (mmorley@mail.med.upenn.edu)
Date: Thu 27 May 2004 - 22:46:32 EST


Message-id: <40B5E328.4070600@mail.med.upenn.edu>

If you want a matrix (perhaps a data.frame so you can add different data
types(gene name, accession, etc) of just the F and Ps from each anova.
Something like this works for me. Though I'm a newbie too, so if there
is a better way someone let me know!
----------------------
#create 2 by # genes matrix, can add row names or col names
#precomputing your matrix will save some computational time as compare
to rbind
#assume genes is some matrix or data.frame

results <- matrix(ncol=2, nrow=length(genes[,1]))

for(i in 1:length(genes[,1]){
     an <- anova(lm(formula,data))
     results[i,] <- c(an$F[1], an$P[1] )
}

------------------

Don't forget about the multiple testing!

-Mike

Joshi, Nina (NIH/NCI) wrote:

>
>
>I am running the aov function to determine the linear relationship between
>individual genes and a number of covariates in a micro-array data set. My
>aov function is working, but I have not been able to write a code to save
>these results in a matrix. I am using the following code or a slight
>variation of this code:
>
>
>
>for(i in 1(length(m[1,])-20)
>
>
>
>{tmp<- aov(m[,i]~treat, data=m)
>
>
>
>{results [i] <- tmp}}
>
>
>
>Any help would be appreciated.
>
>
>
>
>
>Thanks,
>
>
>
>Nina
>
>
>
>
>
>Nina Joshi, PhD
>
>NIH/NCI/ Genetics Branch
>
>National Naval Medical Center, Bldg. 8, Rm. 5101
>
>8901 Wisconsin Ave.
>
>Bethesda, MD. 20889-5101
>
>(301) 435-5436 - phone
>
>(301) 496-0047 - fax
>
>
>
>
>
>
> [[alternative HTML version deleted]]
>
>______________________________________________
>R-help@stat.math.ethz.ch mailing list
>https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>
>

-- 
Michael Morley
Bioinformatics Specialist
University of Pennsylvania
Department of Pediatrics
3516 Civic Center Blvd.,
510B Abramson Pediatric Research Center,
Philadelphia, PA 19104-4318.
Phone: (215) 590-7673
FAX: (215) 590-3709

______________________________________________ R-help@stat.math.ethz.ch mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


About this list Date view Thread view Subject view Author view Attachment view

This archive was generated by hypermail 2.1.3 : Mon 31 May 2004 - 23:05:13 EST