Skip to content
BenEmert edited this page Jan 21, 2021 · 16 revisions

This repository contains a collection of scripts used for image analysis in "Variability within rare cell states enables multiple paths towards drug resistance" (Emert et al. 2020). Briefly, for this manuscript, we developed a methodology termed Rewind, which uses RNA FISH to label transcribed cellular barcodes and thereby identify the rare, primed melanoma cells that give rises to drug resistance. The following will describe our basic approach for finding the rare, primed cells in the barcode RNA FISH imaging data.

For most experiments, we performed barcode RNA FISH using a modified HCR v3.0 protocol (see manuscript for details) then acquired tiled (~10% overlap between FOVs), scan images, in multiple fluorescence channels (DAPI, GFP and the barcode RNA FISH channel), and in a single Z-plane on a Nikon Ti-E running Elements acquisition control software. The acquired data is stored in a single .ND2 file (due to Github file size limits, example output data are available on Dropbox at this link).

autoAdjustScanND2.m

After image acquisition, I run the function autoAdjustScanND2.m to generate contrasted and stitched micrographs that can be manually reviewed rapidly (example output data are available on Dropbox at this link).

Of note, autoAdjustScanND2.m and many other scripts in this repository use bfmatlab software to read .ND2 files into Matlab. This software can be downloaded from the Open Microscopy Consortium here and is also copied in this repository under bfmatlab/. Add this directory to your MATLAB path before running the image analysis scripts described below. Note that you may see a Java warning that says: "log4j:WARN No appenders could be found for logger (loci.formats.ClassList). log4j:WARN Please initialize the log4j system properly."
when first running a bfmatlab function in a new MATLAB session. In my experience, the script should still run properly.

The parameters for autoAdjustScanND2.m are the following:

Required parameters

  • scanSize - Dimension of the scan. Number images in X (across) * number of images in Y (up and down).
  • wavelength - Numeric value indicating which fluorescence channel to process.

Optional parameters

  • inDir - Path to the directory containing the scan ND2 file. Default is working directory.
  • inFile - Option to specify the scan file name. Default is to process all .nd2 files in inDir.
  • outDir - Name of directory to save the contrasted and stitched micrographs.
  • binSize - The size (# of tiles in X and Y) for each output micrograph. Must be a factor of the scanSize. Default is 3x3 or smallest factor of the scanSize.
  • scaleFactor - Parameter for adjusting image contrast. Larger values increase the max intensity (micrographs look darker). See scalePlane.m for further details.

An example command is:

autoAdjustScanND2([40 40], 2, 'inDir', 'exampleData', 'outDir', 'contrasted', 'binSize', [2 2])

This command saves 400 jpegs into contrasted/ with each jpeg containing a contrasted, 2 x 2 stitched micrograph of barcode RNA FISH images like the one shown below. Of note, the stitching simply arranges adjacent tiles side-by-side and does not correct for overlap between fields of view. For more accurate stitching, see stitchScanND2.m.

After running autoAdjustScanND2.m, I manually review the micrographs and record which tiles that contain candidate barcode RNA FISH positive cells. Once I have the list of these tiles, I return to the same positions on the microscope to re-image at high-magnification (60x) and decide whether the fluorescence signal is real or artifact (e.g. auto-fluorescent schmutz).

imageAnalysisGUI

To validate our barcode RNA FISH probesets and protocol, we combined GFP- WM989 A6-G3 cells (~99% of cells) with a GFP+ WM989 A6-G3 subclone carrying a single, known Rewind barcode (~1% of cells), then performed barcode RNA FISH using 4 probes targeting the known barcode along with 120 “off-target” probes (see Supp. Fig. 1 in the manuscript for further details.) We then imaged the entire well with a tiled scan at 20X magnification and identified all barcode FISH+ cells (Alexa647+) followed by all GFP+ cells (true positives) using the scripts contained in imageAnalysisGUI/.

barcodeFISHAccuracy.m.

First, open the script imageAnalysisGUI/barcodeFISHAccuracy.m and edit the first two lines with name of the scan file and the path to the file directory. Next, run the first block to stitch the scan, segment and locate all nuclei, then save to 'S.mat'.

GUI to annotate barcode RNA FISH positive cells

Run the second block to launch the GUI for annotating barcode RNA FISH positive cells. Use the parameter FOV to specify the size (in pixels) of the field of view within the GUI. Use the parameters barcodeFISHChannel and dapiChannel to specify which wavelengths in the scan correspond to the barcode RNA FISH channel and the DAPI channel, respectively. The GUI should look something like this:

Initially, each nucleus should be labeled with a yellow dot. To annotate a barcode RNA FISH positive cell, click the Add button then click on the cell (near its yellow dot). An X mark should appear. You can click on multiple barcode RNA FISH positive cells as shown below.

Click the enter key and the yellows dots for the cells you selected should turn red as shown below. Note that whichever dot is nearest to your selection (and within 10 pixels) will turn red.

If the wrong cell is selected, you can reset all cells in the field of view by clicking on the Clear button. All the dots in the field of view should turn yellow. The dots in other fields of view should be unaffected.

You can move between fields of view by clicking on the Next and Previous buttons. You can also jump to a specific field of view by typing its corresponding number into the box in the top right corner of the GUI.

At any point you can close the GUI and save your annotations to S.mat by clicking on the Done button.

GUI to annotate GFP positive cells

Run the third block to launch the GUI for annotating GFP positive cells. Use the parameter FOV to specify the size (in pixels) of the field of view within the GUI. Use the parameters GFPChannel and dapiChannel to specify which wavelengths in the scan correspond to the GFP channel and the DAPI channel, respectively. The GUI should look something like this:

As in the previous GUI, each nucleus should initially be labeled with a yellow dot. To annotate a GFP positive cell, click the Add button, then click on the cell (near its yellow dot). You can click on multiple GFP positive cells.

Click the enter key and the yellows dots for the cells you selected should turn green. Note that whichever dot is nearest to your selection (and within 10 pixels) will turn green.

Use the same buttons as the GUI to annotate barcode RNA FISH positive cells to reset the cell annotations, move between fields of view, and close the GUI.

An additional feature of the GUI to annotate GFP positive cells, is the option to reveal which cells were annotated as barcode RNA FISH positive (assuming these cells have been annotated with the previous GUI). By clicking on the Reveal button, barcode RNA FISH positive cells will be labeled with a red circle as shown below. Note that we DO NOT recommend using this feature if your aim is to assess the accuracy of identifying barcode RNA FISH positive cells.

Extract cell coordinates and labels.

Run the next two blocks of code to extract the cell coordinates and labels then export the data to a .csv table.

The remaining blocks of code were used to crop, contrast and overlay example micrographs for the manuscript.