Bin2cell

Project home page here, demonstration notebook here.

Main workflow functions

bin2cell.scaled_he_image(adata[, mpp, crop, ...])

Create a custom microns per pixel render of the full scale H&E image for visualisation and downstream application.

bin2cell.scaled_if_image(adata, channel[, ...])

Create a custom microns per pixel render of the full scale IF image for visualisation and downstream application.

bin2cell.destripe(adata[, quantile, ...])

Correct the raw counts of the input object for known variable width of VisiumHD 2um bins.

bin2cell.grid_image(adata, val[, log1p, ...])

Create an image of a specified val across the array coordinate grid.

bin2cell.stardist(image_path, labels_npz_path)

Segment an image with StarDist.

bin2cell.insert_labels(adata, labels_npz_path)

Load StarDist segmentation results and store them in the object.

bin2cell.expand_labels(adata[, labels_key, ...])

Expand StarDist segmentation results to bins a maximum distance away in the array coordinates.

bin2cell.salvage_secondary_labels(adata[, ...])

Create a joint labels_key that takes the primary_label and fills in unassigned bins based on calls from secondary_label.

bin2cell.bin_to_cell(adata[, labels_key, ...])

Collapse all bins for a given nonzero labels_key into a single cell.

Utility functions

bin2cell.get_crop(adata[, basis, ...])

Get a PIL-formatted crop tuple from a provided object and coordinate representation.

bin2cell.view_labels(image_path, labels_npz_path)

Render segmentation results in a lightweight manner on a full image level.

bin2cell.view_cell_labels(image_path, ...[, ...])

Colour morphology segmentations by cell-level metadata or gene expression.

bin2cell.load_image(image_path[, gray, dtype])

Efficiently load an external image and return it as an RGB numpy array.

bin2cell.check_array_coordinates(adata[, ...])

Assess the relationship between .obs["array_row"]/.obs["array_col"] and .obsm["spatial"], as the array coordinates tend to have their origin in places that isn't the top left of the image.

bin2cell.actual_vs_inferred_image_shape(...)

Compare the shape of the actual morphology image versus what the shape of the morphology image that was used for Spaceranger appears to be from information stored for the hires.

bin2cell.mpp_to_scalef(adata, mpp)

Compute a scale factor for a specified mpp value.

bin2cell.get_mpp_coords(adata[, basis, ...])

Get an mpp-adjusted representation of spatial or array coordinates of the provided object.

bin2cell.overlay_onto_img(img, ...[, ...])

Helper function used by b2c.view_cell_labels() to actually overlay the metadata/expression onto the morphology image

bin2cell.destripe_counts(adata[, ...])

Scale each row (bin) of adata.X to have adjusted_counts_key rather than counts_key total counts.

Obsoleted functions

bin2cell.view_stardist_labels(image_path, ...)

Use StarDist's label rendering to view segmentation results in a crop of the input image.

bin2cell.check_bin_image_overlap(adata, img)

Assess the number of bins that fall within the source image coordinate space.