Error message: iMAT-CobraTools
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
Walter Roberson
2024-10-7
initCobraToolbox appears to be from https://www.mathworks.com/matlabcentral/fileexchange/69132-the-constraint-based-reconstruction-and-analysis-toolbox
Walter Roberson
2024-10-7
We would need 'C:\Users\usuario\cobratoolbox\160824_BP-Fe.xlsx' to test with.
采纳的回答
更多回答(1 个)
Walter Roberson
2024-10-7
移动:Walter Roberson
2024-10-7
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 个评论
Walter Roberson
2024-10-8
No, the base problem is that the file contains 'na' entries that are being converted to nan or inf by xlsread().
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!