euba / BacArena

agent based modelling
GNU General Public License v3.0
26 stars 11 forks source link

Undefined error with fluxes of simulation object #128

Closed maringos closed 5 years ago

maringos commented 6 years ago

Dear All,

I am experiencing a very strange issue, which is not consistent - if I rerun the simulation, it is gone. I have a setting where the same bacterial model is used but as three different organisms (e.g. type="Α",type="B", type="C"). After simulation I want to find all the related fluxes of each type by this code (part of a function)

#find model's index
        S <- unique(grep(pattern = "A", x = names(sim@specs),
                         ignore.case = T, invert = F, value = T))
        ggj <- as.vector(sapply((sim@mflux)[S], attributes))
#extract model's fluxes in the simulation
        a3 <- BacArena::plotReaActivity(simlist = sim, reactions = ggj[[1]],
                                        ret_data = T)

Sometimes I get the error

Error in BacArena::plotReaActivity(simlist = sim, reactions = ggj[[1]],  : 
  You have to define reactions

which means that the object ggj does not have any entries. What is more strange, if I search for fluxes of the rest of the organisms, there are fluxes of the type "A", so there is no reason why ggj returns no reactions.

I understand that this issue is very vaguely described and I promise to come back when I have something more concrete.

I look forward to your ideas.

Kind Regards, Georgios

maringos commented 6 years ago

Just to visualize my previous issue

screenshot_2018-11-08_15-33-37

I suspect that this is due to no growth, but even in that case, the elements (i.e. the reactions names) should be available.

I look forward to your ideas.

Kind Regards, Georgios

maringos commented 6 years ago

update: One way to bypass this issue is to replace the ggj object with ggj <- as.vector(sim@specs[[S]]@model@react_id)

and then

a3 <- BacArena::plotReaActivity(simlist = sim, reactions = ggj,
                                        ret_data = T)

GM

jotech commented 5 years ago

is this still happening?

maringos commented 5 years ago

It is ages since I have worked with the script, since I hacked it using this solution. We should not assume that problem is gone.

jotech commented 5 years ago

please reopen if still relevant