Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/io/loadProtData.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
% replPerCond : double
% vector with number of replicates for each condition in the dataset.
% Example: [3, 2] if first condition has triplicates and second
% condition has duplicates.
% condition has duplicates. The sum must equal the number of replicate
% columns of the file (all columns after the UniProt ID), otherwise an
% error is raised.
%
% Name-Value Arguments
% --------------------
Expand Down Expand Up @@ -109,6 +111,15 @@
if ~isstruct(protDataFile)
checkFileExistence(protDataFile);
fID = fopen(protDataFile);
nHeaderCols = numel(strsplit(fgetl(fID),'\t','CollapseDelimiters',false));
if nHeaderCols ~= sum(replPerCond)+1
fclose(fID);
error('loadProtData:replicateMismatch', ...
['The header of %s has %d columns but replPerCond sums to %d, ' ...
'so %d columns are expected (the UniProt ID and one per replicate).'], ...
protDataFile, nHeaderCols, sum(replPerCond), sum(replPerCond)+1)
end
frewind(fID);
protDataRaw = textscan(fID,format,'Delimiter','\t','HeaderLines',1,'TreatAsEmpty',{'NA','na','NaN','#VALUE!'});
uniprotIDs = protDataRaw{1};
abundances = cell2mat(protDataRaw(2:end));
Expand Down
5 changes: 3 additions & 2 deletions src/limit_proteins/calculateFfactor.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
% --------------------
% protData : struct
% structure with proteome data, from loadProtData (by default it instead
% attempts to load data/paxDB.tsv).
% attempts to load data/paxDB.tsv). With several samples, the abundance
% of a protein is averaged over the samples in which it is measured.
% enzymes : cell
% list of enzymes (default model.ec.enzymes).
% modelAdapter : ModelAdapter
Expand Down Expand Up @@ -99,7 +100,7 @@
protData.abundances = protData.level .* protData.MW;
end

avgAbundances = mean(protData.abundances,2);
avgAbundances = mean(protData.abundances,2,'omitnan');
totalProt = sum(avgAbundances,'omitnan');

% Get enzymes in model
Expand Down
2 changes: 1 addition & 1 deletion test/VerificationMatrix.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ gather_kcats/kcatsFromHomologs.m tc0095, tc0096
gather_kcats/extractEnzymeSubstratePairs.m tc0096, tc0015
gather_kcats/convertCustomKcats.m tc0091, tc0092, tc0094
change_model/upgradeEcModel.m tc0093, tc0094, tc0099
io/loadProtData.m tc0101, tc0102
io/loadProtData.m tc0101, tc0102, tc0260
change_model/addNewRxnsToEC.m tc0211, tc0232, tc0237
change_model/mapRxnsToConv.m tc0213
flux_analysis/ecFVA.m tc0214
Expand Down
24 changes: 24 additions & 0 deletions test/unit_tests/protDataTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,30 @@ function testLoadProtDataCutLowestIsUsed_tc0102(testCase)
verifyEqual(testCase, min(p20.abundances), 9)
end

function testLoadProtDataReplicateCountMustMatchColumns_tc0260(testCase)
% replPerCond has to add up to the replicate columns of the file; columns
% beyond the sum are not read silently.
adapter = getTestAdapter();
file = writeProteomics({'X1','X2'}, [1 2 3; 4 5 6]);
verifyError(testCase, @() loadProtData(2, 'protDataFile', file, 'modelAdapter', adapter), ...
'loadProtData:replicateMismatch')
verifyError(testCase, @() loadProtData(4, 'protDataFile', file, 'modelAdapter', adapter), ...
'loadProtData:replicateMismatch')
protData = loadProtData(3, 'protDataFile', file, 'modelAdapter', adapter, ...
'addStdevs', 0, 'cutLowest', 0);
verifyEqual(testCase, protData.uniprotIDs, {'X1';'X2'})
end

function testCalculateFfactorAveragesOverMeasuredSamples_tc0261(testCase)
% A protein measured in one of two samples counts with that measurement
% in both sums of the f factor instead of dropping out of them.
adapter = getTestAdapter();
protData.uniprotIDs = {'A';'B';'C'};
protData.abundances = [10 NaN; 20 20; 30 30];
f = calculateFfactor([], 'protData', protData, 'enzymes', {'A';'B'}, 'modelAdapter', adapter);
verifyEqual(testCase, f, 0.5, 'AbsTol', 1e-12)
end

function testApplyComplexDataStoichiometryByProteinId_tc0103(testCase)
% The complex lists its proteins in another order than model.ec.enzymes;
% each protein receives its own stoichiometry.
Expand Down
Loading