cima.patches package

Submodules

cima.patches.homolog_separator module

class cima.patches.homolog_separator.HomologSeparator

Bases: object

fit(seg: Segment, randseed: int = 0, algorithm: str = 'kmeans', dbscan_config: dict = {'eps': 250, 'min_samples': 1})

Separates a segment into two different homologs using KMeans algorithm

Parameters:
  • seg (Segment) – Segment to separate

  • randseed (int, optional) – Random seed to use when applying the separation algorithm. Defaults to 0.

  • algorithm (str, optional) – Algorithm to use for separation (‘kmeans’, ‘linkage’, ‘dbscan’). Defaults to ‘kmeans’.

  • dbscan_config (dict, optional) – Configuration for DBSCAN algorithm. Defaults to {‘min_samples’: 1, ‘eps’: 250}.

Return type:

None

labels_

No inference is made on the paternal/maternal nature of them.

Type:

np array of same length as seg indicating with 0 and 1 the two homologs.

seg1, seg2

The two segments representing the separated homologs

Type:

Segment

cima.patches.nuclear_mask module

cima.patches.segment_reconstruction module

class cima.patches.segment_reconstruction.Decoder

Bases: object

Decodes a hierarchical barcoding experiment by following the provided patching scheme. To obtain the decoded segment (with loci ids in the clusterID column) first create a Decoder object (decoder = Decoder()), then call fit() with the appropriate parameters and finally get the segment from the object’s loci_segment attribute.

fit(phase1_segments: list[SegmentXYZ], phase2_segments: list[SegmentXYZ], walk_loci_matrix: ndarray, comparison_measure: str = 'overlap_iofirst', n_jobs: int = 4, verbose: bool = True)
Parameters:
  • full_segment (Segment) – Segment obtained from the localizations file of a walk

  • phase1_tpoints (list of Segment) – The timepoints of the phase1

  • phase2_tpoints (list of Segment) – The timepoints of the phase2

  • walk_loci_matrix (numpy array of shape (len(phase1_tpoints), len(phase2_tpoints)) of type 'int') – Defines at the intersection of which phase1 and phase2 timepoints each genomic locus lies. Values inside the matrix are considered as loci ids. Values 0 indicate absence of loci at that intersection.

  • comparison_measure (function, optional) – Function accepting two maps and returning a float. The measure to use to compare maps (default is ‘overlap_iofirst’)

\* loci_segment
Type:

the decoded segment

\* comparison_mats
Type:

matrices representing comparisons between cluster maps and macropatches maps

\* localizations_classification
Type:

DataFrame representing the estimated probability of a localization to come from each of the loci, or neither of them

getEfficacy()

Returns the efficacy (float) of the decoding

load(loci_segment, walk_loci_matrix, localizations_classification)

Fill the Decoder with precomputed data. This is useful for diplaying decoding results for a decoding performed in the past.

plotEfficacyTable()

Plot the efficacy table coloring the found loci according to their relative position on the chromosome

plotEfficacyTableWithUncertainty()

Plot the efficacy table coloring the found loci according to the average uncertainty of the assignment of localizations to the locus.

plotEfficacyTableWithVolume(max_expected_vol=None, verbose=False, precomputed_vols=None)

Plot the efficacy table coloring the found loci according to its volume.