So I am using r, with the packages Bioconductor (oligo), (limma) to analyze some microarray data.
I am having trouble in the paired analysis.
So this is my phenotype data
ph@data
ph@data
index filename group
WT1 WT WT1 WT
WT2 WT WT2 WT
WT3 WT WT3 WT
WT4 WT WT4 WT
LT1 LT LT1 LT
LT2 LT LT2 LT
LT3 LT LT3 LT
LT4 LT LT4 LT
TG1 TG TG1 TG
TG2 TG TG2 TG
TG3 TG TG3 TG
TG4 TG TG4 TG
So to analyze I made this code:
colnames(ph@data)[2]="source"
ph@data
groups = ph@data$source
f = factor(groups,levels = c("WT","LT","TG"))
design = model.matrix(~ 0 + f)
colnames(design)=c("WT","LT","TG")
design
data.fit = lmFit(normData,design)
> design
WT LT TG
1 1 0 0
2 1 0 0
3 1 0 0
4 1 0 0
5 0 1 0
6 0 1 0
7 0 1 0
8 0 1 0
9 0 0 1
10 0 0 1
11 0 0 1
12 0 0 1
attr(,"assign")
[1] 1 1 1
attr(,"contrasts")
attr(,"contrasts")$f
[1] "contr.treatment"
Then I sue this to compare between my groups:
contrast.matrix = makeContrasts(LT-WT,TG-WT,LT-TG,levels=design)
data.fit.con = contrasts.fit(data.fit,contrast.matrix)
data.fit.eb = eBayes(data.fit.con)
So after all this I want to compare my groups:
ph@data[ ,2] = c("control","control","control","control","littermate","littermate","littermate","littermate","transgenic","transgenic","transgenic","transgenic")
colnames(ph@data)[2]="Treatment"
ph@data[ ,3] = c("B1","B2","B3","B4","B1","B2","B3","B4","B1","B2","B3","B4")
colnames(ph@data)[3]="BioRep"
ph@data```
groupsB = ph@data$BioRep
groupsT = ph@data$Treatment
fb = factor(groupsB,levels=c("B1","B2","B3","B4"))
ft = factor(groupsT,levels=c("control","littermate","transgenic"))```
paired.design = (~ fb + ft)
So now my phenoData looks like this:
index Treatment BioRep
WT1 WT control B1
WT2 WT control B2
WT3 WT control B3
WT4 WT control B4
LT1 LT littermate B1
LT2 LT littermate B2
LT3 LT littermate B3
LT4 LT littermate B4
TG1 TG transgenic B1
TG2 TG transgenic B2
TG3 TG transgenic B3
TG4 TG transgenic B4```
B1 is the bioreplicates, then I have the groups that are wild type, littermate and transgenic
to compare my samples I am trying this
colnames(paired.design)=c("Intercept","B4vsB1","B3vsB1","B2vsB1","B4vsB2","B3vsB2","B4vsB3","littermatevscontrol","transgenicvscontrol")
But then I got this error:
Error in `colnames<-`(`*tmp*`, value = c("Intercept", "WTvsLT", "WTvsTG", :
attempt to set 'colnames' on an object with less than two dimensions
What I am doing wrong, and this is the right way to compare my data?
data.fit = lmFit(data.rma,paired.design)
data.fit$coefficients