lineagetree.measure.dynamic_time_warping
¶
Functions:
| Name | Description |
|---|---|
calculate_dtw |
Calculate DTW distance between two chains |
__calculate_diag_line
¶
Calculate the line that centers the band w.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
ndarray
|
distance matrix obtained by the function calculate_dtw |
required |
Returns:
| Type | Description |
|---|---|
float
|
The slope of the curve |
float
|
The intercept of the curve |
Source code in src/lineagetree/measure/dynamic_time_warping.py
__dp
¶
__dp(
dist_mat: ndarray,
start_d: int = 0,
back_d: int = 0,
fast: bool = False,
w: int = 0,
centered_band: bool = True,
) -> tuple[list[int], np.ndarray, float]
Find DTW minimum cost between two series using dynamic programming.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
ndarray
|
distance matrix obtained by the function calculate_dtw |
required |
|
int
|
start delay |
0
|
|
int
|
end delay |
0
|
|
bool
|
if |
False
|
|
int
|
window constrain |
0
|
|
bool
|
if |
True
|
Returns:
| Type | Description |
|---|---|
tuple of tuples of int
|
Aligment path |
ndarray
|
cost matrix |
float
|
optimal cost |
Source code in src/lineagetree/measure/dynamic_time_warping.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | |
__interpolate
¶
__interpolate(
lT: LineageTree,
chain1: list,
chain2: list,
threshold: int,
) -> tuple[np.ndarray, np.ndarray]
Interpolate two series that have different lengths
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
LineageTree
|
The LineageTree instance. |
required |
|
list of int
|
list of nodes of the first chain to compare |
required |
|
list of int
|
list of nodes of the second chain to compare |
required |
|
int
|
set a maximum number of points a chain can have |
required |
Returns:
| Type | Description |
|---|---|
list of np.ndarray
|
|
list of np.ndarray
|
|
Source code in src/lineagetree/measure/dynamic_time_warping.py
calculate_dtw
¶
calculate_dtw(
lT: LineageTree,
nodes1: int,
nodes2: int,
threshold: int = 1000,
regist: bool = True,
start_d: int = 0,
back_d: int = 0,
fast: bool = False,
w: int = 0,
centered_band: bool = True,
cost_mat_p: bool = False,
) -> (
tuple[float, tuple, np.ndarray, np.ndarray, np.ndarray]
| tuple[float, tuple]
)
Calculate DTW distance between two chains
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
LineageTree
|
The LineageTree instance. |
required |
|
int
|
node to compare distance |
required |
|
int
|
node to compare distance |
required |
|
int
|
set a maximum number of points a chain can have |
1000
|
|
bool
|
Rotate and translate trajectories |
True
|
|
int
|
start delay |
0
|
|
int
|
end delay |
0
|
|
bool
|
if |
False
|
|
int
|
window size |
0
|
|
bool
|
when running the fast algorithm, |
True
|
|
bool
|
True if print the not normalized cost matrix |
False
|
Returns:
| Type | Description |
|---|---|
float
|
DTW distance |
tuple of tuples
|
Aligment path |
matrix
|
Cost matrix |
list of lists
|
rotated and translated trajectories positions |
list of lists
|
rotated and translated trajectories positions |
Source code in src/lineagetree/measure/dynamic_time_warping.py
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 | |