Package: cytolysis
CytolysisA python module to facilitate the automatic analysis cytosim simulations.
By itself, it does not include many analysis functions but mostly an API.Installationpip3installcytolysisRequirementsRequires Python3 and modules numpy, pandas.To visualize the simulation in iPython (Jupyter Notebook),
you should installipyvolume:condainstall-cconda-forgeipyvolumePractical examplesWe provide several examples where we analyze the result of a simulation for an exampleconfig file.
This simulation has two asters of microtubules brought to the center by the rigidity of the microtubules and by the activity of dyneins.An example counting the number of fiber points for each filament, and at each time:python3examples/example_fibers.pyAn example where we compute the fiber bending energy as a function of timepython3examples/example_fiber_curvature.pyWe can also analyze any cytosim class that can be reported, by creating custom objects.
For example, this is done here for solids and spaces :python3examples/example_solid.pySeveral ipython notebooks are also available in the notebook folder.Interface (examples)Import the module :fromcytolysisimportcytosim_analysisasanaThe main class isSimulation, a list of time frames. Create an instance of a simulation analysis via :microtubule_reports={'points':'fiber_points.txt'}simul=ana.Simulation(reports={'microtubule':microtubule_reports},config='config.cym')You can specify analysis functions for the different simulation objects, specifying by object name :defcount_points(fiber):returnfiber.shape[0]defcount_fibers(frame):returnlen(frame.fibers)analyzer={}analyzer['microtubule']={'pts_number':count_points}analyzer['frame']={'fib_number':count_fibers}You can then run the analysis :simul.make_analysis(analyzer=analyzer)The analysis of objects is stored as pandas dataframes in the frames. For exemple, the analysis of microtubules for frame5is stored in :simul[5].analysis['microtubule']Similarly, the analysis for couples 'arp_2_3' at frame 10 is stored in :simul[10].analysis['arp_2_3']Simul is a set of frames, and the results of the analysis of all frames can be accessed in :simul.frames_analysisWhile a global analysis of the simulation is available in :simul.analysisThe module contains a function to export analysis dataframes into csv files :ana.export_analysis(simul.frames_analysis,'frames.csv')There is also experimental support for showing the system in 3D in notebooks :simul.show(frame_number)ComponentsSimulationThe classSimulationis a set offrames, instances of the classFrame. Input arguments :reports : a dictionary of dictionaries of pathes to report files.options : a dictionary of dictionaries of options.config : path to the config filedim : dimensionality of the simulation (by default, 3)Simulation has a methodmake_analysisto perform the analysis.
This takes as optionanalyzer, a dictionary of dictionaries of analysis functions.simulation.make_analysisperforms the analysis specified inanalyzer["simulation"],
and the result is stored insimulation.analysis.As a set of frames , simulation implementssimulation.analyze(frame, analyzer=..., ... )(seeObject_set).
This performs the analysis specified inanalyzer['frame']. The results are stored insimulation.frames_analysisFrameEach frame contains several types of dictionaries of object_sets.
Each dictionary is of the type : { name :object_set}.
For instance, if fibers have been loaded, they are available inframe.objects["fibers"].Once the analysis has been performed, the analysis results are stored in :frame.analysis[object_type], e.g.frame.analysis["fibers"].Frame implements the analysis methodframe.make_analysis(...)that calls theobject_set.analyze(object, ...)method of all object sets.Object_setObject set is a class derived from list.Fibers_setandCouples_setare derived fromObject_set. Input arguments :name: name of the object (e.g. "microtubule")type: type of the object (e.g. "fiber")Optional input arguments :config: the pile read from the configuration filebuild: a function to build the object set from the reportsBeyond the initialization (init) method, object set need to implement the methods :object_set.analyze(object, ... ): a function that analyzesobject, a given item from the object setobject_set.type: object typeobject_set.name: object nameobject_set.id: object id (a number)object_set.properties: a dictionary of properties read from the config fileobject_set.show: a way to plot the object set in 3D using iPyVolumeAnalysisAll the analysis results (simulation.analysis,frame.analysis["fibers"], etc.) are stored as Pandas dataframes
and, by default, exported as csv files. Examples:frame.analysis["fiber"][fiber_name]is a dataframe with as many rows as there are fibers.simulation.frame_analysisis a dataframe with as many rows as there are frames.simulation.analysisis a dataframe with a single row.Therefore, if one wants to look at the distribution of some property among objects for a given frame,
one would exportframe.analysis[object_type][object_name].If one wants to analyze something over time, one would exportsimulation.frame_analysis.If one wants a single line to sumarize the simulation, for instance in order to compare different simulations, one would
exportsimulation.analysis.PlottingWhen used in iPython, cytolysis can represent the system in 3D,
and allows to plot objects differently according to their properties,
see thisexample.