## Overview
For Figure 8 and Supplementary Figure 9, The detected single nucleosomes inside/outside the chromosome axis region were analyzed independently.
This script sorts the trajectories located inside/outside the axis region, defined by the binary image of SMC2-mClover.
Detected single nucleosomes inside/outside the axis region were categorized based on the centroids of their trajectories (i.e., the time average of XY coordinates).


## System requirements
This code is written and tested on Python 3.9 environment built with Anaconda Software Distribution (https://anaconda.com/).
The required Python packages are;
- numpy (https://numpy.org/)	- tested with version 1.21.5
- skimage (https://scikit-image.org/)	- tested with version 0.19.3
- matplotlib (https://matplotlib.org/)	- tested with version 3.7.1


## File description
- 01_Track_sorting_20220713.py	- Script file for track sorting

SAMPLE_DATA contains input and output files.
- 20210909b032.csv	- input files containing xy coordinates of the detected particles
- 20210909b032.tif	- input binary image defining chromosome axis region
- 20210909b032_ROIin.csv, 20210909b032_ROIout.csv	- output files containing trajectories
- 20210909b032_centroid-set.csv	- output file containing the calculated centroids of dots
- 20210909b032_sorted-result_xycoordinates.png	- output image showing the sorting result


## How to run
Run Track Sorting using the following command.
Make sure that the SAMPLE_DATA folder is present in the same directory.

```
python 01_Track_sorting_20220713.py
```


## Expected output
Track Sorting generates two csv files recording XY-coordinates of the trajectories inside/outside chromosome axis region.
The files will be exported under "./csvfile/XXX_ROIin" and "./csvfile/XXX_ROIout".
The categorized trajectories were used in subsequent MSD calculations.
This code also generates the plot showing the spatial position of the trajectories for checking results. Trajectories inside the axis are shown in magenta and those outside the axis are shown in green.
The plots will be exported under "./Binary_mask/XXX/".

Execution time is approximately several seconds per single-cell sample.