pept.tracking.Cutpoints#
- class pept.tracking.Cutpoints(max_distance, cutoffs=None, append_indices=False)[source]#
Bases:
LineDataFilter
Transform LoRs (a pept.LineData instance) into cutpoints (a pept.PointData instance) for clustering, in parallel.
Under typical usage, the Cutpoints class is initialised with a pept.LineData instance, automatically calculating the cutpoints from the samples of lines. The Cutpoints class inherits from pept.PointData, such that once the cutpoints have been computed, all the methods from the parent class pept.PointData can be used on them (such as visualisation functionality).
For more control over the operations, pept.tracking.peptml.find_cutpoints can be used - it receives a generic numpy array of LoRs (one ‘sample’) and returns a numpy array of cutpoints.
See also
pept.LineData
Encapsulate LoRs for ease of iteration and plotting.
pept.tracking.HDBSCAN
Efficient, parallel HDBSCAN-based clustering of (cut)points.
pept.read_csv
Fast CSV file reading into numpy arrays.
Examples
Compute the cutpoints for a LineData instance between lines that are less than 0.1 apart:
>>> line_data = pept.LineData(example_data) >>> cutpts = peptml.Cutpoints(0.1).fit(line_data)
Compute the cutpoints for a single sample:
>>> sample = line_data[0] >>> cutpts_sample = peptml.Cutpoints(0.1).fit_sample(sample)
- Attributes
- max_distance
float
The maximum distance between any two lines for their cutpoint to be considered. A good starting value would be 0.1 mm for small tracers and/or clean data, or 0.2 mm for larger tracers and/or noisy data.
- cutoffslist-like
of
length
6 A list (or equivalent) of the cutoff distances for every axis, formatted as [x_min, x_max, y_min, y_max, z_min, z_max]. Only the cutpoints which fall within these cutoff distances are considered. The default is None, in which case they are automatically computed using pept.tracking.peptml.get_cutoffs.
- max_distance
- __init__(max_distance, cutoffs=None, append_indices=False)[source]#
Cutpoints class constructor.
- Parameters
- max_distance
float
The maximum distance between any two lines for their cutpoint to be considered. A good starting value would be 0.1 mm for small tracers and/or clean data, or 0.5 mm for larger tracers and/or noisy data.
- cutoffslist-like
of
length
6, optional A list (or equivalent) of the cutoff distances for every axis, formatted as [x_min, x_max, y_min, y_max, z_min, z_max]. Only the cutpoints which fall within these cutoff distances are considered. The default is None, in which case they are automatically computed using pept.tracking.peptml.get_cutoffs.
- append_indicesbool,
default
False
If set to True, the indices of the individual LoRs that were used to compute each cutpoint are also appended to the returned array.
- max_distance
- Raises
ValueError
If cutoffs is not a one-dimensional array with values formatted as [min_x, max_x, min_y, max_y, min_z, max_z].
Methods
__init__
(max_distance[, cutoffs, append_indices])Cutpoints class constructor.
copy
([deep])Create a deep copy of an instance of this class, including all inner attributes.
fit
(line_data[, executor, max_workers, verbose])Apply self.fit_sample (implemented by subclasses) according to the execution policy.
fit_sample
(sample_lines)load
(filepath)Load a saved / pickled PEPTObject object from filepath.
save
(filepath)Save a PEPTObject instance as a binary pickle object.
Attributes
- copy(deep=True)#
Create a deep copy of an instance of this class, including all inner attributes.
- fit(line_data, executor='joblib', max_workers=None, verbose=True)#
Apply self.fit_sample (implemented by subclasses) according to the execution policy. Simply return a list of processed samples. If you need a reduction step (e.g. stack all processed samples), apply it in the subclass.
- static load(filepath)#
Load a saved / pickled PEPTObject object from filepath.
Most often the full object state was saved using the .save method.
- Parameters
- filepath
filename
orfile
handle
If filepath is a path (rather than file handle), it is relative to where python is called.
- filepath
- Returns
pept.PEPTObject
subclass
instance
The loaded object.
Examples
Save a LineData instance, then load it back:
>>> lines = pept.LineData([[1, 2, 3, 4, 5, 6, 7]]) >>> lines.save("lines.pickle")
>>> lines_reloaded = pept.LineData.load("lines.pickle")
- property max_distance#
- save(filepath)#
Save a PEPTObject instance as a binary pickle object.
Saves the full object state, including inner attributes, in a portable binary format. Load back the object using the load method.
- Parameters
- filepath
filename
orfile
handle
If filepath is a path (rather than file handle), it is relative to where python is called.
- filepath
Examples
Save a LineData instance, then load it back:
>>> lines = pept.LineData([[1, 2, 3, 4, 5, 6, 7]]) >>> lines.save("lines.pickle")
>>> lines_reloaded = pept.LineData.load("lines.pickle")
- property cutoffs#
- property append_indices#