organoid_tracker.core.links module
- class organoid_tracker.core.links.LinkingTrack(positions_by_time_point: List[Position])
Bases:
object
- find_all_descending_tracks(include_self: bool = False) Iterable[LinkingTrack]
Iterates over all tracks that will follow this one, and the one after that, etc.
- find_all_previous_and_descending_tracks(*, include_self: bool = False) Iterable[LinkingTrack]
Finds all tracks that are either before this track, or after this track.
Note: this method will not tracks that branched off earlier in the lineage tree, like sister tracks, or newphew tracks. It will only find ancestors and its own progeny. If you want to find all tracks in the same lineage, use find_all_tracks_in_same_lineage.
- find_all_previous_tracks(include_self: bool = False) Iterable[LinkingTrack]
Iterates over all tracks that precede this one, and the one before that, etc.
- find_all_tracks_in_same_lineage(*, include_self: bool = False) Iterable[LinkingTrack]
Finds all tracks that are in the same lineage as this track.
Note: in case of cell merges, an arbitrary choice is made to follow one of the ancestors.
- get_age(position: Position) int
Gets the age of this position. This will be 0 if its the first track position, 1 on the position after that, etcetera.
- get_duration_in_time_points() int
Gets the time this track takes in time points. This is simply the number of recorded positions.
- get_next_tracks() Set[LinkingTrack]
Gets a set of the tracks that will directly follow this track. If empty, the lineage end. If the length is 2, it is a cell division. Lengths of 1 will never occur. Lengths of 3 can occur, but make no biological sense.
See find_all_descending_tracks if you’re also interested in the tracks that come after that.
- get_previous_tracks() Set[LinkingTrack]
Gets a set of the tracks before this track. If empty, the lineage started. Normally, the set will have a size of 1. Larger sizes indicate a cell merge, which makes no biological sense.
- is_time_point_number_in_range(time_point_number: int) bool
Checks if the given time point number is in the range of this track.
- last_time_point_number() int
Gets the highest time point number where this track still contains a position .
- class organoid_tracker.core.links.Links
Bases:
object
Represents all links between positions at different time points. This is used to follow particles over time. If a position is linked to two positions in the next time step, than that is a cell division. If a position is linked to no position in the next step, then either the cell died or the cell moved out of the image.
- add_link(position1: Position, position2: Position)
Adds a link between the positions. The linking network will be initialized if necessary.
- add_links(links: Links)
Adds all links from the graph. Existing link are not removed. Changes may write through in the original links.
- add_track(track: LinkingTrack)
Adds a track to the linking network. This is useful if you have a track that is not linked to the rest of the network yet.
- connect_tracks(*, previous: LinkingTrack, next: LinkingTrack)
Connects two tracks. The previous track should end one time point before the next track starts. Raises ValueError if the tracks are not after each other in time or if they are already connected.
- contains_link(position1: Position, position2: Position) bool
Returns True if the two given positions are linked to each other.
- contains_position(position: Position) bool
Returns True if the given position is part of this linking network.
- copy() Links
Returns a copy of all the links, so that you can modify that data set without affecting this one.
- debug_sanity_check()
Checks if the data structure still has a valid structure. If not, this method throws ValueError. This should never happen if you only use the public methods (those without a _ at the start), and don’t poke around in internal code.
This method is very useful to debug the data structure if you get some weird results.
- find_all_data_of_lineage(track: LinkingTrack) Iterable[Tuple[str, Union[float, int, str, bool, List[float], List[int], List[str], List[bool]]]]
Finds all lineage data of the given track.
- find_all_links() Iterable[Tuple[Position, Position]]
Gets all available links. The first position is always the earliest in time.
- find_all_positions() Iterable[Position]
Gets all positions in the linking graph. Note that positions without links are not included here.
- find_all_tracks() Iterable[LinkingTrack]
Gets all tracks, even tracks that have another track before them.
- find_all_tracks_and_ids() Iterable[Tuple[int, LinkingTrack]]
Gets all tracks and their id. Just like get_all_tracks, this method returns tracks that have another track before them in time.
- find_all_tracks_in_time_point(time_point_number: int) Iterable[LinkingTrack]
This method finds all tracks that run trough the given time point.
- find_appeared_positions(time_point_number_to_ignore: Optional[int] = None) Iterable[Position]
This method gets all positions that “popped up out of nothing”: that have no links to the past. You can give this method a time point number to ignore. Usually, this would be the first time point number of the experiment, as cells that have no links to the past in the first time point are not that interesting.
- find_disappeared_positions(time_point_number_to_ignore: Optional[int] = None) Iterable[Position]
This method gets all positions that “disappear into nothing”: that have no links to the future. You can give this method a time point number to ignore. Usually, this would be the last time point number of the experiment, as cells that have no links to the future in the last time point are not that interesting.
- find_ending_tracks() Iterable[LinkingTrack]
Gets all ending tracks, which are all tracks that have no links to the future.
- find_futures(position: Position) Set[Position]
Returns the positions linked to this position in the next time point. Normally, this will be one position. However, if the cell divides between now and the next time point, two positions are returned. And if the cell track ends, zero positions are returned.
- find_links_of(position: Position) Set[Position]
Gets all links of a position, both to the past and the future.
- find_pasts(position: Position) Set[Position]
Returns the positions linked to this position in the previous time point. Normally, this will be one position. However, the cell track just started, zero positions are returned. In the case of a cell merge, multiple positions are returned.
- find_single_future(position: Position) Optional[Position]
If the given position is linked to exactly one other position, then that position is returned.
- find_single_past(position: Position) Optional[Position]
If the position has a single link to the previous time point, then this method returns that linked position. Otherwise, it returns None.
- find_starting_tracks() Iterable[LinkingTrack]
Gets all starting tracks, which are all tracks that have no links to the past.
- get_highest_track_id() int
Gets the highest track id currently in use. Returns -1 if there are no tracks.
- get_lineage_data(track: LinkingTrack, data_name: str) Optional[Union[float, int, str, bool, List[float], List[int], List[str], List[bool]]]
Gets the attribute of the lineage tree. Returns None if not found.
- get_position_at_time_point(position: Position, time_point: TimePoint) Optional[Position]
Follows the position backwards or forwards in time through the linking network, until a position at the given time point has been found. If a cell divides, an arbitrary daughter cell will be picked. Returns None if we couldn’t track the position until the requested time point.
- get_position_near_time_point(position: Position, time_point: TimePoint) Position
Follows the position backwards or forwards in time through the linking network, until a position as close as possible to the specified time has been reached. If the given position has no links, the same position will just be returned. If a cell divides, an arbitrary daughter cell will be picked.
- get_track(position: Position) Optional[LinkingTrack]
Gets the track the given position belong in.
- get_track_by_id(track_id: int) Optional[LinkingTrack]
Gets the track with the given id, or None if no such track exists.
- get_track_id(track: LinkingTrack) Optional[int]
Gets the track id of the given track. Returns None if the track is not stored in the linking data here.
- iterate_to_future(position: Position) Iterable[Position]
Iterates towards the future, yielding this position, the next position, the position after that, ect. Stops at cell divisions or at the last detection.
- iterate_to_past(position: Position) Iterable[Position]
Iterates towards the past, yielding this position, the previous position, the position before that, ect. Stops at cell merges or at the first detection.
- of_time_point(time_point: TimePoint) Iterable[Tuple[Position, Position]]
Returns all links where one of the two positions is in that time point. The first position in each tuple is in the given time point, the second one is one time point earlier or later.
- remove_all_links()
Removes all links in the experiment.
- remove_link(position1: Position, position2: Position)
Removes the link between the given positions. Does nothing if there is no link between the positions.
- replace_position(old_position: Position, position_new: Position)
Replaces one position with another. The old position is removed from the graph, the new one is added. All links will be moved over to the new position