rbbt-marq 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/R/CustomDS.R +7 -24
- data/R/GEO.R +1 -21
- data/R/MA.R +253 -223
- data/bin/marq_config +14 -10
- data/install_scripts/CustomDS/Rakefile +1 -1
- data/install_scripts/GEO/Rakefile +2 -1
- data/install_scripts/GEO/series/GSE1814.yaml +44 -0
- data/install_scripts/GEO/series/GSE21.yaml +44 -0
- data/install_scripts/GEO/series/GSE27.yaml +22 -0
- data/install_scripts/GEO/series/GSE5470.yaml +19 -0
- data/install_scripts/rake_includes.rb +22 -5
- data/lib/MARQ/CustomDS.rb +28 -32
- data/lib/MARQ/GEO.rb +77 -91
- data/lib/MARQ/ID.rb +1 -2
- data/lib/MARQ/MADB.rb +31 -25
- data/lib/MARQ/annotations.rb +3 -3
- data/lib/MARQ/main.rb +85 -26
- data/lib/MARQ/rankproduct.rb +14 -8
- metadata +6 -2
data/R/CustomDS.R
CHANGED
@@ -12,7 +12,7 @@ CustomDS.process <- function(prefix, cross_platform, conditions, description, tw
|
|
12
12
|
names = vector();
|
13
13
|
for (file in conditions) {
|
14
14
|
filename = paste(prefix,file,sep="/");
|
15
|
-
values = scan(file=filename, what=character(), sep = "\n");
|
15
|
+
values = scan(file=filename, what=character(), sep = "\n", quiet=T);
|
16
16
|
names = c(names, file);
|
17
17
|
conditions.list = cbind(conditions.list, values);
|
18
18
|
}
|
@@ -46,31 +46,14 @@ CustomDS.process <- function(prefix, cross_platform, conditions, description, tw
|
|
46
46
|
|
47
47
|
values <- MA.process(m, conditions.list, two.channel);
|
48
48
|
|
49
|
-
|
50
|
-
t = as.data.frame(values$t);
|
51
|
-
p.values = as.data.frame(values$p.values);
|
52
|
-
|
53
|
-
|
54
|
-
# Calculate orders from best information
|
55
|
-
best = vector();
|
56
|
-
names = vector();
|
57
|
-
for (name in colnames(ratios)){
|
58
|
-
if (sum(colnames(t) == name) > 0){
|
59
|
-
best = cbind(best, t[,name]);
|
60
|
-
names = c(names, name);
|
61
|
-
}else{
|
62
|
-
best = cbind(best, ratios[,name]);
|
63
|
-
names = c(names, paste(name,'[ratio]', sep=" "));
|
64
|
-
}
|
65
|
-
}
|
66
|
-
rownames(best) <- rownames(ratios);
|
67
|
-
orders = as.data.frame(MA.get_order(best));
|
68
|
-
colnames(orders) <- names;
|
69
|
-
|
70
|
-
|
71
|
-
if (is.null(values)){
|
49
|
+
if (length(values$ratios) == 0){
|
72
50
|
write(file=paste(prefix,'skip',sep="."), "no suitable samples for analysis" );
|
73
51
|
}else{
|
52
|
+
ratios = as.data.frame(values$ratios);
|
53
|
+
t = as.data.frame(values$t);
|
54
|
+
p.values = as.data.frame(values$p.values);
|
55
|
+
orders = as.data.frame(values$orders);
|
56
|
+
|
74
57
|
MA.save(prefix, orders, ratios, t, p.values, colnames(orders), description);
|
75
58
|
}
|
76
59
|
},
|
data/R/GEO.R
CHANGED
@@ -20,8 +20,6 @@ GEO.get <- function(name, cachedir = NULL){
|
|
20
20
|
object <- getGEO(name, filename = complete_path);
|
21
21
|
}
|
22
22
|
}
|
23
|
-
|
24
|
-
|
25
23
|
object
|
26
24
|
}
|
27
25
|
|
@@ -184,30 +182,12 @@ GEO.values <- function(data){
|
|
184
182
|
ratios = as.data.frame(values$ratios);
|
185
183
|
t = as.data.frame(values$t);
|
186
184
|
p.values = as.data.frame(values$p.values);
|
187
|
-
|
188
|
-
|
189
|
-
# Calculate orders from best information
|
190
|
-
best = vector();
|
191
|
-
names = vector();
|
192
|
-
for (name in colnames(ratios)){
|
193
|
-
if (sum(colnames(t) == name) > 0){
|
194
|
-
best = cbind(best, t[,name]);
|
195
|
-
names = c(names, name);
|
196
|
-
}else{
|
197
|
-
best = cbind(best, ratios[,name]);
|
198
|
-
names = c(names, paste(name,'[ratio]', sep=" "));
|
199
|
-
}
|
200
|
-
}
|
201
|
-
rownames(best) <- rownames(ratios)
|
202
|
-
orders = as.data.frame(MA.get_order(best));
|
203
|
-
colnames(orders) <- names
|
185
|
+
orders = as.data.frame(values$orders);
|
204
186
|
|
205
187
|
return(list(ratios = ratios, t = t, p.values = p.values, orders = orders));
|
206
188
|
}
|
207
189
|
}
|
208
190
|
|
209
|
-
|
210
|
-
|
211
191
|
GEO.GDS.process <- function(name, prefix, id.field = NULL, translation.file = NULL,cachedir=NULL){
|
212
192
|
tryCatch(
|
213
193
|
{
|
data/R/MA.R
CHANGED
@@ -5,20 +5,19 @@ MA.get_order <- function(values){
|
|
5
5
|
orders[,] = NA;
|
6
6
|
|
7
7
|
for (i in 1:dim(values)[2]){
|
8
|
-
positions = names(sort(values[,i],decreasing=T))
|
9
|
-
|
10
|
-
orders[,i] = NA
|
8
|
+
positions = names(sort(values[,i],decreasing=T,na.last=NA));
|
9
|
+
orders[,i] = NA;
|
11
10
|
orders[positions,i] = 1:length(positions)
|
12
11
|
}
|
13
12
|
orders
|
14
13
|
}
|
15
14
|
|
16
15
|
MA.guess.do.log2 <- function(m, two.channel){
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
16
|
+
if (two.channel){
|
17
|
+
return (sum(m < 0, na.rm = TRUE) == 0);
|
18
|
+
}else{
|
19
|
+
return (max(m, na.rm = TRUE) > 100);
|
20
|
+
}
|
22
21
|
}
|
23
22
|
|
24
23
|
MA.translate <- function(m, trans){
|
@@ -27,17 +26,16 @@ MA.translate <- function(m, trans){
|
|
27
26
|
|
28
27
|
missing = length(trans) - dim(m)[1];
|
29
28
|
|
30
|
-
|
29
|
+
# If extra genes
|
31
30
|
if (missing < 0){
|
32
|
-
|
33
|
-
|
31
|
+
trans = c(trans,rep(NA, - missing));
|
32
|
+
missing = 0;
|
34
33
|
}
|
35
34
|
n = apply(m,2,function(x){
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
});
|
35
|
+
# Complete data with missing genes
|
36
|
+
x.complete = c(x,rep(NA, missing));
|
37
|
+
tapply(x.complete, factor(trans), median)
|
38
|
+
});
|
41
39
|
n[sort(rownames(n),index.return=T)$ix,]
|
42
40
|
}
|
43
41
|
|
@@ -46,10 +44,10 @@ MA.translate <- function(m, trans){
|
|
46
44
|
MA.conditions.has_control <- function(x){
|
47
45
|
keywords = c('none', 'control', 'normal', 'wild', 'baseline', 'untreat', 'uninfected', 'universal', 'reference', 'vehicle', 'w.t.','wt');
|
48
46
|
for(keyword in keywords){
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
47
|
+
control = grep(keyword, x, ignore.case = TRUE);
|
48
|
+
if (any(control)){
|
49
|
+
return(x[control[1]]);
|
50
|
+
}
|
53
51
|
}
|
54
52
|
return(NULL)
|
55
53
|
}
|
@@ -60,18 +58,18 @@ MA.condition.values <- function(values){
|
|
60
58
|
values.factor = factor(values);
|
61
59
|
values.levels = levels(values.factor);
|
62
60
|
|
63
|
-
|
61
|
+
# If there is a control state remove it from sorting
|
64
62
|
if (!is.null(control))
|
65
63
|
values.levels = values.levels[values.levels != control];
|
66
64
|
|
67
|
-
|
68
|
-
|
65
|
+
|
66
|
+
# Use numeric sort if they all have numbers
|
69
67
|
if (length(grep('^ *[0-9]+',values.levels,perl=TRUE)) == length(values.levels)){
|
70
68
|
ix = sort(as.numeric(sub('^ *([0-9]+).*',"\\1",values.levels)), decreasing = T, index.return = TRUE)$ix
|
71
69
|
}else{
|
72
70
|
ix = sort(values.levels, decreasing = T, index.return = TRUE)$ix
|
73
71
|
}
|
74
|
-
|
72
|
+
|
75
73
|
return(list(values = values.levels[ix], control = control));
|
76
74
|
}
|
77
75
|
|
@@ -98,7 +96,7 @@ MA.ratio.contrast <- function(m, conditions, main, contrast){
|
|
98
96
|
if (!is.null(dim(contrast))){
|
99
97
|
contrast = apply(contrast, 1 ,function(x){mean(x, na.rm = TRUE)});
|
100
98
|
}
|
101
|
-
|
99
|
+
|
102
100
|
return (main - contrast);
|
103
101
|
}
|
104
102
|
|
@@ -106,173 +104,204 @@ MA.ratio.contrast <- function(m, conditions, main, contrast){
|
|
106
104
|
# Limma
|
107
105
|
|
108
106
|
MA.limma.two_channel <- function(m, conditions, main){
|
109
|
-
|
107
|
+
if (sum(conditions == main) < 3){
|
108
|
+
return(NULL);
|
109
|
+
}
|
110
|
+
|
111
|
+
design = rep(0,dim(m)[2]);
|
112
|
+
design[conditions == main] = 1;
|
113
|
+
|
114
|
+
# We need to subset the columns because of a problem with NA values. This
|
115
|
+
# might affect eBayes variance estimations, thats my guess anyway...
|
116
|
+
|
117
|
+
fit <- lmFit(m[,design == 1],rep(1, sum(design)));
|
118
|
+
|
119
|
+
tryCatch({
|
120
|
+
fit <- eBayes(fit);
|
121
|
+
sign = fit$t < 0;
|
122
|
+
sign[is.na(sign)] = FALSE;
|
123
|
+
fit$p.value[sign] = - fit$p.value[sign];
|
124
|
+
return(list(t= fit$t, p.values= fit$p.value));
|
125
|
+
}, error=function(x){
|
126
|
+
print("Exception caught in eBayes");
|
127
|
+
print(x);
|
128
|
+
})
|
129
|
+
|
110
130
|
return(NULL);
|
111
|
-
}
|
112
|
-
|
113
|
-
design = rep(0,dim(m)[2]);
|
114
|
-
design[conditions == main] = 1;
|
115
|
-
|
116
|
-
# We need to subset the columns because of a problem with NA values. This
|
117
|
-
# might affect eBayes variance estimations, thats my guess anyway...
|
118
|
-
|
119
|
-
fit <- lmFit(m[,design == 1],rep(1, sum(design)));
|
120
|
-
|
121
|
-
tryCatch({
|
122
|
-
fit <- eBayes(fit);
|
123
|
-
sign = fit$t < 0;
|
124
|
-
sign[is.na(sign)] = FALSE;
|
125
|
-
fit$p.value[sign] = - fit$p.value[sign];
|
126
|
-
return(list(t= fit$t, p.values= fit$p.value));
|
127
|
-
}, error=function(x){
|
128
|
-
print("Exception caught in eBayes");
|
129
|
-
print(x);
|
130
|
-
})
|
131
|
-
|
132
|
-
return(NULL);
|
133
131
|
}
|
134
132
|
|
135
133
|
MA.limma.contrast <- function(m, conditions, main, contrast){
|
136
|
-
|
134
|
+
if (sum(conditions == main) + sum(conditions == contrast) < 3){
|
135
|
+
return(NULL);
|
136
|
+
}
|
137
|
+
m = cbind(m[,conditions == main],m[,conditions == contrast]);
|
138
|
+
|
139
|
+
design = cbind(rep(1,dim(m)[2]), rep(0,dim(m)[2]));
|
140
|
+
colnames(design) <-c('intercept', 'main');
|
141
|
+
design[1:sum(conditions==main),2] = 1;
|
142
|
+
|
143
|
+
|
144
|
+
fit <- lmFit(m,design);
|
145
|
+
tryCatch({
|
146
|
+
fit <- eBayes(fit);
|
147
|
+
sign = fit$t[,2] < 0;
|
148
|
+
sign[is.na(sign)] = FALSE;
|
149
|
+
fit$p.value[sign,2] = - fit$p.value[sign,2]
|
150
|
+
return(list(t= fit$t[,2], p.values= fit$p.value[,2] ));
|
151
|
+
}, error=function(x){
|
152
|
+
print("Exception caught in eBayes");
|
153
|
+
print(x);
|
154
|
+
})
|
155
|
+
|
137
156
|
return(NULL);
|
138
|
-
}
|
139
|
-
m = cbind(m[,conditions == main],m[,conditions == contrast])
|
140
|
-
|
141
|
-
design = cbind(rep(1,dim(m)[2]), rep(0,dim(m)[2]));
|
142
|
-
colnames(design) <-c('intercept', 'main');
|
143
|
-
design[1:sum(conditions==main),2] = 1;
|
144
|
-
|
145
|
-
|
146
|
-
fit <- lmFit(m,design);
|
147
|
-
tryCatch({
|
148
|
-
fit <- eBayes(fit);
|
149
|
-
sign = fit$t[,2] < 0;
|
150
|
-
sign[is.na(sign)] = FALSE;
|
151
|
-
fit$p.value[sign,2] = - fit$p.value[sign,2]
|
152
|
-
return(list(t= fit$t[,2], p.values= fit$p.value[,2] ));
|
153
|
-
}, error=function(x){
|
154
|
-
print("Exception caught in eBayes");
|
155
|
-
print(x);
|
156
|
-
})
|
157
|
-
|
158
|
-
return(NULL);
|
159
157
|
}
|
160
158
|
|
161
159
|
|
162
160
|
#########################################################################
|
163
161
|
# Process conditions
|
164
162
|
|
163
|
+
MA.strip_blanks <- function(text){
|
164
|
+
text = sub(' *$', '' ,text);
|
165
|
+
text = sub('^ *', '' ,text);
|
166
|
+
|
167
|
+
return(text);
|
168
|
+
}
|
169
|
+
|
170
|
+
MA.orders <- function(ratios, t){
|
171
|
+
best = vector();
|
172
|
+
names = vector();
|
173
|
+
for (name in colnames(ratios)){
|
174
|
+
if (sum(colnames(t) == name) > 0){
|
175
|
+
best = cbind(best, t[,name]);
|
176
|
+
names = c(names, name);
|
177
|
+
}else{
|
178
|
+
best = cbind(best, ratios[,name]);
|
179
|
+
names = c(names, paste(name,'[ratio]', sep=" "));
|
180
|
+
}
|
181
|
+
}
|
182
|
+
rownames(best) <- rownames(ratios);
|
183
|
+
orders <- as.data.frame(MA.get_order(best));
|
184
|
+
colnames(orders) <- names;
|
185
|
+
|
186
|
+
return(orders);
|
187
|
+
}
|
188
|
+
|
165
189
|
MA.process_conditions.contrasts <- function(m, conditions, two.channel){
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
190
|
+
max_levels = 10;
|
191
|
+
max_levels_control = 1;
|
192
|
+
|
193
|
+
|
194
|
+
values = MA.condition.values(conditions);
|
195
|
+
|
196
|
+
|
197
|
+
ratios = vector();
|
198
|
+
t = vector();
|
199
|
+
p.values = vector();
|
200
|
+
|
201
|
+
ratio_names = vector();
|
202
|
+
t_names = vector();
|
203
|
+
|
204
|
+
if (!is.null(values$control)){
|
205
|
+
contrast = values$control;
|
206
|
+
for (main in values$values){
|
207
|
+
name = paste(main, contrast, sep = " <=> ")
|
208
|
+
|
209
|
+
ratio = MA.ratio.contrast(m, conditions, main, contrast);
|
210
|
+
ratio_names = c(ratio_names, name);
|
211
|
+
ratios = cbind(ratios, ratio);
|
212
|
+
|
213
|
+
res = MA.limma.contrast(m, conditions, main, contrast);
|
214
|
+
if (!is.null(res)){
|
215
|
+
t_names = c(t_names, name);
|
216
|
+
t = cbind(t, res$t);
|
217
|
+
p.values = cbind(p.values, res$p.values);
|
218
|
+
}
|
219
|
+
}
|
220
|
+
}
|
221
|
+
|
222
|
+
|
223
|
+
if (length(values$values) <= max_levels_control || (is.null(values$control) && !two.channel && length(values$values) <= max_levels )){
|
224
|
+
|
225
|
+
remaining = values$values;
|
226
|
+
for (main in values$values){
|
227
|
+
remaining = remaining[remaining != main];
|
228
|
+
for (contrast in remaining){
|
229
|
+
name = paste(main, contrast, sep = " <=> ");
|
230
|
+
|
231
|
+
ratio = MA.ratio.contrast(m, conditions, main, contrast);
|
232
|
+
ratio_names = c(ratio_names, name);
|
233
|
+
ratios = cbind(ratios, ratio);
|
234
|
+
|
235
|
+
res = MA.limma.contrast(m, conditions, main, contrast);
|
236
|
+
if (!is.null(res)){
|
237
|
+
t_names = c(t_names, name);
|
238
|
+
t = cbind(t, res$t);
|
239
|
+
p.values = cbind(p.values, res$p.values);
|
240
|
+
}
|
241
|
+
}
|
242
|
+
}
|
243
|
+
}
|
244
|
+
|
245
|
+
|
246
|
+
if (length(ratio_names) != 0){
|
247
|
+
ratio_names = as.vector(sapply(ratio_names, MA.strip_blanks));
|
248
|
+
colnames(ratios) <- ratio_names
|
249
|
+
}
|
250
|
+
|
251
|
+
if (length(t_names) != 0){
|
252
|
+
t_names = as.vector(sapply(t_names, MA.strip_blanks));
|
253
|
+
colnames(t) <- t_names;
|
254
|
+
colnames(p.values) <- t_names;
|
255
|
+
}
|
256
|
+
|
257
|
+
|
258
|
+
return(list(ratios = ratios, t=t, p.values = p.values));
|
232
259
|
}
|
233
260
|
|
234
261
|
MA.process_conditions.two_channel <- function(m, conditions){
|
235
|
-
|
262
|
+
values = MA.condition.values(conditions);
|
263
|
+
|
264
|
+
all_values = values$values;
|
265
|
+
if (!is.null(values$control)){
|
266
|
+
all_values = c(all_values, values$control);
|
267
|
+
}
|
236
268
|
|
237
|
-
all_values = values$values
|
238
|
-
if (!is.null(values$control)){
|
239
|
-
all_values = c(all_values, values$control);
|
240
|
-
}
|
241
|
-
|
242
269
|
|
243
|
-
|
244
|
-
|
245
|
-
|
270
|
+
ratios = vector();
|
271
|
+
t = vector();
|
272
|
+
p.values = vector();
|
246
273
|
|
247
|
-
|
248
|
-
|
274
|
+
ratio_names = vector();
|
275
|
+
t_names = vector();
|
249
276
|
|
250
277
|
|
251
|
-
|
252
|
-
|
278
|
+
for (main in all_values){
|
279
|
+
name = main;
|
253
280
|
|
254
|
-
|
255
|
-
|
256
|
-
|
281
|
+
ratio = MA.ratio.two_channel(m, conditions, main);
|
282
|
+
ratio_names = c(ratio_names, name);
|
283
|
+
ratios = cbind(ratios, ratio);
|
257
284
|
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
285
|
+
res = MA.limma.two_channel(m, conditions, main);
|
286
|
+
if (!is.null(res)){
|
287
|
+
t_names = c(t_names, name);
|
288
|
+
t = cbind(t, res$t);
|
289
|
+
p.values = cbind(p.values, res$p.values);
|
290
|
+
}
|
291
|
+
}
|
265
292
|
|
266
|
-
|
267
|
-
|
268
|
-
|
293
|
+
if (length(ratio_names) != 0){
|
294
|
+
ratio_names = as.vector(sapply(ratio_names, MA.strip_blanks));
|
295
|
+
colnames(ratios) <- ratio_names
|
296
|
+
}
|
269
297
|
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
298
|
+
if (length(t_names) != 0){
|
299
|
+
t_names = as.vector(sapply(t_names, MA.strip_blanks));
|
300
|
+
colnames(t) <- t_names;
|
301
|
+
colnames(p.values) <- t_names;
|
302
|
+
}
|
274
303
|
|
275
|
-
|
304
|
+
return(list(ratios = ratios, t=t, p.values = p.values));
|
276
305
|
}
|
277
306
|
|
278
307
|
|
@@ -280,35 +309,36 @@ MA.process_conditions.two_channel <- function(m, conditions){
|
|
280
309
|
# Process microarray matrix
|
281
310
|
|
282
311
|
MA.process <- function(m, conditions_list, two.channel = FALSE){
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
312
|
+
|
313
|
+
ratios = vector();
|
314
|
+
t = vector();
|
315
|
+
p.values = vector();
|
316
|
+
|
317
|
+
for(type in colnames(conditions_list)){
|
318
|
+
conditions = conditions_list[,type]
|
319
|
+
|
320
|
+
if (two.channel){
|
321
|
+
res = MA.process_conditions.two_channel(m, conditions);
|
322
|
+
if (length(res$ratios) != 0){ colnames(res$ratios) <- sapply(colnames(res$ratios),function(x){paste(type,x,sep=": ")}); ratios = cbind(ratios,res$ratios);}
|
323
|
+
if (length(res$t) != 0){ colnames(res$t) <- sapply(colnames(res$t),function(x){paste(type,x,sep=": ")}); t = cbind(t,res$t);}
|
324
|
+
if (length(res$p.values) != 0){ colnames(res$p.values) <- sapply(colnames(res$p.values),function(x){paste(type,x,sep=": ")}); p.values = cbind(p.values,res$p.values);}
|
325
|
+
}
|
326
|
+
|
327
|
+
res = MA.process_conditions.contrasts(m, conditions, two.channel);
|
328
|
+
if (length(res$ratios) != 0){ colnames(res$ratios) <- sapply(colnames(res$ratios),function(x){paste(type,x,sep=": ")}); ratios = cbind(ratios,res$ratios);}
|
329
|
+
if (length(res$t) != 0){ colnames(res$t) <- sapply(colnames(res$t),function(x){paste(type,x,sep=": ")}); t = cbind(t,res$t);}
|
330
|
+
if (length(res$p.values) != 0){ colnames(res$p.values) <- sapply(colnames(res$p.values),function(x){paste(type,x,sep=": ")}); p.values = cbind(p.values,res$p.values);}
|
331
|
+
}
|
332
|
+
|
333
|
+
orders <- MA.orders(ratios,t);
|
334
|
+
return(list(ratios = ratios, t=t, p.values = p.values, orders=orders));
|
305
335
|
}
|
306
336
|
|
307
337
|
|
308
338
|
MA.save <- function(prefix, orders, ratios, t , p.values, experiments, description = NULL) {
|
309
339
|
if (is.null(orders)){
|
310
340
|
cat("No suitable samples for analysis\n")
|
311
|
-
|
341
|
+
write(file=paste(prefix,'skip',sep="."), "No suitable samples for analysis" );
|
312
342
|
} else {
|
313
343
|
write.table(file=paste(prefix,'orders',sep="."), orders, sep="\t", row.names=F, col.names=F, quote=F);
|
314
344
|
write.table(file=paste(prefix,'codes',sep="."), rownames(orders), sep="\t", row.names=F, col.names=F, quote=F);
|
@@ -322,39 +352,39 @@ MA.save <- function(prefix, orders, ratios, t , p.values, experiments, descripti
|
|
322
352
|
}
|
323
353
|
|
324
354
|
MA.load <- function(prefix, orders = TRUE, logratios = TRUE, t = TRUE, p.values = TRUE){
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
355
|
+
data = list();
|
356
|
+
genes <- scan(file=paste(prefix,'codes',sep="."),sep="\n",quiet=T,what=character());
|
357
|
+
experiments <- scan(file=paste(prefix,'experiments',sep="."),sep="\n",quiet=T,what=character());
|
358
|
+
|
359
|
+
experiments.no.ratio = experiments[- grep('ratio', experiments)];
|
360
|
+
|
361
|
+
if (orders){
|
362
|
+
orders <- read.table(file=paste(prefix,'orders',sep="."),sep="\t");
|
363
|
+
rownames(orders) <- genes;
|
364
|
+
colnames(orders) <- experiments;
|
365
|
+
data$orders=orders;
|
366
|
+
}
|
367
|
+
if (logratios){
|
368
|
+
logratios <- read.table(file=paste(prefix,'logratios',sep="."),sep="\t");
|
369
|
+
rownames(logratios) <- genes;
|
370
|
+
colnames(logratios) <- experiments;
|
371
|
+
data$logratios=logratios;
|
372
|
+
}
|
373
|
+
if (t){
|
374
|
+
t <- read.table(file=paste(prefix,'t',sep="."),sep="\t");
|
375
|
+
rownames(t) <- genes;
|
376
|
+
colnames(t) <- experiments.no.ratio;
|
377
|
+
data$t=t;
|
378
|
+
}
|
379
|
+
if (p.values){
|
380
|
+
p.values <- read.table(file=paste(prefix,'pvalues',sep="."),sep="\t");
|
381
|
+
rownames(p.values) <- genes;
|
382
|
+
colnames(p.values) <- experiments.no.ratio;
|
383
|
+
data$p.values=p.values;
|
384
|
+
}
|
385
|
+
|
386
|
+
|
387
|
+
return(data);
|
358
388
|
|
359
389
|
|
360
390
|
}
|