Possible bug in findRxnsFromMets

14 views
Skip to first unread message

Alan Pacheco

unread,
Jun 12, 2024, 4:11:37 AMJun 12
to COBRA Toolbox
Hi all,

I've been using findRxnsFromMets for a while but ran into an issue upon installing the latest version of COBRA on a new machine. Essentially, the function does not return the correct list of reactions when metList has length 1. Instead, it returns the first reaction in model.rxns.

I think this has to do with how the function gets the 'totals' in line 119 of the new version. When 'index' has length > 1, the sum is done over the rows and it returns the correct indices for the associated reactions. However when 'index' has length == 1, the sum now acts over the columns resulting in the wrong reaction (i.e., always model.rxns(1)) being returned. I see that the code was recently modified from:

totals = sum(model.S(index,:) ~= 0,1);

to 

totals = sum(model.S(index,:) ~= 0);

which seems to have to do with correctly filtering for produced/consumed metabolites, but results in this new behavior. This unfortunately breaks aspects of our pipeline that we've built using findRxnsFromMets, so I wanted to flag it while finding a workaround. I've added a few cases below (with iAF1260, no varargin) and the relevant components of the function to illustrate the issue, and am happy to clarify further.

Thank you very much and best regards,
Alan

Case 1: 'old' version, metList length 1, correct output
clearvars
load iAF1260.mat
model = iAF1260;
metList = {'ala__L_e'};
index = ismember(model.mets,metList); % Line 71
totals = sum(model.S(index,:) ~= 0,1); % Line 119
rels = totals > 0; % Line 120
rxnList = model.rxns(totals > 0 & rels)% Line 135

rxnList =

  2×1 cell array

    {'ALAtex'     }
    {'EX_ala__L_e'}


Case 2, 'new' version, metList length > 1, correct output
clearvars
load iAF1260.mat
model = iAF1260;
metList = {'ala__L_e','cl_e'};
index = ismember(model.mets,metList);
totals = sum(model.S(index,:) ~= 0);
rels = totals > 0;
rxnList = model.rxns(totals > 0 & rels)

rxnList =

  4×1 cell array

    {'ALAtex'     }
    {'CLtex'      }
    {'EX_ala__L_e'}
    {'EX_cl_e'    }


Case 3, 'new' version, metList length  1, incorrect output
clearvars
load iAF1260.mat
model = iAF1260;
metList = {'ala__L_e'};
index = ismember(model.mets,metList);
totals = sum(model.S(index,:) ~= 0);
rels = totals > 0;
rxnList = model.rxns(totals > 0 & rels)

rxnList =

  1×1 cell array

    {'ACGAM1PPpp'}


Case 4, 'new' version, metList length > 1 but index length 1, incorrect output
clearvars
load iAF1260.mat
model = iAF1260;
metList = {'ala__L_e','pizza_e'};
index = ismember(model.mets,metList);
totals = sum(model.S(index,:) ~= 0);
rels = totals > 0;
rxnList = model.rxns(totals > 0 & rels)

rxnList =

  1×1 cell array

    {'ACGAM1PPpp'}

Farid Zare

unread,
Jun 13, 2024, 7:51:51 AMJun 13
to cobra-...@googlegroups.com
Hi Alan,

This problem with "findRxnsFromMets" is solved in the develop branch, please either use the develop branch or clone your copy of this function from the develop branch until the next time that the develop branch is merged into the master branch.
You can find the latest update on this function here:

Regards,
Farid
--
Farid Zare MSc
-----------------------------------------------------
Ph.D. Student at University of Galway, Ireland
LinkedIn: farid-zare
GitHub: farid-zare
GitLab: farid-zare


--

---
You received this message because you are subscribed to the Google Groups "COBRA Toolbox" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cobra-toolbo...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cobra-toolbox/9ee73eaa-13e0-4323-a9f4-7d14d5393890n%40googlegroups.com.

Pacheco Alan

unread,
Jun 14, 2024, 4:21:27 AMJun 14
to cobra-...@googlegroups.com

Hi Farid,


Ok, thank you very much for the reply. We'll use that version of the function in the meantime.


Best regards,

Alan


From: cobra-...@googlegroups.com <cobra-...@googlegroups.com> on behalf of Farid Zare <farid.z...@gmail.com>
Sent: Thursday, June 13, 2024 1:51:12 PM
To: cobra-...@googlegroups.com
Subject: Re: Possible bug in findRxnsFromMets
 
You received this message because you are subscribed to a topic in the Google Groups "COBRA Toolbox" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/cobra-toolbox/nTyt_65VShg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to cobra-toolbo...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cobra-toolbox/CACVX4vT79KvqrjZO-BTtPFnHAAyZn%2BW4UJrWP2%2BZsBeKuZA5AQ%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages