topostats.tracing.dnatracing#
Perform DNA Tracing
Attributes#
Classes#
This class gets all the useful functions from the old tracing code and staples |
|
Combine and save trace statistics. |
Module Contents#
- topostats.tracing.dnatracing.LOGGER#
- class topostats.tracing.dnatracing.dnaTrace(full_image_data: numpy.ndarray, grains, filename: str, pixel_size: float, min_skeleton_size: int = 10, convert_nm_to_m: bool = True)[source]#
This class gets all the useful functions from the old tracing code and staples them together to create an object that contains the traces for each DNA molecule in an image and functions to calculate stats from those traces.
The traces are stored in dictionaries labelled by their gwyddion defined grain number and are represented as numpy arrays.
The object also keeps track of the skeletonised plots and other intermediates in case these are useful for other things in the future.
- full_image_data#
- grains_orig#
- filename#
- pixel_size#
- min_skeleton_size = 10#
- number_of_rows#
- number_of_columns#
- sigma#
- gauss_image = []#
- grains#
- dna_masks#
- skeletons#
- disordered_trace#
- ordered_traces#
- fitted_traces#
- splined_traces#
- contour_lengths#
- end_to_end_distance#
- mol_is_circular#
- curvature#
- number_of_traces = 0#
- num_circular = 0#
- num_linear = 0#
- unprocessed_grains = 0#
- neighbours = 5#
- get_numpy_arrays()[source]#
Function to get each grain as a numpy array which is stored in a dictionary
Currently the grains are unnecessarily large (the full image) as I don’t know how to handle the cropped versions
I find using the gwyddion objects clunky and not helpful once the grains have been found
There is some kind of discrepency between the ordering of arrays from gwyddion and how they’re usually handled in np arrays meaning you need to be careful when indexing from gwyddion derived numpy arrays
- _crop_array(bounding_box: Tuple) numpy.ndarray [source]#
Crop an array.
- Parameters:
array (np.ndarray) – 2D Numpy array to be cropped.
bounding_box (Tuple) – Tuple of co-ordinates to crop, should be of form (max_x, min_x, max_y, min_y) as returned by
_get_bounding_box().
- Returns:
Cropped array
- Return type:
np.ndarray()
- get_disordered_trace()[source]#
Create a skeleton for each of the grains in the image.
Uses my own skeletonisation function from tracingfuncs module. I will eventually get round to editing this function to try to reduce the branching and to try to better trace from looped molecules
- linear_or_circular(traces)[source]#
Determines whether each molecule is circular or linear based on the local environment of each pixel from the trace
This function is sensitive to branches from the skeleton so might need to implement a function to remove them
- get_fitted_traces()[source]#
Create trace coordinates (for each identified molecule) that are adjusted to lie along the highest points of each traced molecule
- get_splined_traces()[source]#
Gets a splined version of the fitted trace - useful for finding the radius of gyration etc
This function actually calculates the average of several splines which is important for getting a good fit on the lower res data
- saveTraceFigures(filename: str | pathlib.Path, channel_name: str, vmaxval, vminval, output_dir: str | pathlib.Path = None)[source]#
- plotCurvature(dna_num)[source]#
Plot the curvature of the chosen molecule as a function of the contour length (in metres)
- class topostats.tracing.dnatracing.traceStats(trace_object: dnaTrace, image_path: str | pathlib.Path)[source]#
Combine and save trace statistics.
- trace_object#
- image_path#
- df = []#
- create_trace_stats()[source]#
Creates a pandas dataframe of the contour length, whether its circular and end to end distance combined with details of the working directory, directory images were found in and the image name.
- save_trace_stats(save_path: str | pathlib.Path, json: bool = True, csv: bool = True) None [source]#
Write trace statistics to JSON and/or CSV.
- Parameters:
save_path (Union[str, Path]) – Directory to save results to.
json (bool) – Whether to save a JSON version of statistics.
csv (bool) – Whether to save a CSV version of statistics.