Error message: iMAT-CobraTools
1 view (last 30 days)
Show older comments
Hi Everyone! I'm a MatLab begginner and I'd like to run the iMAT plugin to reach a comparative proteomic analysis.
My input is an Excel file with data about 2 growth conditions: Wildtype and Fe-growth.
initCobraToolbox(false)
changeCobraSolver('gurobi');
% Load the expression data from an Excel file
expressionDataFile = 'C:\Users\usuario\cobratoolbox\160824_BP-Fe.xlsx'; % Replace with the correct path
[num, txt, raw] = xlsread(expressionDataFile);
% Load the model .mat file
modelFile = 'C:\Users\usuario\cobratoolbox\iBP1870.mat';
load(modelFile);
% Select the columns I want to analyze from the Excel file
geneNames = txt(2:end, 3);
expressionLevels = num(:, 17);
% Check if there are any cells with NaN values
nanIndices = isnan(expressionLevels);
if any(nanIndices)
warning('There are %d NaN values in the expression levels.', sum(nanIndices));
end
% Remove NaN values from the expression data
expressionLevels = expressionLevels(~any(isnan(expressionLevels), 2), :);
% Assuming `nanIndices` is the index of the elements that were NaN in expressionLevels
% and that you have already used it to remove the NaN values:
% Create indices that are NOT NaN
nanIndices = ~isnan(expressionLevels);
% Filter geneNames using nanIndices, i.e., removing gene names that returned NaN values
filteredGeneNames = geneNames(nanIndices);
% Filter genes and expression levels that are in model.genes
isMember = ismember(filteredGeneNames, model.genes);
if any(~isMember)
warning('Some genes in expressionDataadjusted are not in model.genes');
end
filteredGenes = filteredGeneNames(isMember);
% Run this:
expressionRxns = mapExpressionToReactions(model, filteredGenes, filteredExpressionLevels);
% Set the expression level thresholds
threshold_ub = 50.0; % Upper threshold for expression levels
threshold_lb = 5.0; % Lower threshold for expression levels
% This is where I run iMAT:
tissueModel = iMAT(model, expressionRxns, threshold_lb, threshold_ub);
tissueModel = iMAT(model, expressionRxns, threshold_lb, threshold_ub);
Warning: There are 216 NaN values in the expression levels.
Warning: Some genes in expressionDataadjusted are not in model.genes
RHindex:
53
55
81
156
184
197
........
RLindex:
1
3
4
5
6
7
9
10
11
18
19
20
21
22
1652
1653
1655
1656
1658
1660
1662
1664
1665
1666
1667
1668
1669
1672
Verificando lb y ub para NaN o Inf...
Error using iMAT (line 61)
Vector ub contiene NaN o Inf valores
However, I can't run this code because I keep getting error messages relationated to RHindex.
There is not Nan o Inf values. It was checked
Someone knows how it can solve?
Thanks a lot
DEb
2 Comments
Walter Roberson
on 7 Oct 2024
initCobraToolbox appears to be from https://www.mathworks.com/matlabcentral/fileexchange/69132-the-constraint-based-reconstruction-and-analysis-toolbox
Walter Roberson
on 7 Oct 2024
We would need 'C:\Users\usuario\cobratoolbox\160824_BP-Fe.xlsx' to test with.
Accepted Answer
More Answers (1)
Walter Roberson
on 7 Oct 2024
Moved: Walter Roberson
on 7 Oct 2024
expressionDataFile = '160824_BP-Fe.xlsx';
T = readtable(expressionDataFile, 'VariableNamingRule', 'preserve');
summary(T)
The "num" output of xlsread() would skip leading character vector arrays, so would skip the first four columns.
expressionLevels = num(:, 17);
That would refer to column 17 of the num output, which would be column 21 of T.
summary(T(:,21))
That column is missing 311 inputs. Let's find them
idxmissing = ismissing(T{:,21});
obj = detectImportOptions(expressionDataFile, 'VariableNamingRule', 'preserve');
obj = setvartype(obj, 21, 'char');
T2 = readtable(expressionDataFile, obj);
summary(T2(:,21))
T2(idxmissing, 21)
So the entries might not be inf or nan, but they are 'na'
2 Comments
Walter Roberson
on 8 Oct 2024
No, the base problem is that the file contains 'na' entries that are being converted to nan or inf by xlsread().
See Also
Categories
Find more on Spreadsheets in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!