API Reference
Setting Parameters
To set parameters, use a DecodeParams object
SeqFISHSyndromeDecoding.DecodeParams
— TypeDecodeParams()
Constructor for DecodeParams object that sets default values for every parameter. Cost function parameters must be set by the user. If they are not, the decoding functions will throw an error.
Required parameters
Users are required to set the some parameters for decoding using the following methods:
SeqFISHSyndromeDecoding.set_xy_search_radius
— Functionset_xy_search_radius(prms :: DecodeParams, r :: Real)
Arguments
prms
: DecodeParams Objectr
: The lateral KDTree Search radius in pixels for aligned dots in previous barcoding blocks.
SeqFISHSyndromeDecoding.set_z_search_radius
— Functionset_z_search_radius(prms :: DecodeParams, r :: Real)
Arguments
prms
: DecodeParams Objectr
: The z KDTree Search radius in slices for aligned dots in previous barcoding blocks.
SeqFISHSyndromeDecoding.set_n_allowed_drops
— Functionset_n_allowed_drops(prms :: DecodeParams, d :: Integer)
Arguments
prms
: DecodeParams Objectr
: The number of allowed drops in a barcode. Only 0 and 1 are currently supported. The parity check matrix must have redundancy to support correcting for one drop, otherwise errors will occur.
SeqFISHSyndromeDecoding.set_lat_var_cost_coeff
— Functionset_lat_var_cost_coeff(prms :: DecodeParams, lvf :: Real)
Arguments
prms
: DecodeParams Objectlvf
: The lateral variance penalty coefficient in the cost function.
SeqFISHSyndromeDecoding.set_z_var_cost_coeff
— Functionset_z_var_cost_coeff(prms :: DecodeParams, zvf :: Real)
Arguments
prms
: DecodeParams Objectr
: The z variance penalty coefficient in the cost function.
SeqFISHSyndromeDecoding.set_lw_var_cost_coeff
— Functionset_lw_var_cost_coeff(prms :: DecodeParams, lwvf :: Real)
Arguments
prms
: DecodeParams Objectlwvf
: The log weight variance penalty coefficient in the cost function.
SeqFISHSyndromeDecoding.set_s_var_cost_coeff
— Functionset_s_var_cost_coeff(prms :: DecodeParams, sf :: Real)
Arguments
prms
: DecodeParams Objectsvf
: The σ variance penalty coefficient in the cost function.
Parameters with default values
The rest of the parameters are given a default value by the DecodeParams
Constructor, but may be set using the following methods:
SeqFISHSyndromeDecoding.set_zeros_probed
— Functionset_zeros_probed(prms :: DecodeParams, zp :: Bool)
Arguments
prms
: DecodeParams Objectzp
: Whether or not zeros in codewords are probed in the experiment. Drops are not supported when false.
SeqFISHSyndromeDecoding.set_erasure_penalty
— Functionset_erasure_penalty(prms :: DecodeParams, ep :: Real)
The penalty that each dot dropped from a barcode adds to the cost function of the corrected barcode is ep. For example a barcode with one drop adds 1*ep to the cost of the barcode.
Arguments
prms
: DecodeParams Objectep
: penalty for decoding a barcode with a dropped dot
SeqFISHSyndromeDecoding.set_free_dot_cost
— Functionset_free_dot_cost(prms :: DecodeParams, fdc :: Real)
Arguments
prms
: DecodeParams Objectfdc
: The cost of not decoding a dot in the barcode candidate network
SeqFISHSyndromeDecoding.set_skip_thresh
— Functionset_skip_thresh(prms :: DecodeParams, st :: Integer)
Arguments
prms
: DecodeParams Objectst
: conflicting networks of barcode candidates containing more barcode candidates than this threshold will be discarded.
SeqFISHSyndromeDecoding.set_skip_density_thresh
— Functionset_skip_density_thresh(prms :: DecodeParams, sdt :: Real)
Arguments:
prms
: DecodeParams Objectsdt
: conflicting networks of barcode candidates that have a higher ratio of candidate barcodes to area of their bounding box in pixels than this threshold will be discarded.
Running Decoding
SeqFISHSyndromeDecoding.get_codepaths
— Functionget_codepaths(pnts :: DataFrame, cb_df :: DataFrame, H :: Matrix, params :: DecodeParams)
Arguments
pnts
: DataFrame of seqFISH psfs. Must include columns:x
: x spatial coordinate of psfsy
: y spatial coordinate of psfsz
: z spatial coordinate of psfss
: the sigma width parameter of the psfsw
: the weight (or brightness) of the psfs
Additionally, there the data frame must either have columns
block
: the barcoding block in which the psf was foundpseudocolor
: the pseudocolor of the barcoding block in which the psf was found
or the block and pseudocolor can be computed from the hybridization
hyb
: the hybridization in which the dot was found
where block = ceil(hyb / q), pseudocolor = (hyb - (block - 1) * q) % q, and q is the number of pseudocolors.
cb
: The codebook.H
: The parity check Matrixparams
: DecodeParams object holding the parameters for decoding
Computes codepaths with syndrome decoding, removes codepaths that exceed the cost of not decoding their component dots, and and returns DataFrame of candidate codepaths.
get_codepaths(pnts :: DataFrame, cb :: Matrix, H :: Matrix, params :: DecodeParams)
Computes codepaths with syndrome decoding, removes codepaths that exceed the cost of not decoding their component dots, and returns DataFrame of candidate codepaths.
Arguments
pnts
: DataFrame of seqFISH psfs. Must include columns:x
: x spatial coordinate of psfsy
: y spatial coordinate of psfsz
: z spatial coordinate of psfss
: the sigma width parameter of the psfsw
: the weight (or brightness) of the psfs
cb
: The codebook.H
: The parity check Matrixparams
: DecodeParams object holding the parameters for decoding
SeqFISHSyndromeDecoding.choose_optimal_codepaths
— Functionchoose_optimal_codepaths(pnts :: DataFrame, cb_df :: DataFrame, H :: Matrix, params :: DecodeParams, cpath_df :: DataFrame, optimzer, ret_discarded :: Bool=false)
Arguments
pnts
: DataFrame of seqFISH psfs. Must include columns:x
: x spatial coordinate of psfsy
: y spatial coordinate of psfsz
: z spatial coordinate of psfss
: the sigma width parameter of the psfsw
: the weight (or brightness) of the psfs
block
: the barcoding block in which the psf was foundpseudocolor
: the pseudocolor of the barcoding block in which the psf was found
hyb
: the hybridization in which the dot was found
cb
: The codebook.H
: The parity check Matrixparams
: DecodeParams object holding the parameters for decodingcpath_df
: A DataFrame output from theget_codepaths
function, defined above.optimizer
: solver for integer linear programming optimizations. A list of supported solvers is available hereret_discarded
: if true, return data frame of candidate codepaths that were discarded for being in too large/too dense of a conflict network
Returns
- DataFrame of decoded barcodes
- If
ret_discarded
== True, returns second DataFrame of the codepaths discarded to density filters
Choose best codepaths from previouly found candidates that may have been found with less strict parameters. Reevaluates the costs for each candidate and trims according to the passed parameters.
SeqFISHSyndromeDecoding.decode_syndromes!
— Functiondecode_syndromes!(
pnts :: DataFrame,
cb,
H :: Matrix,
params :: DecodeParams
optimizer = GLPK.Optimizer
)
Arguments
pnts
: DataFrame of seqFISH psfs. Must include columns:x
: x spatial coordinate of psfsy
: y spatial coordinate of psfsz
: z spatial coordinate of psfss
: the sigma width parameter of the psfsw
: the weight (or brightness) of the psfs
Additionally, there the data frame must either have columns
block
: the barcoding block in which the psf was foundpseudocolor
: the pseudocolor of the barcoding block in which the psf was found
or the block and pseudocolor can be computed from the hybridization
hyb
: the hybridization in which the dot was found
where block = ceil(hyb / q), pseudocolor = (hyb - (block - 1) * q) % q, and q is the number of pseudocolors.
cb
: The codebook.H
: The parity check Matrixparams
: DecodeParams object holding the parameters for decodingoptimizer
: solver for integer linear programming optimizations. Uses the open source GLPK optimizer by default, but allows faster commercial optimizers to be used if necessary.
A list of supported solvers is available here
Takes a DataFrame of aligned points with hyb, x, y, z, w, and s columns; codebook matix; parity check matrix (H); and DecodeParams stucture with decoding parameters set. Adds columns to input pnts matrix indicating the encoding block, syndrome component value, and decoding result indicated as the row of the codebook matrix matched to. Split up points into weakly connected components, then finds possible codeword messages and runs simulated annealing to assign them. The pnts dataframe should have hybridization, x, y, and z columns