With great help from dpryan I have come a long way, but now Im stuck again. I need to be able to calculated both within and between samples. I have two groups at two time points, the data is paired within samples, but not between:
sampleFiles <- list.files(path="/Volumes/timemachine/HTseq_DEseq2",pattern="*.txt");
status <- factor(c(rep("Healthy",26), rep("Diabetic",22)))
timepoints = as.factor(c(1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2));
sampleTable <- data.frame(sampleName = sampleFiles, fileName = sampleFiles, status=status, timepoints=timepoints);
directory <- c("/Volumes/timemachine/HTseq_DEseq2/");
des <- formula(~timepoints+status);
ddsHTSeq <- DESeqDataSetFromHTSeqCount(sampleTable = sampleTable, directory = directory, design=des);
ddsHTSeq
These commands all work, but they are incorrect due to not taken the paired data in account.
So I looked here: page 49; http://www.bioconductor.org/packages...usersguide.pdf
So I tried instead;
Treat <- factor(paste(sampleTable$status,sampleTable$timepoints,sep=""));
design <- model.matrix(~0+Treat);
colnames(design) <- levels(Treat);
> design
Diabetic1 Diabetic2 Healthy1 Healthy2
1 0 0 1 0
2 0 0 1 0
3 0 0 1 0
4 0 0 1 0
5 0 0 1 0
6 0 0 1 0
7 0 0 1 0
8 0 0 1 0
9 0 0 1 0
10 0 0 1 0
11 0 0 1 0
12 0 0 1 0
13 0 0 1 0
14 0 0 0 1
15 0 0 0 1
16 0 0 0 1
17 0 0 0 1
18 0 0 0 1
19 0 0 0 1
20 0 0 0 1
21 0 0 0 1
22 0 0 0 1
23 0 0 0 1
24 0 0 0 1
25 0 0 0 1
26 0 0 0 1
27 1 0 0 0
28 1 0 0 0
29 1 0 0 0
30 1 0 0 0
31 1 0 0 0
32 1 0 0 0
33 1 0 0 0
34 1 0 0 0
35 1 0 0 0
36 1 0 0 0
37 1 0 0 0
38 0 1 0 0
39 0 1 0 0
40 0 1 0 0
41 0 1 0 0
42 0 1 0 0
43 0 1 0 0
44 0 1 0 0
45 0 1 0 0
46 0 1 0 0
47 0 1 0 0
48 0 1 0 0
attr(,"assign")
[1] 1 1 1 1
attr(,"contrasts")
attr(,"contrasts")$Treat
[1] "contr.treatment"
However my "old" design, the "des", looks like this:
> des
~timepoints + status
Running with "new" design:
ddsHTSeq <- DESeqDataSetFromHTSeqCount(sampleTable = sampleTable, directory = directory, design=design)
Gives error:
Error in formula.default(design) : invalid formula
Not to suprising.. But Im stuck, what to do? Am I totally of?
Thanks!
sampleFiles <- list.files(path="/Volumes/timemachine/HTseq_DEseq2",pattern="*.txt");
status <- factor(c(rep("Healthy",26), rep("Diabetic",22)))
timepoints = as.factor(c(1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2));
sampleTable <- data.frame(sampleName = sampleFiles, fileName = sampleFiles, status=status, timepoints=timepoints);
directory <- c("/Volumes/timemachine/HTseq_DEseq2/");
des <- formula(~timepoints+status);
ddsHTSeq <- DESeqDataSetFromHTSeqCount(sampleTable = sampleTable, directory = directory, design=des);
ddsHTSeq
These commands all work, but they are incorrect due to not taken the paired data in account.
So I looked here: page 49; http://www.bioconductor.org/packages...usersguide.pdf
So I tried instead;
Treat <- factor(paste(sampleTable$status,sampleTable$timepoints,sep=""));
design <- model.matrix(~0+Treat);
colnames(design) <- levels(Treat);
> design
Diabetic1 Diabetic2 Healthy1 Healthy2
1 0 0 1 0
2 0 0 1 0
3 0 0 1 0
4 0 0 1 0
5 0 0 1 0
6 0 0 1 0
7 0 0 1 0
8 0 0 1 0
9 0 0 1 0
10 0 0 1 0
11 0 0 1 0
12 0 0 1 0
13 0 0 1 0
14 0 0 0 1
15 0 0 0 1
16 0 0 0 1
17 0 0 0 1
18 0 0 0 1
19 0 0 0 1
20 0 0 0 1
21 0 0 0 1
22 0 0 0 1
23 0 0 0 1
24 0 0 0 1
25 0 0 0 1
26 0 0 0 1
27 1 0 0 0
28 1 0 0 0
29 1 0 0 0
30 1 0 0 0
31 1 0 0 0
32 1 0 0 0
33 1 0 0 0
34 1 0 0 0
35 1 0 0 0
36 1 0 0 0
37 1 0 0 0
38 0 1 0 0
39 0 1 0 0
40 0 1 0 0
41 0 1 0 0
42 0 1 0 0
43 0 1 0 0
44 0 1 0 0
45 0 1 0 0
46 0 1 0 0
47 0 1 0 0
48 0 1 0 0
attr(,"assign")
[1] 1 1 1 1
attr(,"contrasts")
attr(,"contrasts")$Treat
[1] "contr.treatment"
However my "old" design, the "des", looks like this:
> des
~timepoints + status
Running with "new" design:
ddsHTSeq <- DESeqDataSetFromHTSeqCount(sampleTable = sampleTable, directory = directory, design=design)
Gives error:
Error in formula.default(design) : invalid formula
Not to suprising.. But Im stuck, what to do? Am I totally of?
Thanks!
Comment