-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmt_read_R_exprs.m
More file actions
70 lines (62 loc) · 1.85 KB
/
mt_read_R_exprs.m
File metadata and controls
70 lines (62 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
%MT_READ_R_EXPRS - Read summarized data from R data file
% E = MT_WRITE_R_EXPRS(probes,filename)
%
% INPUT
% PROBES Probe structure into which to load summarized data
% Overwrites overall_factors and array_factors,
% matches array names in R file to array names in probes structure,
% and probeset names to probeset names in probes structure.
% FILENAME file to read from
%
% SEE ALSO
% MT_WRITE_R_EXPRS
%
% (c) Marc Hulsman, 2010
% Information & Communication Theory Group
% Faculty of Electrical Engineering, Mathematics and Computer Science
% Delft University of Technology, Mekelweg 4, 2628 CD Delft, The Netherlands
function probes = mt_read_R_exprs(probes,fname)
%read array names
f = fopen(fname,'r');
frewind(f);
tmp = fgetl(f);
%process array names
start = regexp(tmp,'([\w\.]+)');
if(length(strfind(lower(tmp),'.cel')) > 0)
stop = [start(2:end) - 6 length(tmp) - 4];
else
stop = [start(2:end) - 2 length(tmp)];
end;
array_names = {};
for i = 1:length(start)
array_names{i} = tmp(start(i):stop(i));
end;
%read probe names
tmp = textscan(f,'%s%*[^\n]','BufSize',64 * 1024 * 1024);
probe_names = tmp{1};
fclose(f);
%read data
values = dlmread(fname,'\t',1,1);
%matches probes names
probes_idx = [];
for i = 1:length(probe_names);
probes_idx(find(strcmp(probe_names{i},probes.name))) = i;
end;
%matches array names
acounter = 1;
for i = 1:length(array_names)
t = find(cellfun(@length,strfind(probes.array_filenames,array_names{i})));
if(length(t) > 0)
array_idx(t) = acounter;
acounter = acounter + 1;
end;
end;
%determine data
sv = values(probes_idx,array_idx)';
%perform log2 scaling if necessary
if(max(max(sv)) > 50)
sv = log2(sv);
end;
%set variables
probes.overall_factors = mean(sv);
probes.array_factors = sv - repmat(probes.overall_factors,length(probes.array_names),1);