Thanks James, that all worked great apart from the last line:

contrast <- makeContrasts(blastomere - oocyte, blastomere - eight_cell, blastomere - four_cell, <added all my contrasts here>, levels =design)



Which produced the following error:

Error in makeContrasts(oocyte - four_cell, oocyte - eight_cell, oocyte -  :

  The levels must by syntactically valid names in R, see help(make.names).  Non-valid names: Date02/07/2013,Date06/03/2013,Date10/01/2008,Date13/02/2007,Date16/02/2007,Date23/03/2007,Date24/10/2007



Ideas?

Thank you, you have turned a frustrating day into one in which I can see light at the end of the tunnel…….



-----Original Message-----
From: James W. MacDonald [mailto:jmacdon@uw.edu]
Sent: 12 September 2013 15:01
To: Helen Smith
Cc: bioconductor@r-project.org
Subject: Re: [BioC] limma - batch dates incorrporated into t-test



Hi Helen,



On Thursday, September 12, 2013 9:02:25 AM, Helen Smith wrote:

> Hi All,

>

> I am new to limma and R programming.

>

> I have the CEL.files uploaded, normalised as an expression set, and have put together the target.txt file containing the following layout:

> Name    FileName             Target   Date

> 5              0207_DaB7_H_ea_Blast1.CEL     blastocyst            13/02/2007

> 6              0207_DaB8_H_ea_Blast2.CEL     blastocyst            13/02/2007

> 4              0207_DaB6_H_ea_4cell_r3.CEL  4cell       16/02/2007

> 16           0307_DaB1_H_ea_oocyte_r1.CEL             oocyte  23/03/2007

> 17           0307_DaB3_H_ea_oocyte_r3.CEL             oocyte  23/03/2007

> 18           0307_DaB5_H_ea_4cell_r2.CEL  4cell       23/03/2007

> 21           1007_DaB4_H_ea_4cell_r1.CEL  4cell       24/10/2007

> 22           1007_DaB9_H_ea_Blast3.CEL     blastocyst            24/10/2007

> 23           1007_DaB21_H_ea_oocyte9856.CEL        oocyte  24/10/2007

> 24           1007_DaB22_H_ea_oocyte9858.CEL        oocyte  24/10/2007

> 1              0108_DaB18_H_ea_4cell_0.9_r4.CEL       4cell       10/01/2008

> 2              0108_DaB20_H_ea_4cell_0.9_r6.CEL       4cell       10/01/2008

> 3              0108_DaB23_H_ea_Blast_2.5_r4.CEL      blastocyst            10/01/2008

> 10           0213_SueK(2)4_H_ea_005_B4.CEL           blastomere         01/03/2013

> 14           0213_SueK(2)8_H_ea_005_B8.CEL           blastomere         01/03/2013

> 15           0213_SueK(2)10_H_ea_002_8CE.CEL      8cell       01/03/2013

> 7              0213_SueK(2)1_H_ea_005_B1.CEL           blastomere         06/03/2013

> 8              0213_SueK(2)2_H_ea_005_B2.CEL           blastomere         06/03/2013

> 9              0213_SueK(2)3_H_ea_005_B3.CEL           blastomere         06/03/2013

> 11           0213_SueK(2)5_H_ea_005_B5.CEL           blastomere         06/03/2013

> 12           0213_SueK(2)6_H_ea_005_B6.CEL           blastomere         06/03/2013

> 13           0213_SueK(2)7_H_ea_005_B7.CEL           blastomere         06/03/2013

> 19           0713_Suek(3)2_Ep_H_8C_006_11.CEL    8cell       02/07/2013

> 20           0713_Suek(3)3_Ep_H_8C_004_11.CEL    8cell       02/07/2013

>

>

> But am struggling with setting up the design matrix and contrasts. My

> limited programming ability is probably playing the largest role, and

> I feel like smashing the computer against the wall (probably a sign of

> slight frustration ïŠ)



It's really quite simple ;-D. You just make a design matrix that includes the dates, and then make a contrasts matrix that doesn't use the dates to make comparisons.



The simplest way to do this is to use model.matrix() and makeContrasts().



Assume you read in your targets.txt file like so:



targets <- read.table("targets.txt", header=TRUE, stringsAsFactors =

FALSE)



we have to do the stringsAsFactors business because your 4cell and 8cell sample designations won't work with makeContrasts() (they cannot start with a number).



targets$Targets <- factor(gsub("4", "four_", gsub("8", "eight_",

targets$Targets)))



then



design <- model.matrix(~0+Target+Date, targets)



Now you probably have column names with an extra 'targets' in the name, which nobody likes, so we remove



colnames(design) <- gsub("targets", "", colnames(design))



contrast <- makeContrasts(blastomere - oocyte, blastomere - eight_cell, blastomere - four_cell, <add all the contrasts you want here>, levels =

design)



and now you proceed on to the lmFit/contrasts.fit/eBayes steps.



Best,



Jim





>

> The batch dates are included in the Target file, as I would like to

> add them as a factor when computing the T-test. But this isnâ€™t a

> contrast I would like to make on its own (does that make sense?)

>

> I would like to make all possible combinations of contrasts, listed as targets.

>

> Any help would be fantastic!!!!!

> Thank you in advance,

> Helen

>

>

>

>

>             [[alternative HTML version deleted]]

>

>

>

> _______________________________________________

> Bioconductor mailing list

> Bioconductor@r-project.org<mailto:Bioconductor@r-project.org>

> https://stat.ethz.ch/mailman/listinfo/bioconductor

> Search the archives:

> http://news.gmane.org/gmane.science.biology.informatics.conductor



--

James W. MacDonald, M.S.

Biostatistician

University of Washington

Environmental and Occupational Health Sciences

4225 Roosevelt Way NE, # 100

Seattle WA 98105-6099

	[[alternative HTML version deleted]]

