starcall.sequencing
index
/home/nicho/starcall-docs/starcall/sequencing.py

 
Modules
       
dataclasses
math
numpy
matplotlib.pyplot
skimage
sklearn
time
starcall.utils

 
Classes
       
builtins.object
BarcodeLibrary
NearestNeighbors
TreeNode

 
class BarcodeLibrary(builtins.object)
    BarcodeLibrary(barcodes, distance_function=None, batch_size=50)
 
Class that efficiently matches reads to a set of barcodes.
Uses nearest neighbors to avoid comparing every read, barcode pair.
It can also accept barcode libraries with multiple barcodes, in which case
a set of reads is matched to a set of barcodes if all barcodes are present in
said set of reads.
 
  Methods defined here:
__init__(self, barcodes, distance_function=None, batch_size=50)
Constructs a barcode library
 
barcodes: a sequence of strings of characters 'GTAC'. Can be a sequence of sets of
    strings if there are multiple barcodes per entry.
nearest(self, reads, counts=None, match_threshold=2, second_threshold=None)
Find the best matching barcode for each read.
 
reads: Same as constructing the library, this can be a sequence of strings
    or an 2d array with multiple reads per entry.
counts: If multiple reads are specified per entry, the counts of each can
    be specified here. This should be the same shape as reads.
permutations(self, max_val, num)

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class NearestNeighbors(builtins.object)
    NearestNeighbors(n_neighbors=5, metric='euclidean')
 

 
  Methods defined here:
__init__(self, n_neighbors=5, metric='euclidean')
Initialize self.  See help(type(self)) for accurate signature.
closest(read)
fit(self, X, y=None)

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class TreeNode(builtins.object)
    TreeNode(points, indices)
 

 
  Methods defined here:
__init__(self, points, indices)
Initialize self.  See help(type(self)) for accurate signature.

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
Functions
       
barcodes_to_vector(barcodes)
Helper function to turn an array of strings into
a array of uint8 with an extra dimension of the characters
of the string
calc_barcode_distances(reads, library, counts=None, max_edit_distance=None, read_mask=None, dtype=<class 'numpy.float32'>, reads_needed=None)
Calculates a full distance matrix between reads and a barcode library.
 
reads: array of barcode sequences, or 2d array if multiple reads are specified
    per entry
library: same as reads, array or 2d array of barcode sequences
counts (optional): Integer array same shape as reads, can be used to specify
    counts of each read.
call_reads(cells, poses, values, num_reads=8, distance_threshold=None, quality_threshold=None)
Function to collect detected reads into cells
 
cells: int array of shape (W, H)
    A segmentation mask of cells, 0 is the background and all values N>0 correspond
    to the mask of cell N.
poses: int array of shape (N, 2)
    The positions of the reads found.
values: float array of shape (N, cycle, channel)
    The values of the reads across all cycles and channels.
cluster_reads(values, distance_threshold=None)
Clusters the values of many reads to determine which reads
are likely to belong to the same sequence, despite errors
that may have altered their sequence.
edit_distance(barcode1, barcode2, out=None)
Calculates edit distance of packed barcodes. Limit specifies a limit for the distance,
if for example you only care about distances lower than 2 this will limit the computation.
euclidean_distance(poses1, poses2)
filter_reads(values, quality_threshold=None)
Filters out reads that are clearly not true reads.
make_edit_distance_table()
match_barcodes(reads, counts, library, max_edit_distance=0, return_distances=False, debug=True, progress=False)
Matches each set of reads given with a library barcode or set of barcodes.
If max_edit_distance is nonzero, it will also try to match barcodes that differ
in less that or equal to that many bases.
match_barcodes_bad(reads, counts, library, max_edit_distance=0, debug=True, progress=False)
Matches each set of reads given with a library barcode or set of barcodes.
If max_edit_distance is nonzero, it will also try to match barcodes that differ
in less that or equal to that many bases.
match_barcodes_nn(reads, counts, library, max_edit_distance=0)
pack_barcodes(barcodes, dtype=None, out=None)
Helper function that converts strings of 'GTAC' into packed integers or byte strings.
Because there are only 4 possibilities for each character, we can use two bits to represent
them and allow for much faster comparisons and edit distance computation.
dtype can be an unsigned integer type or bytes, if it is None it will default to uint64 unless
the barcodes are longer than 32 characters
unpack_barcodes(barcodes, length=None, out=None)
Reverse function to utils.pack_barcodes that converts the packed integer values back to sequences.
Importantly, this function will not give the exact same sequence given into pack_barcodes. The
length of the barcode is not stored, so if not specified it will decode as many bases as the underlying
dtype can hold.

 
Data
        plot_counter = 0