-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNumbering.asv
42 lines (34 loc) · 1.29 KB
/
Numbering.asv
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
function[input_data]=Numbering(scdataset, path,printLevel, cell_index )
%% Loading/Importing the data
if printLevel==1
mkdir ([path,'/Numbered'])
end
files_length = length(scdataset);
input_data=struct();
for i=1:files_length
%import data
data = readtable([scdataset(i).folder,'/', scdataset(i).name]);
fid=fopen([scdataset(i).folder,'/', scdataset(i).name]);
varNames = fgetl(fid);
varNames=split(varNames,' ');
varNames=strrep(varNames,"",'');
varNames=regexp(varNames,'[^""]*','match','once');
varNames=strrep(varNames,'-','_');
varNames=[{'Num'};string(varNames)];
fclose(fid);
data.Properties.VariableNames=varNames;
data=removevars(data,'Num');
%add 'Gene Numeration' column to the right position, after Gene ID
gene_numeration = cellstr(convertStringsToChars(strcat(num2str(data.GeneID) ,'_',num2str(i))));
gene_numeration = strrep(gene_numeration,' ','');
%build the table
table_data = [data(:,2),gene_numeration, data(:,4:end)];
table_data.Properties.VariableNames(2) = {'Gene_Numeration'};
table_data=table_data(:,cell_index)
%save the table
if printLevel==1
name = [path,'/Numbered/Numbered_', scdataset(i).name];
writetable(table_data,name);
end
input_data(i).input_data=table_data;
end