Skip to content

Commit

Permalink
Fixed some bugs in DEMETER/mgPipe
Browse files Browse the repository at this point in the history
  • Loading branch information
almut-heinken committed Oct 10, 2024
1 parent cd75070 commit b3492e4
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ function analyzeMgPipeResults(infoFilePath,resPath,varargin)
% Print the results as a text file
filename = strrep(fileList{i},'.csv','');
filename = strrep(filename,'.txt','');
writetable(cell2table(Statistics),[statPath filesep filename '_' sampleGroupHeaders{j} '_Statistics'],'FileType','text','WriteVariableNames',false,'Delimiter','tab');
writetable(cell2table(Statistics),[statPath filesep filename '_' sampleGroupHeaders{j} '_Statistics.csv'],'WriteVariableNames',false);
if size(significantFeatures,2)>1
writetable(cell2table(significantFeatures),[statPath filesep filename '_' sampleGroupHeaders{j} '_SignificantFeatures'],'FileType','text','WriteVariableNames',false,'Delimiter','tab');
writetable(cell2table(significantFeatures),[statPath filesep filename '_' sampleGroupHeaders{j} '_SignificantFeatures.csv'],'WriteVariableNames',false);
end

% create plots
Expand All @@ -133,9 +133,9 @@ function analyzeMgPipeResults(infoFilePath,resPath,varargin)
% Print the results as a text file
filename = strrep(fileList{i},'.csv','');
filename = strrep(filename,'.txt','');
writetable(cell2table(Statistics),[statPath filesep filename '_Statistics'],'FileType','text','WriteVariableNames',false,'Delimiter','tab');
writetable(cell2table(Statistics),[statPath filesep filename '_Statistics.csv'],'WriteVariableNames',false);
if size(significantFeatures,2)>1
writetable(cell2table(significantFeatures),[statPath filesep filename '_SignificantFeatures'],'FileType','text','WriteVariableNames',false,'Delimiter','tab');
writetable(cell2table(significantFeatures),[statPath filesep filename '_SignificantFeatures.csv'],'WriteVariableNames',false);
end

% create violin plots
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,16 @@ function makeViolinPlots(sampleData, sampleInformation, varargin)
cnt=1;
delArray=[];
for i=2:size(sampleData,1)
if sum(str2double(sampleData(i,2:end)))<0.0001
delArray(cnt,1)=i;
cnt=cnt+1;
if contains(version,'R202') % for MATLAB 2020a or newer
if sum(cell2mat(sampleData(i,2:end)))<0.0001
delArray(cnt,1)=i;
cnt=cnt+1;
end
else
if sum(str2double(sampleData(i,2:end)))<0.0001
delArray(cnt,1)=i;
cnt=cnt+1;
end
end
end
sampleData(delArray,:)=[];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function createPanModels(agoraPath, panPath, taxonLevel, agoraVersion, numWorkers)
function createPanModels(agoraPath, panPath, taxonLevel, agoraVersion, numWorkers, builtTaxa)
% This function creates pan-models for all unique taxa (e.g., species)
% included in the AGORA resource. If reconstructions of multiple strains
% in a given taxon are present, the reactions in these reconstructions will
Expand All @@ -23,16 +23,22 @@ function createPanModels(agoraPath, panPath, taxonLevel, agoraVersion, numWorker
% created pan-models will be stored in. Must end with a file separator.
% taxonLevel String with desired taxonomical level of the pan-models.
% Allowed inputs are 'Species','Genus','Family','Order', 'Class','Phylum'.
% agoraVersion Version of AGORA that will be used (allowed inputs: 'AGORA', 'AGORA2')
% agoraVersion Version of AGORA that will be used (allowed inputs: 'AGORA', 'AGORA2',
% alternatively: path to custom table with reconstruction information)
%
% OPTIONAL INPUTS
% numWorkers Number of workers for parallel pool (default: no pool)
% builtTaxa Names of taxa in table that will be built (default:
% all). Need to be entered as a cell array of strings with names written
% exactly as in the corresponding column in the table.
%
% .. Authors
% - Stefania Magnusdottir, 2016
% - Almut Heinken, 06/2018: adapted to function.
% - Almut Heinken, 03/2021: enabled parallelization
% - Almut Heinken, 05/2024: enforced specifying AGORA version
% - Almut Heinken, 10/2024: allowed specifying input table and taxa
% to create

tol = 1e-5;

Expand All @@ -58,13 +64,13 @@ function createPanModels(agoraPath, panPath, taxonLevel, agoraVersion, numWorker
solver = CBT_LP_SOLVER;
environment = getEnvironment();

% load the file with information on AGORA/AGORA2
% load the file with information on AGORA/AGORA2 or custom table
if strcmp(agoraVersion,'AGORA')
infoFile = readInputTableForPipeline('AGORA_infoFile.xlsx');
elseif strcmp(agoraVersion,'AGORA2')
infoFile = readInputTableForPipeline('AGORA2_infoFile.xlsx');
else
error('Incorrect input for agoraVersion! Allowed inputs: AGORA, AGORA2')
infoFile = readInputTableForPipeline(agoraVersion);
end

% get the reaction and metabolite database
Expand All @@ -78,6 +84,12 @@ function createPanModels(agoraPath, panPath, taxonLevel, agoraVersion, numWorker
allTaxa(strncmp(allTaxa, 'unclassified', 12)) = [];
allTaxa(strcmp(allTaxa, '')) = [];

% reduce to specified list of taxa to build if entered
if nargin >5
[~,I] = setdiff(allTaxa,builtTaxa);
allTaxa(I,:) = [];
end

% Remove models that have already been assembled from the list of models to create
dInfo = dir(panPath);
dInfo = dInfo(~[dInfo.isdir]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
% create the pan-models on species level
panPath=[pwd filesep 'panSpeciesModels'];

createPanModels(modPath,panPath,'Species','AGORA',numWorkers);
builtTaxa = {'Acinetobacter junii','Bacteroides ovatus','Enterobacter cloacae','Megasphaera elsdenii','Ruminococcus flavefaciens'};
createPanModels(modPath,panPath,'Species','AGORA_infoFile.xlsx',numWorkers,builtTaxa)

% test that pan-models can grow
[notGrowing,Biomass_fluxes] = plotBiomassTestResults(panPath, 'pan-models','numWorkers',numWorkers);
Expand All @@ -40,7 +41,8 @@
% create the pan-models on genus level
panPath=[pwd filesep 'panGenusModels'];

createPanModels(modPath,panPath,'Genus','AGORA',numWorkers);
builtTaxa = {'Acinetobacter','Bacteroides','Megasphaera','Ruminococcus'};
createPanModels(modPath,panPath,'Genus','AGORA_infoFile.xlsx',numWorkers,builtTaxa);

% test that pan-models can grow
[notGrowing,Biomass_fluxes] = plotBiomassTestResults(panPath, 'pan-models','numWorkers',numWorkers);
Expand Down

0 comments on commit b3492e4

Please sign in to comment.