iss_preprocess.diagnostics package

Submodules

iss_preprocess.diagnostics.diag_ara module

iss_preprocess.diagnostics.diag_ara.plot_ara_registration(data_path, roi, reference_prefix='genes_round_1_1')

Overlay reference image to ARA borders

Parameters:
  • data_path (str) – Relative path to data

  • roi (int) – ROI number to plot

  • reference_prefix (str, optional) – Image to use as reference. Defaults to “genes_round_1_1”.

Raises:

ImportError – If cricksaw_analysis is not installed

Returns:

Reference to the figure created.

Return type:

plt.Figure

iss_preprocess.diagnostics.diag_hybridisation module

iss_preprocess.diagnostics.diag_hybridisation.check_hybridisation_setup(data_path, prefixes)

Plot the hybridisation spot clusters scatter plots and bleedthrough matrices

Parameters:
  • data_path (str) – Relative path to data folder

  • prefixes (list) – Prefix of the acquisition to check

iss_preprocess.diagnostics.diag_hybridisation module

iss_preprocess.diagnostics.diag_hybridisation.check_hybridisation_setup(data_path, prefixes)

Plot the hybridisation spot clusters scatter plots and bleedthrough matrices

Parameters:
  • data_path (str) – Relative path to data folder

  • prefixes (list) – Prefix of the acquisition to check

iss_preprocess.diagnostics.diag_reg2ref module

iss_preprocess.diagnostics.diag_reg2ref.check_reg_to_ref_correction(data_path, prefix, rois=None, roi_dimension_prefix=None, *, use_slurm=False, dependency_type=None, job_dependency=None, slurm_folder=None, scripts_name=None, slurm_options=None, batch_param_names=None, batch_param_list=None)

Plot estimation of shifts/angle for registration to ref

Compare raw measures to ransac

Parameters:
  • data_path (str) – Relative path to data

  • prefix (str) – Acquisition prefix, “barcode_round” for instance.

  • rois (list) – List of ROIs to process. If None, will either use ops[“use_rois”] if it is defined, or all ROIs otherwise. Defaults to None

  • roi_dimension_prefix (str, optional) – prefix to load roi dimension. Defaults to None

iss_preprocess.diagnostics.diag_reg2ref.check_registration_to_reference(data_path, prefix, ref_prefix, tile_coords=None, *, use_slurm=False, dependency_type=None, job_dependency=None, slurm_folder=None, scripts_name=None, slurm_options=None, batch_param_names=None, batch_param_list=None)
iss_preprocess.diagnostics.diag_reg2ref.check_rolonies_registration(savefname, data_path, tile_coors, n_rolonies, prefix='genes_round', channel_colors=([1, 0, 0], [0, 1, 0], [1, 0, 1], [0, 1, 1]), vmax=0.5, correct_illumination=True, corrected_shifts='best')

Check the registration of rolonies

Will plot a random selection of rolonies overlaid on the spot sign image circles.

Parameters:
  • savefname (str) – Path to save the figure to

  • data_path (str) – Path to the data folder

  • tile_coors (tuple) – Tile coordinates

  • n_rolonies (int) – Number of rolonies to plot

  • prefix (str, optional) – Prefix to use. Defaults to “genes_round”.

  • channel_colors (list, optional) – List of colors for each channel. Defaults to ([1,0,0],[0,1,0],[1,0,1],[0,1,1]).

  • vmax (float, optional) – Max value image scale. Defaults to 0.5.

  • correct_illumination (bool, optional) – Whether to correct for illumination. Defaults to True.

  • corrected_shifts (str, optional) – Which shifts to use. One of best, ransac, single_tile, reference, Defaults to ‘best’.

iss_preprocess.diagnostics.diag_reg2ref.check_tile_reg2ref(data_path, reg_prefix='barcode_round', ref_prefix='genes_round', correction='best', tile_coords=None, reg_channels=None, ref_channels=None, binarise_quantile=0.7, window=None, *, use_slurm=False, dependency_type=None, job_dependency=None, slurm_folder=None, scripts_name=None, slurm_options=None, batch_param_names=None, batch_param_list=None)

Check the registration to reference for some tiles

If tile_coords is None, will select 10 tiles. If ops has a xx_ref_tiles matching prefix, these will be part of the 10 tiles. The remaining tiles will be selected randomly.

Parameters:
  • data_path (str) – Relative path to data folder

  • prefix (str, optional) – Prefix of the images to load. Defaults to “genes_round”.

  • correction (str, optional) – Corrections to plot. Defaults to ‘best’.

  • tile_coords (list, optional) – List of tile coordinates to process. If None, will select 10 tiles. Defaults to None.

  • reg_channels (list, optional) – List of channels to plot for the registered images. If None, will use the average of all channels. Defaults to None.

  • ref_channels (list, optional) – List of channels to plot for the reference images. If None, will use the average of all channels. Defaults to None.

  • binarise_quantile (float, optional) – Quantile to binarise the images. Defaults to 0.7.

  • window (int, optional) – Size of the window to plot around the center of the image. Full image if None. Defaults to None.

iss_preprocess.diagnostics.diag_reg2ref.debug_reg_to_ref(data_path, reg_prefix, ref_prefix, tile_coords=None, ref_channels=None, reg_channels=None, binarise_quantile=0.7)

Diagnostic functions helping to debug registration to reference

This redo the steps of register_to_reference to plot intermediate figures

iss_preprocess.diagnostics.diag_register module

iss_preprocess.diagnostics.diag_register.check_affine_channel_registration(data_path, prefix='genes_round', tile_coords=None, projection=None, binarise_quantile='ops', block_size='ops', overlap='ops', max_residual='ops', ref_ch='ops', correct_illumination='ops')
iss_preprocess.diagnostics.diag_register.check_ref_tile_registration(data_path, prefix='genes_round', *, use_slurm=False, dependency_type=None, job_dependency=None, slurm_folder=None, scripts_name=None, slurm_options=None, batch_param_names=None, batch_param_list=None)

Plot the reference tile registration and save it in the figures folder

Parameters:
  • data_path (str) – Relative path to data folder

  • prefix (str, optional) – Prefix of the images to load. Defaults to “genes_round”.

iss_preprocess.diagnostics.diag_register.check_sequencing_tile_registration(data_path, tile_coords, prefix='genes_round')

Plot the a mp4 of registered tile and save it in the figures folder

This will load the data after ransac correction

Parameters:
  • data_path (str) – Relative path to data folder

  • prefix (str, optional) – Prefix of the images to load. Defaults to “genes_round”.

iss_preprocess.diagnostics.diag_register.check_shift_correction(data_path, prefix='genes_round', roi_dimension_prefix=None, within=True, between=True, *, use_slurm=False, dependency_type=None, job_dependency=None, slurm_folder=None, scripts_name=None, slurm_options=None, batch_param_names=None, batch_param_list=None)

Plot the shift correction and save it in the figures folder

Compare the ransac output to the tile-by-tile shifts and plot matrix of differences

Parameters:
  • data_path (str) – Relative path to data folder

  • prefix (str, optional) – Prefix of the images to load. Defaults to “genes_round”.

  • roi_dimension_prefix (str, optional) – Prefix of the roi dimensions. Defaults to None.

  • within (bool, optional) – Plot within channel shifts. Defaults to True.

  • between (bool, optional) – Plot between channel shifts. Defaults to True.

iss_preprocess.diagnostics.diag_register.check_tile_registration(data_path, prefix='genes_round', corrections='best', tile_coords=None, *, use_slurm=False, dependency_type=None, job_dependency=None, slurm_folder=None, scripts_name=None, slurm_options=None, batch_param_names=None, batch_param_list=None)

Check the registration of sequencing data for some tiles

If tile_coords is None, will select 10 tiles. If ops has a xx_ref_tiles matching prefix, these will be part of the 10 tiles. The remaining tiles will be selected randomly.

Parameters:
  • data_path (str) – Relative path to data folder

  • prefix (str, optional) – Prefix of the images to load. Defaults to “genes_round”.

  • corrections (tuple, optional) – Corrections to plot. Defaults to (‘best’).

  • tile_coords (list, optional) – List of tile coordinates to process. If None, will select 10 tiles. Defaults to None.

iss_preprocess.diagnostics.diag_register.check_tile_shifts(data_path, prefix, rois=None, roi_dimension_prefix=None, *, use_slurm=False, dependency_type=None, job_dependency=None, slurm_folder=None, scripts_name=None, slurm_options=None, batch_param_names=None, batch_param_list=None)

Plot estimation of shifts/angle for registration to ref

Compare raw measures to ransac

Parameters:
  • data_path (str) – Relative path to data

  • prefix (str) – Acquisition prefix, “barcode_round” for instance.

  • rois (list) – List of ROIs to process. If None, will either use ops[“use_rois”] if it is defined, or all ROIs otherwise. Defaults to None

  • roi_dimension_prefix (str, optional) – prefix to load roi dimension. Defaults to None

iss_preprocess.diagnostics.diag_segmentation module

iss_preprocess.diagnostics.diag_segmentation.check_segmentation(data_path, roi, prefix, reference='genes_round_1_1', stitched_stack=None, masks=None, save_fig=True)

Check that segmentation is working properly

Compare masks to the original images

Parameters:
  • data_path (str) – Relative path to data

  • roi (int) – ROI to process

  • prefix (str) – Acquisition prefix, “barcode_round” for instance.

  • reference (str, optional) – Reference prefix. Defaults to “genes_round_1_1”.

  • stitched_stack (np.ndarray, optional) – Stitched stack to use. If None, will stitch and align the images. Defaults to None.

  • masks (np.ndarray, optional) – Masks to use. If None, will load them. Defaults to None.

  • save_fig (bool, optional) – Save the figure. Defaults to True.

Returns:

Figure

Return type:

plt.Figure

iss_preprocess.diagnostics.diag_segmentation.plot_mcherry_gmm(df, features, cluster_centers, initial_centers)
iss_preprocess.diagnostics.diag_segmentation.plot_unmixing_diagnostics(signal_image, background_image, pure_signal, valid_pixel, coef, intercept, vmax=200)

Plot the unmixing diagnostics

Parameters:
  • signal_image (np.ndarray) – Signal image

  • background_image (np.ndarray) – Background image

  • pure_signal (np.ndarray) – Pure signal

  • valid_pixel (np.ndarray) – Valid pixels

  • coef (np.ndarray) – Coefficients

  • intercept (np.ndarray) – Intercept

  • vmax (int, optional) – Maximum cmap value for the images. Defaults to 200.

Returns:

List of figures

Return type:

list

iss_preprocess.diagnostics.diag_sequencing module

iss_preprocess.diagnostics.diag_sequencing.check_barcode_basecall(data_path, tile_coords=None, center=None, window=200, show_scores=True, savefig=True, *, use_slurm=False, dependency_type=None, job_dependency=None, slurm_folder=None, scripts_name=None, slurm_options=None, batch_param_names=None, batch_param_list=None)

Check that the basecall is correct

Plots the basecall for a tile, with the raw data, the basecall, and the scores

Parameters:
  • path (str) – Path to data folder

  • tile_coords (list, optional) – Tile coordinates to use. Defaults to None.

  • center (list, optional) – Center of the tile to use. Defaults to None.

  • window (int, optional) – Half size of the window to show in the figures. Defaults to 200.

  • savefig (bool, optional) – Save the figure. Defaults to True.

Returns:

Figure(s) with the basecall

Return type:

plt.Figure

iss_preprocess.diagnostics.diag_sequencing.check_barcode_calling(data_path, *, use_slurm=False, dependency_type=None, job_dependency=None, slurm_folder=None, scripts_name=None, slurm_options=None, batch_param_names=None, batch_param_list=None)

Plot the barcode cluster scatter plots and cluster means and save them in the figures folder

Parameters:

data_path (str) – Relative path to data folder

iss_preprocess.diagnostics.diag_sequencing.check_omp_alpha_thresholds(data_path, spot_score_thresholds=(0.05, 0.075, 0.1, 0.125, 0.15, 0.2), omp_thresholds=(0.1, 0.125, 0.15, 0.2, 0.25, 0.3), alphas=(10, 50, 100, 200, 300, 400), tile_coors=None, *, use_slurm=False, dependency_type=None, job_dependency=None, slurm_folder=None, scripts_name=None, slurm_options=None, batch_param_names=None, batch_param_list=None)
iss_preprocess.diagnostics.diag_sequencing.check_omp_setup(data_path, *, use_slurm=False, dependency_type=None, job_dependency=None, slurm_folder=None, scripts_name=None, slurm_options=None, batch_param_names=None, batch_param_list=None)

Plot the OMP setup, including clustering of reference gene spots and gene templates, and save them in the figures folder

Parameters:

data_path (str) – Relative path to data folder

iss_preprocess.diagnostics.diag_sequencing.check_omp_thresholds(data_path, spot_score_thresholds=(0.05, 0.075, 0.1, 0.125, 0.15, 0.2), omp_thresholds=(0.1, 0.125, 0.15, 0.2, 0.25, 0.3), rhos=(0.5, 1.0, 2.0, 4.0, 8.0), tile_coors=None, *, use_slurm=False, dependency_type=None, job_dependency=None, slurm_folder=None, scripts_name=None, slurm_options=None, batch_param_names=None, batch_param_list=None)

iss_preprocess.diagnostics.diag_stitching module

iss_preprocess.diagnostics.diag_stitching.check_barcode_mcherry_reg(data_path, roi, barcode_prefix='barcode_round_1_1', mcherry_prefix='mCherry_1', target=None, *, use_slurm=False, dependency_type=None, job_dependency=None, slurm_folder=None, scripts_name=None, slurm_options=None, batch_param_names=None, batch_param_list=None)

Check registration of barcode and mCherry to reference on whole stitched image

Parameters:
  • data_path (str) – Path to data

  • roi (int) – ROI number

  • barcode_prefix (str, optional) – Prefix for barcode. Defaults to “barcode_round_1_1”.

  • mcherry_prefix (str, optional) – Prefix for mCherry. Defaults to “mCherry_1”.

  • target (str, optional) – Path to save the figure to. Defaults to None.

Returns:

Figure instance

Return type:

plt.Figure

iss_preprocess.diagnostics.diag_stitching.combine_overview_plots(data_path, prefix, chamber_list)

Combine all the round overviews into a single figure

Parameters:
  • data_path (str) – path to the data

  • prefix (str) – prefix for the round overview files, e.g. “genes_round”, “barcode_round”, “DAPI”

  • chamber_list (list) – list of chambers to include

iss_preprocess.diagnostics.diag_stitching.plot_overview_images(data_path, prefix, plot_grid=True, downsample_factor=25, save_raw=True, dependency=None, group_channels=True, vmin=None, vmax=None, *, use_slurm=False, dependency_type=None, job_dependency=None, slurm_folder=None, scripts_name=None, slurm_options=None, batch_param_names=None, batch_param_list=None)

Plot individual channel overview images.

Parameters:
  • data_path (str) – Relative path to data

  • prefix (str) – Prefix of acquisition

  • plot_axis (bool, optional) – Whether to plot gridlines at tile boundaries. Defaults to True.

  • downsample_factor (int, optional) – Amount to downsample overview. Defaults to 25

  • save_raw (bool, optional) – Whether to save a tif with no gridlines. Defaults to True.

  • dependency (str, optional) – Dependency for the generates slurm scripts

  • group_channels (bool, optional) – Whether to group channels together. Defaults to True.

  • vmin (list, optional) – vmin for each channel. Default to None

  • vmax (list, optional) – vmax for each channel. Default to None

iss_preprocess.diagnostics.diag_stitching.plot_single_overview(data_path, prefix, roi, ch, nx=None, ny=None, plot_grid=True, downsample_factor=25, save_raw=False, correct_illumination=True, filter_r=False, channel_colors=([1, 0, 0], [0, 1, 0], [1, 0, 1], [0, 1, 1]), vmin=None, vmax=None, *, use_slurm=False, dependency_type=None, job_dependency=None, slurm_folder=None, scripts_name=None, slurm_options=None, batch_param_names=None, batch_param_list=None)

Plot a single channel overview image.

Parameters:
  • data_path (str) – Relative path to data

  • prefix (str) – Prefix of acquisition

  • roi (int) – ROI number

  • ch (int or list) – Channel number

  • nx (int, optional) – Number of tiles in x. If None will read from roi_dimensions

  • ny (int, optional) – Number of tiles in y. If None will read from roi_dimensions

  • plot_axis (bool, optional) – Whether to plot gridlines at tile boundaries. Defaults to True.

  • downsample_factor (int, optional) – Amount to downsample overview. Defaults to 25

  • save_raw (bool, optional) – Whether to save a full size tif with no gridlines. Defaults to False.

  • correct_illumination (bool, optional) – Whether to correct for uneven illumination. Defaults to True.

  • channel_colors (list, optional) – List of colors for each channel. Use only if ch is a list. Defaults to ([1, 0, 0], [0, 1, 0], [1, 0, 1], [0, 1, 1]).

  • vmin (float, optional) – Minimum value for each channel. Defaults to None.

  • vmax (float, optional) – Maximum value for each channel. Defaults to None.

Returns:

Figure object

Return type:

fig