LNA task execution in BASICO

52 views
Skip to first unread message

manmath panigrahy

unread,
Oct 29, 2024, 9:51:27 AM10/29/24
to COPASI User Forum
Hi all, 
I am trying to get the covariance matrix using BASICO in VS code(python environment) using LNA task; although the task executes successfully; the output is empty. Does the library for this task is not updated as i need the covariance matrix as the output. Or could you please share a line of code to extract the output if any specific command is included in the library which i might not know !

Frank Bergmann

unread,
Oct 29, 2024, 10:21:05 AM10/29/24
to COPASI User Forum
I've not yet added convenience functions for returning results from the LNA task, i shall do so within the next days and let you know. 

best
Frank

Sebastián

unread,
Oct 29, 2024, 10:40:09 AM10/29/24
to COPASI User Forum
Hi,

Sorry to get into this conversation, but may be related. Can LNA be applied to ODE systems (dynamically) as well in COPASI? I have only been able to run LNA in steady state using the COPASI interface.

Best,
Sebastian

Frank Bergmann

unread,
Oct 29, 2024, 10:56:27 AM10/29/24
to COPASI User Forum
To follow up on my own message, unfortunately currently there is no access to the results from the LNA task from python (or any language other than Java). We'll add that to the SWIG API with the next version of COPASI. I'll inform here when we have a snapshot available. 

best
Frank

Frank Bergmann

unread,
Oct 29, 2024, 11:00:22 AM10/29/24
to COPASI User Forum


Sorry to get into this conversation, but may be related. Can LNA be applied to ODE systems (dynamically) as well in COPASI? I have only been able to run LNA in steady state using the COPASI interface.


COPASI will only calculate the LNA after it reached a steady state. 

best
Frank

Pedro Mendes

unread,
Oct 29, 2024, 12:08:34 PM10/29/24
to copasi-u...@googlegroups.com
*** Attention: This is an external email. Use caution responding, opening attachments or clicking on links. ***

Unfortunately LNA has only been developed for steady state. Maybe these
two papers (and others cited there) are useful:
https://doi.org/10.1186/1752-0509-6-86
https://doi.org/10.1088/1742-5468/2012/11/P11010

Pedro
> --
> You received this message because you are subscribed to the Google
> Groups "COPASI User Forum" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to copasi-user-fo...@googlegroups.com
> <mailto:copasi-user-fo...@googlegroups.com>.
> To view this discussion visit
> https://groups.google.com/d/msgid/copasi-user-forum/a1776271-9dec-4e42-9548-a4236b2adf3fn%40googlegroups.com <https://groups.google.com/d/msgid/copasi-user-forum/a1776271-9dec-4e42-9548-a4236b2adf3fn%40googlegroups.com?utm_medium=email&utm_source=footer>.

--
Pedro Mendes, PhD
Professor and Director
Richard D. Berlin Center for Cell Analysis and Modeling
University of Connecticut School of Medicine
group website: http://www.comp-sys-bio.org

Frank Bergmann

unread,
Nov 13, 2024, 9:45:17 AM11/13/24
to COPASI User Forum
I've now released a new version of basico that includes access to the LNA results: 


To install, ensure you upgrade the `copasi-basico` and `python-copasi` modules using pip. 

Cheers
Frank

manmath panigrahy

unread,
Nov 13, 2024, 10:26:00 AM11/13/24
to copasi-u...@googlegroups.com
Thank you so much, professor. 

With regards, 
Manmath

To unsubscribe from this group and stop receiving emails from it, send an email to copasi-user-fo...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/copasi-user-forum/3caee1c2-06e9-443b-a050-0d4fa2f2dfafn%40googlegroups.com.
Message has been deleted
Message has been deleted

Frank Bergmann

unread,
Nov 21, 2024, 3:52:15 AM11/21/24
to COPASI User Forum
The problem is, that the pre-release version of COPASI that is being used by basico for the LNA does not find a steady state with the settings you have made. I've changed the Target criterium in the attached file, such that a steady state is found. With that it basico can compute the LNA. We are looking into why we did not find a steady state anymore with the original settings. 

best
Frank


On Wednesday, November 20, 2024 at 7:14:16 PM UTC+1 manmathpa...@gmail.com wrote:
I am also attaching the output plot where i have run the lna task using basico for different initial A and K, keeping all the other species zero as initial conditions; 
The white space is where the lna task is failed to execute. But while doing it in the copasi gui it works completely fine. 
On Wednesday, November 20, 2024 at 6:09:26 PM UTC manmath panigrahy wrote:
from basico import *
print("COPASI Basico is imported successfully!")
load_model('C:\\Users\\mpanigra\\Desktop\\Multisite pdpc Work folder\\COPASI FILES\\distributive ordered multisite pdpc.cps')
get_species()
get_parameters()
run_lna()
import matplotlib.pyplot as plt
df_cov_matrix = get_lna_covariance_matrix()
   
# Generate heatmap
plt.figure(figsize=(10, 8))
plt.imshow(df_cov_matrix, cmap='viridis', aspect='auto')
plt.colorbar()
plt.title('LNA Covariance Matrix Heatmap')
plt.xticks(range(df_cov_matrix.shape[1]), df_cov_matrix.columns, rotation=90)
plt.yticks(range(df_cov_matrix.shape[0]), df_cov_matrix.index)
plt.show()
output: Could not run LNA Task:
COPASI Basico is imported successfully!

run_lna()

# Get the covariance matrix
cov_matrix = get_lna_covariance_matrix()

print(cov_matrix)


if isinstance(cov_matrix, pd.DataFrame):
    element_55 = cov_matrix.iloc[5, 5]
else:
    element_55 = cov_matrix[5, 5]

print(f"\nElement (5, 5): {element_55}")
Could not run LNA Task:
K P AP AK PAPP APP A PAP APK K NaN NaN NaN NaN NaN NaN NaN NaN NaN P NaN NaN NaN NaN NaN NaN NaN NaN NaN AP NaN NaN NaN NaN NaN NaN NaN NaN NaN AK NaN NaN NaN NaN NaN NaN NaN NaN NaN PAPP NaN NaN NaN NaN NaN NaN NaN NaN NaN APP NaN NaN NaN NaN NaN NaN NaN NaN NaN A NaN NaN NaN NaN NaN NaN NaN NaN NaN PAP NaN NaN NaN NaN NaN NaN NaN NaN NaN APK NaN NaN NaN NaN NaN NaN NaN NaN NaN Element (5, 5): nan
Dear Professor,

For the uploaded model named distributive ordered multisite pdpc.cps; i run the linear noise approximation task; for some initial conditions of A and K keeping P=90, the lna task executes
well in basico but for other initial conditions (let A=1900, K=800) the copasi software runs smoothly and gives the covariance matrix but basico fails at that. I have attached the copasi model file
and the output that i am getting. Please look into it as i think there is some issue with the package.

With regards,
Manmath
distributive ordered multisite pdpc_distance.cps
Message has been deleted

frank.thom...@gmail.com

unread,
Nov 21, 2024, 11:10:59 AM11/21/24
to copasi-u...@googlegroups.com

You can change the target criterion as follows;

 

  1. Retrieve the task settings for the steady state task
  2. Change the method dictionary entry for "Target Criterion" to one of : “Rate”, “Distance” or “Distance and Rate”
  3. Set the task settings with the updated dictionary

 

In python:

 

 

```python

settings = get_task_settings(T.STEADY_STATE)

settings['method']['Target Criterion'] = 'Distance' # or 'Rate' or 'Distance and Rate'

set_task_settings(T.STEADY_STATE, settings)

```

 

Best

Frank

 

From: copasi-u...@googlegroups.com <copasi-u...@googlegroups.com> On Behalf Of manmath panigrahy
Sent: Thursday, November 21, 2024 3:46 PM
To: COPASI User Forum <copasi-u...@googlegroups.com>
Subject: Re: [copasi-user-forum] Re: LNA task execution in BASICO

 

If i am making a new copasi file for a different model altogether, and if this problem still occurs, how can i change the target criterion myself !

manmath panigrahy

unread,
Nov 21, 2024, 1:49:19 PM11/21/24
to copasi-u...@googlegroups.com
Thank you, Professor. 

With regards,
Manmath

Reply all
Reply to author
Forward
0 new messages