I can't find a solution for my code. I want to run the plugin iMAT (CobraTools) in MATLAB

19 views
Skip to first unread message

Deb Colman

unread,
Oct 7, 2024, 9:37:30 AM10/7/24
to COBRA Toolbox
Hi Everyone! I'm a MatLab begginner and I'd like to run the iMAT plugin to reach a comparative proteomic analysis. This program is inside CobraTools package.
My input is an Excel file with data about 2 growth conditions: Wildtype and Fe-growth.
I share my code and one of various error messages than I obtain when I try to execute the iMAT function.


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
Reply all
Reply to author
Forward
0 new messages