alanderos91 / BioSimulator.jl

A stochastic simulation framework in Julia.
https://alanderos91.github.io/BioSimulator.jl/stable/
Other
47 stars 7 forks source link

Output dataframe with wrong column names (get_dataframe function) #4

Closed oliviaAB closed 5 years ago

oliviaAB commented 6 years ago

I noticed a small mistake in the definition of the function get_dataframe in the file partial_history.jl. The names of the columns of the returned data frame do not correspond to the correct species for the corresponding columns, (this can be seen because the species name and initial abundance don't match). The code for the function could be updated as follow: From line 79 to 81 of the partial_history.jl file, instead of:

    for i = 1:d1
        df[ids[i]] = vec(convert(Array, view(data, i, :, :)))
    end

write:

    for i in ids
        df[i] = vec(convert(Array, view(data, id2ind[i], :, :)))
    end

I hope this will help.

alanderos91 commented 6 years ago

@oliviaAB

Thank you for your help! This should be fixed in the latest release. DataFrame conversion now works as follows:

result = simulate(...)
DataFrame(result)

Species order is not preserved, but the resulting DataFrame appears to match the initial abundance. I'll leave this open until I have an explicit test for this.

alanderos91 commented 5 years ago

Partially addressed by 3c07682864b728b044c1f4f42889d1744767fdd5