You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#999 introduced the mean width of DNA to the output statistics (thanks @tcatley 👍 )
There are a couple of improvements that can be made...
Flexible average
Correctly handle odd-width masks
Flexible average
Currently the mean() of the width across the whole molecule is returned. It would be simple to add an option average: str with options mean and median and allow the calculation of either the mean or median width (or by extension other measures of centrality). The option should be specified in topostats/default_config.yaml under disordered_tracing
topostats/default_config.yaml
disordered_tracing:
...width_average: mean # Measure of central tendency across molecule width. Options : mean | median
docs/configuration.md
| `disordered_tracing` | `width_average` | str | `mean` | Method of central tendency across molecule width. Options: `mean`, `median`. |
topostats/tracing/disordered_tracing.py
NB The following is untested and just a suggestion
@staticmethoddefcalculate_dna_width(
smoothed_mask: npt.NDArray,
pruned_skeleton: npt.NDArray,
px2nm: float=1,
width_average: str="mean",
) ->float:
""" Calculate the mean width in metres of the DNA using the trace and mask. Parameters ---------- smoothed_mask : npt.NDArray Smoothed mask to be measured. pruned_skeleton : npt.NDArray Pruned skeleton. px2nm : float Scaling of pixels to nanometres. width_average : str Measure of central tendency. Options are ``mean`` and ``median``. Returns ------- float Width of grain in metres. """dist_trans=distance_transform_edt(smoothed_mask)
comb=np.where(pruned_skeleton==1, dist_trans, 0)
width_average= {
"mean": np.mean,
"median": np.median,
}
returnwidth_average(comb[comb!=0]) *2*px2nm
Tests will need updating in light of changes.
Correctly handle odd-width masks
As noted in this comment the width of any region where the mask is an odd number of pixels will be over-estimated because the comb is multiplied by 2. This systematically inflates the estimate of the width across the length of the molecule.
Ideally we should get a more accurate measurement of the width that correctly handles such regions.
The text was updated successfully, but these errors were encountered:
#999 introduced the mean width of DNA to the output statistics (thanks @tcatley 👍 )
There are a couple of improvements that can be made...
Flexible average
Currently the
mean()
of the width across the whole molecule is returned. It would be simple to add an optionaverage: str
with optionsmean
andmedian
and allow the calculation of either the mean or median width (or by extension other measures of centrality). The option should be specified intopostats/default_config.yaml
underdisordered_tracing
topostats/default_config.yaml
docs/configuration.md
topostats/tracing/disordered_tracing.py
NB The following is untested and just a suggestion
Tests will need updating in light of changes.
Correctly handle odd-width masks
As noted in this comment the width of any region where the mask is an odd number of pixels will be over-estimated because the
comb
is multiplied by 2. This systematically inflates the estimate of the width across the length of the molecule.Ideally we should get a more accurate measurement of the width that correctly handles such regions.
The text was updated successfully, but these errors were encountered: