Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    saubhagya-gatech
    @saubhagya-gatech
    Trace_plots.png
    GR Plot.png
    Oscar Ortega
    @ortega2247
    Yes, you are right. If the posterior distribution is bimodal the Gelman-Rubin diagnostics would fail. I don't know what to do in those cases, but I found this paper where the authors developed a modified Gelman-Rubin test that works for multimodal distributions: https://arxiv.org/pdf/1812.09384.pdf You could try to apply it to your results
    saubhagya-gatech
    @saubhagya-gatech
    Thanks. I will try that. I am having little bit f hard time understanding how gamma is adapted. Since, its default value is False, it appears that it is not a key functionality of DREAM(ZS). If I keep gamma adaptation disabled, I do not see any argument to pass gamma_0 value. I was exploring this option to improve the acceptance rate by reducing reducing the gamma_0 value. Or, is increasing Gamma level a better way to do this?
    Oscar Ortega
    @ortega2247
    You can set adapt_gamma=True if you want the gamma probabilities to be adapted. Otherwise, the gamma probabilities are defined: gamma_probabilities = [1/float(gamma_levels) for i in range(gamma_levels)], so if you want to include lower gamma probabilities you can increase the integer passed to the gamma_levels argument
    vw-liane
    @vw-liane

    Hi there! I hope you and yours are well.

    New person to Gitter & PySB here. I have some questions after going through the tutorial at https://pysb.readthedocs.io/en/latest/tutorial.html.

    1) When I run the cmd visualization command, I don't get errors, but neither do I get any visual output. Would you know what could be causing this or things I should try to debug? I can post the screenshots (how do I attach something?).

    2) Is there a spot for me to learn more about the "Model calibration" and "Modules" sections? They are empty at the moment.

    3) I saw multiple typos in the tutorial. Can I send you somehow the locations of the typos? Sorry about that; spelling is one of those small things that bugs me.

    Thank you for your time and I look forward to hearing from you.

    Alex Lubbock
    @alubbock
    Hi @vw-liane,
    1) What operating system are you using? Unfortunately, I think Gitter doesn't a way to upload images directly. You'd have to upload it somewhere like imgur and paste the link here.
    2) For model calibration, PyDREAM has PySB integration (here is a publication on that). There's more detail on the PySB modules here. We'll update the tutorial with a few links in the next release. Thanks for bringing it to my attention.
    3) We'd welcome your suggestions for improvements and fixes to the documentation. You could either open an issue on Github describing the issues, or even better, if you're comfortable with Github you could make the edits to the tutorial directly and open a pull request.
    vw-liane
    @vw-liane

    Hi @alubbock ,
    Sorry for my delay; life is wild.
    1) I am on Windows 10 64 bit. For now I will work around the visualization aspect until I explore that deeper in my project. Thank you for the tip on using imgur!
    2) I'm checking out PyDREAM as well! Thank you for that insight.
    3) Yes, I think I could do the edit and pull request! That sounds like the best option.

    When I have more thoughts/ questions, I will let you know! Thank you for your help so far.

    Alex Lubbock
    @alubbock
    @vw-liane No problem; thanks for taking the time to put together a pull request. I've just merged it.
    saubhagya-gatech
    @saubhagya-gatech

    Dear forum members,

    I am a PyDream user. I have a quick question. Is there a way to define different form of priors for different parameters?
    Currently I am using uniform priors for all my parameters. I am using following line of code:

    parameters_to_sample = SampledParam(uniform, loc=lower_limits, scale=scale)
    sampled_parameter_names = [parameters_to_sample]

    Now, I want to give uniform priors to a few parameters and gaussians to the rest. What is the best way to go about it?

    Oscar Ortega
    @ortega2247

    Hi,

    You can use any of the scipy distributions (https://docs.scipy.org/doc/scipy/reference/stats.html) as a prior in pydream.

    To use a uniform and a gaussian distribution you can do something like this:

    from scipy.stats import norm, uniform
    
    par1 = SampledParam(uniform, loc=lower_limits, scale=scale)
    par2=SampledParam(norm,  loc=mean, scale=std)
    
    sampled_parameters = [par1, par2

    Hope this is helpful

    saubhagya-gatech
    @saubhagya-gatech
    oh ok. This makes so much sense. Essentially, we have to give a list of scion distributions. Can we give distributions other than uniform or normal? Like some fitted kernel?
    image.png
    something like this:
    Oscar Ortega
    @ortega2247
    Interesting. I have never done anything like that but in theory it should be doable. Check this example from StackOverFlow to create a new scipy distribution. You just have to make sure that your distribution has a rvs and interval methods
    saubhagya-gatech
    @saubhagya-gatech
    I see. So, I can give any distribution that is definable in Scipy. That's great.
    pietromicheli
    @pietromicheli
    Hi all, i'm new in the forum.
    I have a very quick question: is it somehow possible to pass as input to the simulation a list of values (one for each time point) which is meant to describe how a Parameter (or Expression) entity must vary during the simulation?
    Oscar Ortega
    @ortega2247

    Hi @pietromicheli, if your parameters change over time as a function of the concentration of one or multiples species in your model, you can create an Expression and pass it as rules' rates. For doing something like this, you can check this example:

    https://github.com/pysb/pysb/blob/master/pysb/examples/expression_observables.py

    If you just want to pass a list parameter values to be used at different time points, I am not aware that there is function like that in pysb. However, you could simulate the first time points with the parameters that you want and then used the simulated results as the initial conditions of the next simulation that has different parameter values. For an example like that, take a look at this function:

    https://github.com/LoLab-VU/pydyno/blob/9b93be55f5e6159cc98847e41d1e44290f4dcfcb/pydyno/tools/miscellaneous_analysis.py#L9

    @alubbock might have some better ideas :)

    Leonard Harris
    @lh64
    @pietromicheli Can you explain a bit more what you’re trying to do or provide a short example? There are piecewise linear functions that might work but without an example it’s a bit hard for us to determine what the best solution might be for your problem.
    pietromicheli
    @pietromicheli

    Hi @ortega2247 and @lh64, thank you for the answers! :)

    @lh64 you're definitely right, I apologize. I'm trying to model a post-synaptic neuron activity:
    First, I simulate the gating of post-synaptic ion channels in a Pysb model. Then I use the trajectory of the open channels to calculate, for each time point, the quantity of Calcium ions that flow in the time unit. This post simulation calculation will create an array (of length equal to the time span array used for the first pysb simulation) that basically describes the time course of the post-synaptic calcium influx. What I'm trying to do now is to pass this array to a second Pysb model which contains some Calcium-dependent reactions. The goal here is to use the values of my array (one for each time step) to drive a synthesis-like reaction for a Calcium monomer that can be used by all the Calcium-dependent reactions. I really hope it's clear enough! :)

    Thanks a lot @ortega2247 , your function seems super cool for creating a kind of discrete event during the simulation, but in this case I want that my parameter continuously change at each time step :)

    saubhagya-gatech
    @saubhagya-gatech
    Good Morning Forum Members,
    I am a PyDream user. I wanted to confirm that there is no strict requirement for the number of chains in Dream(ZS), right? For 19 parameters, can I use 5 chains? For MCMC-DE, we had to use a minimum of D/2 chains where D is the dimension of parameter space. I read that Dream(ZS) does not have any such requirement. Just wanted to double-check.
    Thanks
    Rodrigo Santibáñez
    @glucksfall
    Hello everyone. I hope you're well. Is there a way to delete a Rule from the model?
    Leonard Harris
    @lh64
    @glucksfall There's not a simple function for deleting a Rule but you can try manually recreating the model.rules object by excluding the Rule(s) you don't want, using model.reset_equations to clear out the reactions, species, etc. created by BNG, and then regenerating the network. Here's a small example script I put together doing that:
    Rodrigo Santibáñez
    @glucksfall
    Thank you @lh64.
    saubhagya-gatech
    @saubhagya-gatech

    Hello everyone,

    I was wondering if it is possible to provide multivariate distribution as prior instead of independent priors for parameters in PyDream?

    Oscar Ortega
    @ortega2247
    Hi @saubhagya-gatech , sorry for the late reply. Dream(ZS) has a minimum number of chains requirement of 3. Unfortunately, pydream doesn't support the usage of multivariate distributions as a prior
    saubhagya-gatech
    @saubhagya-gatech
    @ortega2247 Thank you!
    Leonard Harris
    @lh64
    @pietromicheli You should be able to accomplish what you want using the initials or param_values arguments to the run method of the simulator. I'm attaching an example here. I defined two simple rules: X() >> None and A() + X() >> X(). In the code, I first run a simulation of the full system. Then, I run two sequential simulations, the first with only the X() >> None rule and the second with only the A() + X() >> X() rule, where the concentration of X() from the first simulation is fed into the simulator for the second simulation using the initials argument to ScipyOdeSimulator.run. To be clear, the second "simulation" is actually a series of simulations from output time point to output time point, with the final concentration of A() from the previous step and the corresponding value of X() passed into the simulator at each step. I have it loop over three different numbers of output points (10, 100, and 1000) to show how the output of the sequential simulation approaches the true result from the full simulation as the number of output points increases. I'm attaching those plots here as well. Hopefully this helps. If you have any further questions just let us know.
    Figure_1.png
    figure_2.png
    figure_3.png
    pietromicheli
    @pietromicheli

    @lh64 Thank you for the answer!

    Actually my first approach to this problem was to iteratively run one simulation for each time point just as you suggested, but I wasn't very happy with the computational cost of a such sequential simulation (expecially for a high number of time points). However looking at your code I noticed that (stupidly) I created at each iteration a new simulator object (via ScipyOdeSimulator() function). So it turned out that this unnecessary step tripled the cost of each iteration, compared to the cost that runinning the simulations (via .run() method) using always the same simulator object at each iteration would require. The overall cost is still quite high obviously, but for reasonably small number of time points it is tollerable.

    Your answer and your code has been really helpfull, thanks a lot! :)

    saubhagya-gatech
    @saubhagya-gatech
    Hello @ortega2247
    Was there any change made in the PyDream in the last one month? I installed the package again and the "start" argument is not working. It does not matter what chain initialization I give, the chains are starting at random positions. Any help here would be appreciated. Before I reinstalled PyDream yesterday, I did not have this issue.
    saubhagya-gatech
    @saubhagya-gatech
    Here is the output file. I have printed the list of starting positions of 5 chains, and I also print the parameters received my likelihood function as "proposed parameter values". The first step has totally different proposed values then what is specified in the "start". I think this might be a bug.
    Oscar Ortega
    @ortega2247
    Hi @saubhagya-gatech , I am sorry PyDREAM is having issues. PyDREAM hasn't been updated since March 25 so I am not sure why this is happening. If you used pip to install pydream you can check the version installed by typing: pip show pydream in the terminal. The version should be 2.0.0
    If you send me a reproducible example, that would help me to find where the problem is
    saubhagya-gatech
    @saubhagya-gatech
    Thank you Oscar. I was looking at Github and I see pull request accepted on May 14th which had some changes relevant to the start argument. Is "pip install" currently installing version with these changes?
    https://github.com/LoLab-VU/PyDREAM/pull/20/files/384866c232f9a16b8da4a7ececea62d665eaf644
    I will prepare a reproducible example. I actually manually installed March 25 version using the source code and that is not showing the mentioned issue
    saubhagya-gatech
    @saubhagya-gatech
    I did some more numerical tests and found that if I used this version:( https://github.com/LoLab-VU/PyDREAM/releases/tag/v2.0.0) the start argument is working, but if I use the version installed from "pip install pydream", the start argument is not working. Give me few minute to send an example
    Oscar Ortega
    @ortega2247
    mmm so strange. pip install should be installing this release: https://github.com/LoLab-VU/PyDREAM/releases/tag/v2.0.0 unless you are using python 2
    saubhagya-gatech
    @saubhagya-gatech
    ah ok. I am currently double-checking my python versions and package locations. I will get back to you either today or tomorrow if I figure out what is happening.
    On a different note, the version with acceptance-ratio correction is not released yet, right?
    Oscar Ortega
    @ortega2247
    that's correct
    i should be releasing it soon
    Oscar Ortega
    @ortega2247
    it fixes the reporting of acceptance rates when one restarts a pydream run. Before this fix, we observed that the acceptance rates were dropping when restarting because the number of accepted points where reset to zero instead of keeping the history of the number of accepted points in the previous run
    saubhagya-gatech
    @saubhagya-gatech
    That makes sense. Thank you. Here is a reproducible example. After running the mcmc_run.py, you can run reading_results.py to print the first step that chains actually took. This is coming out to be different from the first step defined in "start" which is also printed in the python outputs. I could not think of any reason for this. Any help would be appreciated.