Plot Rastergram
Here’s a full script that you can use to plot the (ordered) set of all events in your trajectories. For instance, if you have a three state model, where state 0
is unbound, and state 1
and state 2
are bound but different conformations, you can change the inds
variable (line 3, below) to show when state 1
and state 2
are happening.
= [1,2] inds
Note that you must have a model first. In general, you should save this as a .py
file, and use the Scripts
>> Run Scripts
menu option to run that file. You can edit it as you go if you want to change something, and then re-run it. Note that it use’s the current activate model for the calculation.
Save the code below in a file as plot_rastergram.py
import numpy as np
import matplotlib.pyplot as plt
= [0,]
inds
= maven.modeler.model
m = maven.data.nt
nt = m.nstates
nk = 1.
kb
= m.chain
vits = vits.shape
nmol,nt
= maven.data.pre_list
pre = maven.data.post_list
post
= np.zeros((nmol,nt)) + np.nan
data for i in range(nmol):
if post[i]-pre[i] > 1:
0:post[i]-pre[i]] = np.isin(vits[i][pre[i]:post[i]],inds).astype('float')
data[i,
= np.nanargmax(data,axis=1)
first = first.argsort()
order = data[order]
data
= maven.prefs['plot.time_dt']
dt = m.description()
desc = desc.split('] ')[1]
desc = ''.join(desc.split(' -')[:-1])
desc
= plt.subplots(1,figsize=(3,3))
fig,ax *dt,np.arange(nmol),data,cmap='Greys')
ax.pcolormesh(np.arange(nt)'Molecules')
ax.set_ylabel(
ax.set_yticks(())'Time (s)')
ax.set_xlabel(
ax.set_title(desc)
fig.tight_layout() plt.show()