fucciphase 0.0.1__py3-none-any.whl → 0.0.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- fucciphase/main_cli.py +200 -0
- fucciphase/plot.py +2 -2
- {fucciphase-0.0.1.dist-info → fucciphase-0.0.2.dist-info}/METADATA +2 -2
- {fucciphase-0.0.1.dist-info → fucciphase-0.0.2.dist-info}/RECORD +7 -5
- fucciphase-0.0.2.dist-info/entry_points.txt +3 -0
- {fucciphase-0.0.1.dist-info → fucciphase-0.0.2.dist-info}/WHEEL +0 -0
- {fucciphase-0.0.1.dist-info → fucciphase-0.0.2.dist-info}/licenses/LICENSE +0 -0
fucciphase/main_cli.py
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
import json
|
|
3
|
+
|
|
4
|
+
import pandas as pd
|
|
5
|
+
|
|
6
|
+
from fucciphase import process_dataframe, process_trackmate
|
|
7
|
+
from fucciphase.napari import add_trackmate_data_to_viewer
|
|
8
|
+
from fucciphase.phase import estimate_percentage_by_subsequence_alignment
|
|
9
|
+
from fucciphase.sensor import FUCCISASensor, get_fuccisa_default_sensor
|
|
10
|
+
|
|
11
|
+
try:
|
|
12
|
+
import napari
|
|
13
|
+
except ImportError as err:
|
|
14
|
+
raise ImportError("Install napari.") from err
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def main_cli() -> None:
|
|
18
|
+
"""Fucciphase CLI."""
|
|
19
|
+
parser = argparse.ArgumentParser(
|
|
20
|
+
prog="fucciphase",
|
|
21
|
+
description="FUCCIphase tool to estimate cell cycle phases and percentages.",
|
|
22
|
+
epilog="Please report bugs and errors on GitHub.",
|
|
23
|
+
)
|
|
24
|
+
parser.add_argument("tracking_file", type=str, help="TrackMate XML or CSV file")
|
|
25
|
+
parser.add_argument(
|
|
26
|
+
"-ref",
|
|
27
|
+
"--reference_file",
|
|
28
|
+
type=str,
|
|
29
|
+
help="Reference cell cycle CSV file",
|
|
30
|
+
required=True,
|
|
31
|
+
)
|
|
32
|
+
parser.add_argument(
|
|
33
|
+
"--sensor_file",
|
|
34
|
+
type=str,
|
|
35
|
+
help="sensor file in JSON format "
|
|
36
|
+
"(can be skipped, then FUCCI SA sensor is used by default)",
|
|
37
|
+
default=None,
|
|
38
|
+
)
|
|
39
|
+
parser.add_argument(
|
|
40
|
+
"-dt", "--timestep", type=float, help="timestep in hours", required=True
|
|
41
|
+
)
|
|
42
|
+
parser.add_argument(
|
|
43
|
+
"-m",
|
|
44
|
+
"--magenta_channel",
|
|
45
|
+
type=str,
|
|
46
|
+
help="Name of magenta channel in TrackMate file",
|
|
47
|
+
required=True,
|
|
48
|
+
)
|
|
49
|
+
parser.add_argument(
|
|
50
|
+
"-c",
|
|
51
|
+
"--cyan_channel",
|
|
52
|
+
type=str,
|
|
53
|
+
help="Name of cyan channel in TrackMate file",
|
|
54
|
+
required=True,
|
|
55
|
+
)
|
|
56
|
+
parser.add_argument(
|
|
57
|
+
"--generate_unique_tracks",
|
|
58
|
+
type=bool,
|
|
59
|
+
help="Split subtracks (TrackMate specific)",
|
|
60
|
+
default=False,
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
args = parser.parse_args()
|
|
64
|
+
|
|
65
|
+
reference_df = pd.read_csv(args.reference_file)
|
|
66
|
+
reference_df.rename(
|
|
67
|
+
columns={"cyan": args.cyan_channel, "magenta": args.magenta_channel},
|
|
68
|
+
inplace=True,
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
if args.sensor_file is not None:
|
|
72
|
+
with open(args.sensor_file) as fp:
|
|
73
|
+
sensor_properties = json.load(fp)
|
|
74
|
+
sensor = FUCCISASensor(**sensor_properties)
|
|
75
|
+
else:
|
|
76
|
+
sensor = get_fuccisa_default_sensor()
|
|
77
|
+
|
|
78
|
+
if args.tracking_file.endswith(".xml"):
|
|
79
|
+
df = process_trackmate(
|
|
80
|
+
args.tracking_file,
|
|
81
|
+
channels=[args.cyan_channel, args.magenta_channel],
|
|
82
|
+
sensor=sensor,
|
|
83
|
+
thresholds=[0.1, 0.1],
|
|
84
|
+
generate_unique_tracks=args.generate_unique_tracks,
|
|
85
|
+
)
|
|
86
|
+
elif args.tracking_file.endswith(".csv"):
|
|
87
|
+
df = pd.read_csv(args.tracking_file)
|
|
88
|
+
process_dataframe(
|
|
89
|
+
df,
|
|
90
|
+
channels=[args.cyan_channel, args.magenta_channel],
|
|
91
|
+
sensor=sensor,
|
|
92
|
+
thresholds=[0.1, 0.1],
|
|
93
|
+
generate_unique_tracks=args.generate_unique_tracks,
|
|
94
|
+
)
|
|
95
|
+
else:
|
|
96
|
+
raise ValueError("Tracking file must be an XML or CSV file.")
|
|
97
|
+
|
|
98
|
+
track_id_name = "UNIQUE_TRACK_ID"
|
|
99
|
+
if not args.generate_unique_tracks:
|
|
100
|
+
track_id_name = "TRACK_ID"
|
|
101
|
+
|
|
102
|
+
estimate_percentage_by_subsequence_alignment(
|
|
103
|
+
df,
|
|
104
|
+
dt=args.timestep,
|
|
105
|
+
channels=[args.cyan_channel, args.magenta_channel],
|
|
106
|
+
reference_data=reference_df,
|
|
107
|
+
track_id_name=track_id_name
|
|
108
|
+
)
|
|
109
|
+
df.to_csv(args.tracking_file + "_processed.csv", index=False)
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def main_visualization() -> None:
|
|
113
|
+
"""Fucciphase visualization."""
|
|
114
|
+
parser = argparse.ArgumentParser(
|
|
115
|
+
prog="fucciphase-napari",
|
|
116
|
+
description="FUCCIphase napari script to launch visualization.",
|
|
117
|
+
epilog="Please report bugs and errors on GitHub.",
|
|
118
|
+
)
|
|
119
|
+
parser.add_argument("fucciphase_file", type=str, help="Processed file.")
|
|
120
|
+
parser.add_argument(
|
|
121
|
+
"video", type=str, help="OME-Tiff file with video data and segmentation masks"
|
|
122
|
+
)
|
|
123
|
+
parser.add_argument(
|
|
124
|
+
"-m",
|
|
125
|
+
"--magenta_channel",
|
|
126
|
+
type=int,
|
|
127
|
+
help="Index of magenta channel in video file",
|
|
128
|
+
required=True,
|
|
129
|
+
)
|
|
130
|
+
parser.add_argument(
|
|
131
|
+
"-c",
|
|
132
|
+
"--cyan_channel",
|
|
133
|
+
type=int,
|
|
134
|
+
help="Index of cyan channel in video file",
|
|
135
|
+
required=True,
|
|
136
|
+
)
|
|
137
|
+
parser.add_argument(
|
|
138
|
+
"-s",
|
|
139
|
+
"--segmask_channel",
|
|
140
|
+
type=int,
|
|
141
|
+
help="Index of segmentation mask channel in video file",
|
|
142
|
+
required=True,
|
|
143
|
+
)
|
|
144
|
+
parser.add_argument(
|
|
145
|
+
"--pixel_size",
|
|
146
|
+
type=float,
|
|
147
|
+
help="Pixel size, only used if not in metadata",
|
|
148
|
+
default=None)
|
|
149
|
+
|
|
150
|
+
args = parser.parse_args()
|
|
151
|
+
|
|
152
|
+
AICSIMAGE = False
|
|
153
|
+
BIOIMAGE = False
|
|
154
|
+
try:
|
|
155
|
+
from aicsimageio import AICSImage
|
|
156
|
+
|
|
157
|
+
AICSIMAGE = True
|
|
158
|
+
except ImportError as err:
|
|
159
|
+
from bioio import BioImage
|
|
160
|
+
|
|
161
|
+
BIOIMAGE = True
|
|
162
|
+
import bioio_ome_tiff
|
|
163
|
+
|
|
164
|
+
if not BIOIMAGE:
|
|
165
|
+
raise ImportError(
|
|
166
|
+
"Please install AICSImage or bioio to read videos"
|
|
167
|
+
) from err
|
|
168
|
+
if AICSIMAGE:
|
|
169
|
+
image = AICSImage(args.video)
|
|
170
|
+
elif BIOIMAGE:
|
|
171
|
+
image = BioImage(args.video, reader=bioio_ome_tiff.Reader)
|
|
172
|
+
scale = (image.physical_pixel_sizes.Y, image.physical_pixel_sizes.X)
|
|
173
|
+
if None in scale:
|
|
174
|
+
if args.pixel_size is not None:
|
|
175
|
+
scale = (args.pixel_size, args.pixel_size)
|
|
176
|
+
else:
|
|
177
|
+
print("WARNING: No pixel sizes found, using unit scale")
|
|
178
|
+
scale = (1.0, 1.0)
|
|
179
|
+
cyan = image.get_image_dask_data("TYX", C=args.cyan_channel)
|
|
180
|
+
magenta = image.get_image_dask_data("TYX", C=args.magenta_channel)
|
|
181
|
+
masks = image.get_image_dask_data("TYX", C=args.segmask_channel)
|
|
182
|
+
track_df = pd.read_csv(args.fucciphase_file)
|
|
183
|
+
|
|
184
|
+
viewer = napari.Viewer()
|
|
185
|
+
|
|
186
|
+
add_trackmate_data_to_viewer(
|
|
187
|
+
track_df,
|
|
188
|
+
viewer,
|
|
189
|
+
scale=scale,
|
|
190
|
+
image_data=[cyan, magenta],
|
|
191
|
+
colormaps=["cyan", "magenta"],
|
|
192
|
+
labels=masks,
|
|
193
|
+
cycle_percentage_id="CELL_CYCLE_PERC_DTW",
|
|
194
|
+
textkwargs={"size": 14},
|
|
195
|
+
)
|
|
196
|
+
napari.run()
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
if __name__ == "__main__":
|
|
200
|
+
main_cli()
|
fucciphase/plot.py
CHANGED
|
@@ -293,7 +293,7 @@ def plot_dtw_query_vs_reference(
|
|
|
293
293
|
"Percentage column not found in reference DataFrame"
|
|
294
294
|
f", available options {reference_df.columns}"
|
|
295
295
|
)
|
|
296
|
-
|
|
296
|
+
_, ax = plt.subplots(1, len(channels))
|
|
297
297
|
for idx, channel in enumerate(channels):
|
|
298
298
|
ax[idx].plot(
|
|
299
299
|
df[est_percentage_column], df[channel], label="Query", **plot_kwargs
|
|
@@ -540,7 +540,7 @@ def plot_cell_trajectory(
|
|
|
540
540
|
**kwargs,
|
|
541
541
|
)
|
|
542
542
|
)
|
|
543
|
-
|
|
543
|
+
_, ax = plt.subplots()
|
|
544
544
|
for line_collection in line_collections:
|
|
545
545
|
ax.add_collection(line_collection)
|
|
546
546
|
ax.margins(0.05)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: fucciphase
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.2
|
|
4
4
|
Summary: Cell cycle analysis plugin.
|
|
5
5
|
Project-URL: homepage, https://github.com/nobias-ht/fucciphase
|
|
6
6
|
Project-URL: repository, https://github.com/nobias-ht/fucciphase
|
|
@@ -57,7 +57,7 @@ Obtain cell cycle information from FUCCI fluorescence intensities.
|
|
|
57
57
|
The best way to run fucciphase is to install it in a virtual conda environment.
|
|
58
58
|
Make sure that git is installed and can be called from the command line.
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
To install from pip:
|
|
61
61
|
|
|
62
62
|
```bash
|
|
63
63
|
pip install fucciphase
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
fucciphase/__init__.py,sha256=8PA6UNaYjycfPpOg7e5ArP3k9Lj9H15Lmw-Mnd14azY,375
|
|
2
2
|
fucciphase/fucci_phase.py,sha256=VgydHVN0nWzC6Eeh0LRaPHdScL2w7C5X7IhGSvyp4qw,6134
|
|
3
3
|
fucciphase/io.py,sha256=ELcoxsPHzcg9tf48MaMNnuSMxe0Fd3Nc9LCWbQ6p4I8,1715
|
|
4
|
+
fucciphase/main_cli.py,sha256=S4nRitMkLFFR77DHDT3j5_OtYbTST55ysMzE9J8pf9I,5979
|
|
4
5
|
fucciphase/phase.py,sha256=jy2l9LD81FTk6TIlyWyYPbVnwClGP9N4RrYyqtiMStg,17130
|
|
5
|
-
fucciphase/plot.py,sha256=
|
|
6
|
+
fucciphase/plot.py,sha256=gFoprFvJGH5Zb-227riRH1x5NEAAhpeqaVCyb1kYLr8,18589
|
|
6
7
|
fucciphase/py.typed,sha256=esB4cHc6c07uVkGtqf8at7ttEnprwRxwk8obY8Qumq4,187
|
|
7
8
|
fucciphase/sensor.py,sha256=6-WEI8viI5fSVyKHnECmKYKaROW4tQaPaNW4hHYVAcA,14788
|
|
8
9
|
fucciphase/tracking_utilities.py,sha256=IfKH2fyPo7fkW3PBvQrCz-UcfrdkOj7D-iLJabynvfw,2776
|
|
@@ -16,7 +17,8 @@ fucciphase/utils/phase_fit.py,sha256=Ht_dEyuLYonv6is9qQ-Xd95pQR7IR-8C8mv0ckDcp4E
|
|
|
16
17
|
fucciphase/utils/simulator.py,sha256=7bmrO0IWUqsk4CyM-PlVpG2QTJxjTsY1h6buxmTs1iM,2322
|
|
17
18
|
fucciphase/utils/track_postprocessing.py,sha256=cTe3OOCR4dxFBZwN7XdbzDbnsgouoJql8rv4WwvmbM8,14438
|
|
18
19
|
fucciphase/utils/trackmate.py,sha256=dir4ayS1Fl-gtK8NTbP7t7CBLnrumC8LgPiCwxsBf-c,10666
|
|
19
|
-
fucciphase-0.0.
|
|
20
|
-
fucciphase-0.0.
|
|
21
|
-
fucciphase-0.0.
|
|
22
|
-
fucciphase-0.0.
|
|
20
|
+
fucciphase-0.0.2.dist-info/METADATA,sha256=Hbprshl_yGXUkarqCfjd1r34CDz9doj2HSHo5XN0m8Q,4893
|
|
21
|
+
fucciphase-0.0.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
22
|
+
fucciphase-0.0.2.dist-info/entry_points.txt,sha256=B77Cm5QnxeQz6DEfqD6n7zDw48-HrlepWPwLbdVITMY,119
|
|
23
|
+
fucciphase-0.0.2.dist-info/licenses/LICENSE,sha256=pQGrOGpOTwikEzkZ8Zc9XLQwbaZ85TMJP-GaWCNZciw,1554
|
|
24
|
+
fucciphase-0.0.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|