forked from RafaelRomeroGarcia/geneExpression_Repository
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstep3_individualProbe_to_geneExpression.m
59 lines (51 loc) · 1.97 KB
/
step3_individualProbe_to_geneExpression.m
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
%%%%%%%%%%%%%%
%Rafael Romero Garcia
%6th July 2017
%University of Cambridge
%Use probe data to calculate gene expression of each subject
function step3_individualProbe_to_geneExpression()
path_probe_dir='AIBS_map/downloaded/';
load([path_probe_dir '/gene_to_probe.mat'],'gene_to_probe');
load([path_probe_dir '/probe_to_gene.mat'],'probe_to_gene');
donors_name={'normalized_microarray_donor9861',...
'normalized_microarray_donor10021',...
'normalized_microarray_donor12876',...
'normalized_microarray_donor14380',...
'normalized_microarray_donor15496',...
'normalized_microarray_donor15697'};
for ifol=1:numel(donors_name)
donor_name=donors_name{ifol};
%load Probe data
path_prob=[path_probe_dir donor_name '/MicroarrayExpression.csv'];
load([path_probe_dir donor_name '/probe2gene/res_gene_symbol_tonum.mat']);
load([path_probe_dir donor_name '/probe2gene/probe_id.mat']);
%Total number of genes
numGenes=numel(unique(res_gene_symbol_tonum))-1;
fileID=fopen(path_prob);
tline=fgets(fileID);
numSamples=numel(strfind(tline,','));
expression_samples=zeros(numGenes,numSamples);
posProbe=1;
genes_iter=ones(numGenes,1);
%For each probe
while ischar(tline)
display(num2str(posProbe));
splitted=regexp(tline,'\,','split');
tline_num=str2num(tline);
tline_num=tline_num(2:end);
%Gene associated to that Probe
posGene=probe_to_gene(posProbe);
if posGene>0
%sum of the expression of all gene
%associated to that probe
expression_samples(posGene,:)=tline_num;
%Number of genes added to that probe
end
posProbe=posProbe+1;
tline=fgets(fileID);
end
%Expression sample is the average of all the expression probe associated to each gene
genes_samples=expression_samples;
save([path_probe_dir donor_name '/probe2gene/genes_samples.mat'],'genes_samples');
end