Showing posts with label General Interest. Show all posts
Showing posts with label General Interest. Show all posts

Thursday, August 6, 2026

 Penultimate Version of Iridium Desktop Released. 

I believe I have finally reached the penultimate version of the Iridium Desktop simulator for Windows and Mac OS. The next version will be 1.0

The Iridium Desktop App is designed to be a productive and easy-to-use interactive SBML-compatible simulation environment for biochemical models. All code is open source  under the MIT license.

Mac OS and Windows binaries can be obtained from 

https://github.com/sys-bio/IridiumSimulator/releases

Click on assets to either download the Mac OS dmg file or a zip file for Windows. To use teh zip file, unzip the contents anywhere on your hard drive and run the Iridium executable. 

There is also a non-install Web Version at:

https://sys-bio.github.io/WebIridium/

Here are some screenshots of the Desktop version.

The main window is split into three sections, left to right: Control Panel, Input Panel, Output Panel. The control panel is switchable between different analysis types; these currently include Time Course simulation, Parameter Scanning, and Steady State. A variety of built-in models come with the distribution (Accessible in the bottom-left drop-down combo)

Time Course Simulation

The screenshot below shows the app operating in Time Course simulation mode. The central input panel has the antimony/SBML editor at the top and the optional slider panel at the bottom. Simulation results are shown on the plot panel to the right. 

Simulations are live in the sense that movement in any slider results in an instant change to the plotting output. All output is rendered in high definition. Output can also be captured as raw data by selecting the Text View tab on the output panel


Parameter Scan Panel

The following screenshot shows the parameter scan panel operation. Parameter scans can be with respect to any parameter of the model. The output measure can be any observable, but can also be limited to time course overlays, peak values, endpoints, and time to peak.  The slider panel is also active during a parameter scan.



Steady State Panel

The steady state panel is used to compute the steady state panel of the model. It can display the steady-state concentrations, Jacobian, and sensitivities of metabolic control analysis. The slider panel is also active in this mode. The steady state panel can display grid data or 3D plot.


Import/Export

SBML models (such as BioModels) can be imported or exported. When imported, they are automatically converted to Antimony form for easy editing.

Reproducibility

Both Time Course and Parameter Scan panels can export the last analysis as a Python script. This allows any parameter scan or time course simulation to be reproducible separately from the Iridium app.

Two sister applications are also under development:

1. Bifurcation Analysis Tool (Windows edition complete)

https://github.com/hsauro/BifurcationTool


2. A Model Fitting App for Windows and Mac OS

This is currently under development but should be released before October 2026

1. Fit SBML models to data using Antimony to edit models

2. Supports multiple data sets as well as time-course and dose-response data.

3. Implements 4 optimizers: Levenberg-Marquardt, Nelder-Mead, Swarm Particle, Differential Evolution.

3. Implements standard linear error uncertainty, profile likelihood, and bootstrap methods for uncertainty estimation.

4. Plots of the fitted model, residuals, profile likelihoods, and bootstrap estimations.

5. Differential Evolution and Particle Swarm can use multiple cores on a computer for higher performance.

6. Import/Export of PEtab.


All work on this page was supported by the NIH Center for Reproducible Biomedical Modeling


Tuesday, April 8, 2025

What were they thinking?

This paper popped into one of my feeds today:

Breakdown and repair of metabolism in the aging brain

I think the paper should have been titled "How not to publish a large model" The paper publishes a model is large but the way they deploy to the commuity is insane.

To save you hunting for the model, this link is to the GitHub repo

In summary the paper describes a kinetic model of brain metabolism with:

183 processes, which include:

95 enzymatic reactions

19 transport processes (across cell and mitochondrial membranes)

69 other processes (related to ionic currents, blood flow, and other non-enzymatic processes)

Additionally: The model uses 151 differential equations to simulate the dynamics of molecular concentrations.

So its large, but what's really a problem is the model is essentially inaccessible. The entire model is built using one huge Julia program. All the biology has been subsumed into a large set of difficult to read differential equations. There is no sharable SBML model so this won't go to Biomodels and reusing it will be very difficult. Why is this a problem? It means other researchers cannot build on what was undoubtedly, a huge amount of work. I took a screen shot of a small fragment of the Julia program so you can see what you're up against:

Sunday, December 11, 2022

Experimenting with foreach loops in TikZ to draw biochemical pathways

Here is an example of a foreach loop in TikZ that can be used to draw an arbitrary long linear chain of reactions.

By setting the value of N in the following TikZ code, you can get any length linear chain. Obviously, you're limited by the width of the page. It uses the xifthen package to provide a conditional that is used to print out the last species, which is X1. There could be a better way of doing this, but this works. For example, use newcommand instead of def
 
\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{arrows}
\usetikzlibrary{calc}
\usepackage{xifthen}

\begin{document}


\begin{tikzpicture}[>=latex', node distance=2cm]     
\node (X0) {$X_o$};
\pgfmathsetmacro{\N}{4}
\foreach \x in {0,...,\N}
{
  \pgfmathtruncatemacro{\nextval}{\x+1}
  \ifthenelse{\x = \N}
        {\def\speciesName{$X_1$}}
        {\def\speciesName{\large $x_\nextval$}}
  
  \node [right of = X\x] (X\nextval) {\speciesName};   
  \draw [->,ultra thick,blue] (X\x) -- node[above, black] {$v_{\nextval}$} (X\nextval);
}
\end{tikzpicture}

\end{document}

Here are some examples for N = 0, N = 2 and N = 4



Tuesday, August 16, 2022

Plot of 1/x using pgfplots

I noticed I couldn't find pgfplots version of the $1/x$ plot that describes $e$. I needed one, so here is the LaTeX I used.

\documentclass[margin=3mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\usepgfplotslibrary{fillbetween}

\begin{document


\begin{tikzpicture}
\begin{axis}[
ytick = {1,2},
xtick = {0,1,2,3},
xlabel=$x$, ylabel=$y$,
ymax=2.5, xmin=0, ymin=0,
xlabel style = {anchor=north east},
ylabel style = {anchor=north east}
]
\addplot [color = blue, name path=A,domain=0:4, line width = 1.4pt, samples=200] {1/x};
\path [name path=B]
    (\pgfkeysvalueof{/pgfplots/xmin},0) --
    (\pgfkeysvalueof{/pgfplots/xmax},0);
\addplot [blue!20]
    fill between [of=A and B,
                  soft clip={(1,0) rectangle (2.71,25)},];
\node at (axis cs:1.5,1.2) {$y=1/x$};
\node at (axis cs:1.6,0.31) {Area = $1$};
\node at (axis cs:2.71, 0.82) {$e$};
\addplot[-latex] coordinates
           {(2.71,0.75) (2.71,0.45)};
\end{axis}
\end{tikzpicture}

\end{document} 



Tuesday, April 5, 2022

Analogmachine reborn

I decided to rebuild my blog on blogger. Originally I used my own WordPress site but discovered that maintaining it was quite time-consuming. The main problem was stopping the site from being hacked and corrupted.  This happened again recently and it prompted me to move to a more resilient and less demanding platform.

Monday, April 4, 2022

Theory of the Origin, Evolution, and Nature of Life by Andrulis

 Ars Technica has an interesting article that I can't avoid bringing up here. The title of the article is:

"How the craziest f#@!ing "theory of everything" got published and promoted"

The Ars Technica article describes a paper (Theory of the Origin, Evolution, and Nature of Life) published by an assistant professor from Case Western. The author of the paper describes a theory of everything which because of a press release from Case Western manages to get amplified out of all proportion even though the content is highly suspect. Just reading the first sentence is enough to raise a big red flag. That sentence is:

"How life abides by the second law of thermodynamics yet evolutionarily complexifies and maintains its intrinsic order is a fundamental mystery in physics, chemistry, and biology [1]."

There is no mystery here as the author suggests. If he had bothered to read up on Prigogine's and Nichols well-known work on non-equilibrium thermodynamics published decades ago he would have an explanation for this "mystery".

Testing Code Formating using hightlight.js


# Python Program to find the area of triangle

if x == True:
   pass
   
a = 5
b = 6
c = 7

# Uncomment below to take inputs from the user
# a = float(input('Enter first side: '))
# b = float(input('Enter second side: '))
# c = float(input('Enter third side: '))

# calculate the semi-perimeter
s = (a + b + c) / 2

# calculate the area
area = (s*(s-a)*(s-b)*(s-c)) ** 0.5
print('The area of the triangle is %0.2f' %area)

Sunday, April 4, 2021

A note on ex nihilo

In terms of the origin of the universe, "Out of nothing" is something we often hear from theists who argue that something, i.e the universe,  cannot come from nothing from which they conclude that it must have come from something, which they call God. 

The notion of nothing 'before' the universe however is problematic because what is 'nothing'? It is better to refer to the 'nothing' as something that isn't space-time, rather than a simple negation of space-time. What 'out of nothing' seems to imply is that space-time cannot come from space-time which seems reasonable.

All our notations of cause and effect and the logical absolutes only operate within our own space-time. It is impossible for us to contemplate anything that isn't space-time, so asking questions about creation is extremely difficult if not impossible. Jumping to God as an explanation, however, makes no sense since we can't comprehend anything outside space-time, let alone an all-powerful sentient being to which the bible attaches all sorts of very specific properties. 

Thursday, September 3, 2020

Mathpix Snip

Originally Posted on  by hsauro

I came across this amazing tool that can convert images of math equations into LaTeX format. The tool can be found at https://mathpix.com/. I’ve tried it on a number of texts including some not so clear and it does a fantastic job of converting to LaTeX. Here is a screen showing part of a page from Paul’s Online Notes:



The way it works is you select the screen icon on the mathpix tool, the entire screen goes black and white, then we draw a square around the section we want to convert and that’s it. In this case, it generates the following latex

We’ll start with finding the derivative of the sine function. To do this we will need to use the definition of the derivative. It’s been a while since we’ve had to use this, but sometimes there just isn’t anything we can do about it. Here is the definition of the derivative for the sine function.
$$
\frac{d}{d x}(\sin (x))=\lim _{h \rightarrow 0} \frac{\sin (x+h)-\sin (x)}{h}
$$
since we can’t just plug in $h=0$ to evaluate the limit we will need to use the following trig formula on the first sine in the numerator.
$$
\sin (x+h)=\sin (x) \cos (h)+\cos (x) \sin (h)
$$
Doing this gives us,
$$
\begin{aligned}
\frac{d}{d x}(\sin (x)) &=\lim _{h \rightarrow 0} \frac{\sin (x) \cos (h)+\cos (x) \sin (h)-\sin (x)}{h} \\
&=\lim _{h \rightarrow 0} \frac{\sin (x)(\cos (h)-1)+\cos (x) \sin (h)}{h} \\
&=\lim _{h \rightarrow 0} \sin (x) \frac{\cos (h)-1}{h}+\lim _{h \rightarrow 0} \cos (x) \frac{\sin (h)}{h}
\end{aligned}
$$
As you can see upon using the trig formula we can combine the first and third term and then factor a sine out of that. We can then break up the fraction into two pieces, both of which can be dealt with separately.

Which when processed by LaTeX becomes:



This is rendered inside the mathpix tool but you’ll notice there isn’t a significant difference between the original and the converted image. I’ve converted some fairly rough images and it generally succeeds. It also gives you a confidence level on how well it thinks it’s done. It took under a second to generate the LaTeX.

As a harder test, I decided to attempt to translate a page from Jim Burns’ thesis. This is a thesis from the 1970s that was typed and the equations a combination of typed characters and hand drawn. The following image shows page 93 which is part of the proof for the connectivity theorem.



And here is the image analyzed by mathpix. Remarkably the conversion is almost perfect, the equations, in particular, are translated almost without error, even getting the subscripts on the subscripts correct. It got the delta F1 wrong at the start and it interpreted a mark on the paper as an apostrophe. I tried other pages that included derivatives and these converted without incident.



Saturday, December 14, 2019

Marsaglia’s MWC (multiply with carry) Random Number Generator for Object Pascal

Originally Posted on  by hsauro 

In the past, I’ve tended to use the Mersenne Twister for generating pseudo-random numbers. This is a widely used generator because it has a very long period of 2^{19937} – 1. The one issue is that it’s not the fastest generator and this is particularly an issue when drawing random numbers for implementing the Gillespie direct method. A much faster variant is the Multiply-with-carry (MWC) random number generator. This uses much simpler arithmetic which means it’s faster. The algorithm can be described in three lines:

  \[  m_z = 36969 * (m_z \text{ and } 65535) + (m_z >> 16) \]

  \[ m_w = 18000 * (m_w \text{ and } 65535) + (m_w >> 16) \]

  \[ \text{random number} = (m_z << 16) + m_w \]

The symbol >> means shift the bits to the right by the given number and << is similar but moves the bits to the left. In object pascal, these operations are represented by shr and shl respectively. The generator needs two values to be initialized, m_z and m_w I've recently implemented the Gillespie method in three languages, C, Go and Object Pascal. Object Pascal has good support for the Mersenne Twister but I had to create my own MWC generator. The code below shows the object pascal implementation:

What about some tests? There are random generator test systems such as TestU01 and dieharder but they are written to run on Linux and I didn't have time to set something up on windows plus the usage docs are not that great. Instead I did three simple sanity tests. The simplest is to check that the mean value for a sample of random numbers is 0.5. Another test is to make sure that, say out of 10,000 random numbers, 10% are between 0 and 0.1, etc. Ideally there should be statistical tests done to check that these values are within certain tolerances. The third test is a visual test where I generate 32768 random numbers and map them on to a bitmap. Each random number is 32 bits long and each bit represents a pixel in the bitmap. 32768 numbers means I generate a bitmap 1024 by 1024 pixels. Thus 32 numbers occupy each row of the bitmap. I wrote a simple Delphi console application that calls the random number generator and creates the bitmap. The main part of this code is shown below. For a comparison I also implemented the NOT to be used randu generator and also the Delphi's built in generator. The approach I take isn't very sophisticated and I am sure it could be made shorter, but for each random number I generate, I convert it into a string of 1's and 0's. I then work my way through the string setting pixels in a bitmap. I do this 32 times for each row in the bitmap.

The results of running this code is below. First randu to show you how bad it is, note the patterns and lines in the bitmap:



The next figure shows the results from Delphi’s builtin random number generator, which isn’t so great either:



Finally, the MWC algorithm, which you can see from the image the distribution of pixels appears to show no pattern: