|
273 | 273 | tic;
|
274 | 274 | % Load all variables defined in the configPersephone.m
|
275 | 275 | run(configPath);
|
276 |
| - |
| 276 | +resultPath |
277 | 277 | % Do not run MARS if seqC was run.
|
278 | 278 | if paths.seqC.flagSeqC == true
|
279 | 279 | paths.Mars.paths.Mars.flagMars = false;
|
|
284 | 284 |
|
285 | 285 | % Validate the set workspace variables and give descriptive errors on which
|
286 | 286 | % variables were not set correctly.
|
| 287 | +resultPath |
287 | 288 | validatePersephoneInputs(paths,resultPath);
|
288 | 289 |
|
289 | 290 | % Create log file on the pipeline setup
|
290 |
| -diary([resultPath filesep 'logFile_initialisation.txt']) |
| 291 | +resultPath |
| 292 | +diary(fullfile(resultPath, 'logFile_initialisation.txt')) |
291 | 293 |
|
292 | 294 | % Initialise PERSEPHONE
|
293 |
| -[~, ~, updatedMetadataPath] = initPersephone(resultPath, paths); |
| 295 | +[~, statToolboxInstalled, updatedMetadataPath] = initPersephone(resultPath, paths); |
294 | 296 | paths.General.metadataPath = updatedMetadataPath;
|
295 | 297 |
|
296 | 298 | % Validate the path to the given diet.
|
|
412 | 414 | disp(' > Calculation of relative abundances with MARS is skipped')
|
413 | 415 | end
|
414 | 416 | diary('off'); % Save MARS logfile
|
415 |
| -%% Adjust metadata to remove any potential missing samples compared to the microbiome sample. |
416 |
| -% Remove samples in the metadata that are not in the microbiome data |
417 |
| -if ~isempty(paths.Mars.relAbunFilePath) |
418 |
| - |
419 |
| - % Load microbiome data |
420 |
| - relAbunFile = readtable(paths.Mars.relAbunFilePath,'VariableNamingRule','preserve'); |
421 |
| - |
422 |
| - % Check if the microbiome table is empty |
423 |
| - validateattributes(relAbunFile, {'table'}, {'nonempty'}, mfilename, 'readsTable') |
424 |
| - |
425 |
| - % Check if a column named Taxon exists |
426 |
| - if ~ismember('Taxon', relAbunFile.Properties.VariableNames) |
427 |
| - error('COBRA:BadInput', 'Microbiome read table must contain an Taxon column') |
428 |
| - end |
429 |
| - |
430 |
| - % Read in the metadata |
431 |
| - metadata = readMetadataForPersephone(paths.General.metadataPath); |
432 |
| - |
433 |
| - % Find the intersection of samples between the readsTable and the |
434 |
| - % metadata table |
435 |
| - [~,ia,ib] = intersect(metadata.ID, ... |
436 |
| - relAbunFile.Properties.VariableNames(2:end)','stable'); |
437 |
| - |
438 |
| - % Perform checks |
439 |
| - if isempty(ia) |
440 |
| - error('COBRA:BadInput', 'No overlapping samples could be found between the reads table and the metadata table.') |
441 |
| - else |
442 |
| - numRemovedSamples = size(metadata,1)-numel(ia); |
443 |
| - if numRemovedSamples>0 |
444 |
| - disp(strcat("> Removed ", string(numRemovedSamples), " samples in the metadata that were not present in the reads table.")) |
445 |
| - end |
446 |
| - relAbunFile = relAbunFile(:,[1; 1+ib]); |
447 |
| - metadata = metadata(ia,:); |
448 |
| - end |
449 |
| - |
450 |
| - % Remove all samples in the metadata that are not in the readsTable |
451 |
| - disp(strcat("> ", string(size(metadata,1)), " samples were included in this study.")) |
452 |
| - writetable(relAbunFile, paths.Mars.relAbunFilePath); |
453 |
| - writetable(metadata,paths.General.metadataPath); |
454 |
| -end |
| 417 | +% %% Adjust metadata to remove any potential missing samples compared to the microbiome sample. |
| 418 | +% % Remove samples in the metadata that are not in the microbiome data |
| 419 | +% if ~isempty(paths.Mars.relAbunFilePath) |
| 420 | +% |
| 421 | +% % Load microbiome data |
| 422 | +% relAbunFile = readtable(paths.Mars.relAbunFilePath,'VariableNamingRule','preserve'); |
| 423 | +% |
| 424 | +% % Check if the microbiome table is empty |
| 425 | +% validateattributes(relAbunFile, {'table'}, {'nonempty'}, mfilename, 'readsTable') |
| 426 | +% |
| 427 | +% % Check if a column named Taxon exists |
| 428 | +% if ~ismember('Taxon', relAbunFile.Properties.VariableNames) |
| 429 | +% error('COBRA:BadInput', 'Microbiome read table must contain an Taxon column') |
| 430 | +% end |
| 431 | +% |
| 432 | +% % Read in the metadata |
| 433 | +% metadata = readMetadataForPersephone(paths.General.metadataPath); |
| 434 | +% |
| 435 | +% % Find the intersection of samples between the readsTable and the |
| 436 | +% % metadata table |
| 437 | +% [~,ia] = intersect(metadata.ID, ... |
| 438 | +% relAbunFile.Properties.VariableNames(2:end)','stable'); |
| 439 | +% % Perform checks |
| 440 | +% if isempty(ia) |
| 441 | +% error('COBRA:BadInput', 'No overlapping samples could be found between the reads table and the metadata table.') |
| 442 | +% else |
| 443 | +% numRemovedSamples = size(metadata,1)-numel(ia); |
| 444 | +% if numRemovedSamples>0 |
| 445 | +% disp(strcat("> Removed ", string(numRemovedSamples), " samples in the metadata that were not present in the reads table.")) |
| 446 | +% end |
| 447 | +% metadata = metadata(ia,:); |
| 448 | +% end |
| 449 | +% |
| 450 | +% % Remove all samples in the metadata that are not in the readsTable |
| 451 | +% disp(strcat("> ", string(size(metadata,1)), " samples were included in this study.")) |
| 452 | +% writetable(metadata,paths.General.metadataPath); |
| 453 | +% end |
455 | 454 |
|
456 | 455 | %% Part 2:
|
457 | 456 | %%%%%%%%%%%%%%%%%%%%%%% Create microbiome models %%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
611 | 610 | %% Part 6:
|
612 | 611 | %%%%%%%%%%%%%%%%%%%%%% Analysis of flux results %%%%%%%%%%%%%%%%%%%%%%%%%%%
|
613 | 612 | tic;
|
614 |
| -if paths.stats.flagStatistics |
| 613 | +if paths.stats.flagStatistics && statToolboxInstalled |
615 | 614 | diary([resultPath filesep 'logFile_statistics.txt']) % Open diary for log file
|
616 | 615 |
|
617 | 616 | for i = 1:size(paths.stats.response,2)
|
|
644 | 643 | end
|
645 | 644 | totalT= 0;
|
646 | 645 | fields = fieldnames(progress);
|
647 |
| -for i = 1:numel(fields) |
| 646 | +for i = 1:numel(fields)-1 |
648 | 647 | data = progress.(fields{i});
|
649 | 648 | totalT = totalT + data(2);
|
650 | 649 | end
|
|
0 commit comments