nature protocols: doi:10.1038/nprot.2015€¦ · over the connections and heated to protect the...

24
Supplementary Figure 1 Control experiment for Figure 2. Figure 2 shows a typical experiment for strain EY2967/ASH189 in response to six 5-min pulses of 690 nM 1-NM-PP1 separated by 10- min intervals. This figure shows the same plots with the same axes for a control experiment without 1-NM-PP1 treatment. As can be seen, in the absence of 1-NM-PP1 treatment, no gene expression is observed. a) Msn2 translocation dynamics. In this control experiment, no 1-NM-PP1 is added, so no Msn2-mCherry activation is observed. Raw data (black dots) and errorbars (standard deviation) are from 101 single cells and the red line shows a fit to the data. b)-c) Single cell time traces of the YFP (b) and CFP (c) gene expression reporters. Raw, unsmoothed data is shown. As can be seen, in the absence of 1-NM-PP1 treatment, no gene expression is observed. d) By following both CFP and YFP gene expression dynamics in the same single cell, their co-variance can be computed. Each dot in the scatterplot is the max CFP and YFP from the same single cell. Nature Protocols: doi:10.1038/nprot.2015.079

Upload: others

Post on 05-Apr-2020

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Nature Protocols: doi:10.1038/nprot.2015€¦ · over the connections and heated to protect the connections. Next, wait for the soldering iron to become hot enough and cover the wire

Supplementary Figure 1

Control experiment for Figure 2.

Figure 2 shows a typical experiment for strain EY2967/ASH189 in response to six 5-min pulses of 690 nM 1-NM-PP1 separated by 10-min intervals. This figure shows the same plots with the same axes for a control experiment without 1-NM-PP1 treatment. As can be seen, in the absence of 1-NM-PP1 treatment, no gene expression is observed. a) Msn2 translocation dynamics. In this control experiment, no 1-NM-PP1 is added, so no Msn2-mCherry activation is observed. Raw data (black dots) and errorbars (standard deviation) are from 101 single cells and the red line shows a fit to the data. b)-c) Single cell time traces of the YFP (b) and CFP (c) gene expression reporters. Raw, unsmoothed data is shown. As can be seen, in the absence of 1-NM-PP1 treatment, no gene expression is observed. d) By following both CFP and YFP gene expression dynamics in the same single cell, their co-variance can be computed. Each dot in the scatterplot is the max CFP and YFP from the same single cell.

Nature Protocols: doi:10.1038/nprot.2015.079

Page 2: Nature Protocols: doi:10.1038/nprot.2015€¦ · over the connections and heated to protect the connections. Next, wait for the soldering iron to become hot enough and cover the wire

1

SUPPLEMENTARY TUTORIAL 1 Anders S. Hansen, Nan Hao & Erin K. O’Shea

SETTING UP ELECTRONIC BOARD AND ELECTROVALVES

Introduction In this supplementary tutorial, we provide a detailed step-by-step protocol for setting up the

electronic board and how to use it to control the solenoid valves. This protocol requires a small amount of soldering. However, we provide detailed instructions aimed at someone without previous soldering or electronics experience. So the tutorial should be easy to follow and should not take longer than around an hour.

All MATLAB code provided through this tutorial is provided under the GNU General Public License version 3 for free software as a service to the community and you can redistribute and modify it according to the GNU license. We hope that you will find the code useful, but it is distributed without any warranty and without any guarantee that it will work for any particular purpose. For the GNU General Public License please see: http://www.gnu.org/licenses

Items required

The following items are required for this protocol:

o A soldering iron and solder (any will work). o A wire cutter (any will work). o A screwdriver (any appropriately sized one will work). o Heat shrink tubing (any will work – this is recommended but not necessary). o Computer (either PC or Mac) with USB port and MATLAB software (The Mathworks). o Control board (F81 RS-232 8-Channel 1-Amp N-Channel FET Controller Board (item F81)

from National Control Devices, LLC www.controlanything.com). o Quick start kit with power supply, serial cable and RSIO serial interface board (QS12 +12

Volt Quick start kit (item QS12) from National Control Devices, LLC www.controlanything.com).

o Solenoid valves (3-way 12 volts LFYA1228032H Y-valve in perfluoroelastomer, the Lee Company).

o Valve adaptor tubing (Polyethylene tubing (1.57OD x 1.14ID), PE-160/10. Cat 64-0755 from Warner Instruments).

o Serial-to-USB converter (Tripp-lite USA-19HS - Keyspan High-Speed USB to Serial Adapter. Can be purchased from CDW as item 555201. See also http://www.tripplite.com/high-speed-usb-to-serial-adapter-keyspan~USA19HS/ )

Below, we will go through the steps required to set up the board in more detail.

Overview First, make sure that you have everything required for this protocol. From ControlAnything.com,

the items below should be obtained:

Nature Protocols: doi:10.1038/nprot.2015.079

Page 3: Nature Protocols: doi:10.1038/nprot.2015€¦ · over the connections and heated to protect the connections. Next, wait for the soldering iron to become hot enough and cover the wire

2

We strongly recommend using five valves of the LFYA1228032H type (3-way 12 volts LFYA1228032H Y-valve in perfluoroelastomer (FFKM), the Lee Company). However, for purposes of illustration we will show the steps using two valves of a different type in this tutorial. In terms of setting everything up, this makes no difference. The two valves used here are shown below:

Next, screw in one wire for each valve into the board as shown below:

Nature Protocols: doi:10.1038/nprot.2015.079

Page 4: Nature Protocols: doi:10.1038/nprot.2015€¦ · over the connections and heated to protect the connections. Next, wait for the soldering iron to become hot enough and cover the wire

3

The electronic board has room for eight valves in total, but we only need five (or two in this tutorial). Avoid using the first one – this is because the valves are programmed by sending ASCII characters from MATLAB and MATLAB has problems sending ASCII character number 0. So use positions 2-6 (or 2-3 in this case). Each module has two places where the wire can be screwed in. Use number 4 and number 6 as shown above.

Attaching power cable to valve wires

The next step requires connecting the valve wires to the power cable. For this a wire cutter is used. It can be helpful to have additional wire there, but otherwise some of the wire from the power cable can be used instead (this is what we do in this illustration).

Using the wire cutter, cut the power cable as shown below:

Next, either extra wire can be used or a small part of the power cable can be cut off to provide the

extra wire as shown below:

Next, before soldering, make sure that everything is properly connected. Connect the red wire

(positive) to the valve wires as shown below:

Nature Protocols: doi:10.1038/nprot.2015.079

Page 5: Nature Protocols: doi:10.1038/nprot.2015€¦ · over the connections and heated to protect the connections. Next, wait for the soldering iron to become hot enough and cover the wire

4

Tie the wires together as shown above. When tying the red wire together to valve wires, make sure

that all valve wires are in contact with metal from the red wire. Also attach the serial connector part to the main board as shown below:

Remember to fasten the connection using a screwdriver.

Soldering power cable to valve wires Once everything is connected, the next step is to solder. Strictly speaking, soldering is not necessary

as long as everything is properly connected. However, if anything were to come loose the valves would no longer switch so we strongly recommend soldering.

We also recommend using heat shrink tubing to cover soldering subsequently. Heat shrink tubing is very cheap and can be bought at any hardware shop or e.g. on Amazon. Alternatively, tape can be used, but below we illustrate how to use heat shrink tubing. It is crucial to place heat shrink tubing on connections before soldering. Do this as shown below:

Nature Protocols: doi:10.1038/nprot.2015.079

Page 6: Nature Protocols: doi:10.1038/nprot.2015€¦ · over the connections and heated to protect the connections. Next, wait for the soldering iron to become hot enough and cover the wire

5

After the wires have been permanently attached by soldering, the heat shrink tubing will be placed

over the connections and heated to protect the connections. Next, wait for the soldering iron to become hot enough and cover the wire connections in solder as

shown below:

It is a good idea to solder in a room with proper ventilation since the fumes can be toxic. Once the

soldering is completed for all three connections, then move the heat shrink tubing up over the connections. Ideally, a hair drier would be used to heat and shrink the heat shrink tubing. However, if that is not available another option (which is what we do here), is to use the soldering iron to heat the heat shrink tubing. Just be careful not to use the hottest end part of the soldering iron, but instead the less warm parts further down. The process is illustrated below:

Nature Protocols: doi:10.1038/nprot.2015.079

Page 7: Nature Protocols: doi:10.1038/nprot.2015€¦ · over the connections and heated to protect the connections. Next, wait for the soldering iron to become hot enough and cover the wire

6

When finished, the connections should look like this:

Of course, in this illustration we have used just two valves. When all five valves of type

LFYA1228032H are used, the final board connection should look like this:

Nature Protocols: doi:10.1038/nprot.2015.079

Page 8: Nature Protocols: doi:10.1038/nprot.2015€¦ · over the connections and heated to protect the connections. Next, wait for the soldering iron to become hot enough and cover the wire

7

Again, it is important to use connections 2-6 as shown above if controlling valves using MATLAB.

Adding adaptor tubing to valve inlets We use PE tubing (Polyethylene tubing, 0.050” OD/0.034” ID, item BPE-T90 from Instech

Solomon) to connect the flasks containing medium to the valves. However, this type of PE tubing does not fit the valve inlets. So to make the connections we use a different type of PE tubing (Polyethylene tubing (1.57OD x 1.14ID), PE-160/10. Cat 64-0755 from Warner Instruments) as valve adaptor tubing. Cut small pieces of Warner tubing (approximately 10-15 mm in length) and add this to the two inlets, but not the outlets where ismaprene tubing is connected. Then attach the adaptor tubing as shown below for both valve types:

Nature Protocols: doi:10.1038/nprot.2015.079

Page 9: Nature Protocols: doi:10.1038/nprot.2015€¦ · over the connections and heated to protect the connections. Next, wait for the soldering iron to become hot enough and cover the wire

8

Finally, add the ismaprene tubing (this part is also explained in the main protocol). Cut 5 pieces of

ismaprene tubing so that each is around 12 cm in length. Then simply squeeze it over the valve outlet as shown below (left). Next, use a 20G needle and attach PE tubing to the needle. With a pair of scissors, cut off the PE tubing end diagonally and insert this end into the ismaprene tubing as shown below (right)

Repeat this process for all five valves. Once the setup is complete, it is ready for an experiment.

Interfacing valves and board with MATLAB In the remaining section we describe how to interface the valves and board with MATLAB. There is

one important adjustment that must be made to the board before proceeding. We use a serial-to-USB converter, since few computers have serial ports, but all have USB ports. We use the Tripp-lite USA-19HS converter shown below.

For this converter to connect successfully to a computer, the board must be adjusted from “PC” to

“Mac”, no matter what type of computer is used. Thus, even if a PC running Windows is used, the board must still be changed to “Mac” as shown below:

Nature Protocols: doi:10.1038/nprot.2015.079

Page 10: Nature Protocols: doi:10.1038/nprot.2015€¦ · over the connections and heated to protect the connections. Next, wait for the soldering iron to become hot enough and cover the wire

9

To make the change, lift up the black piece of plastic and move it from the PC to the Mac position.

If this step is not completed, it will not be possible to control the valves in MATLAB. Next, make sure that the power cable is plugged in and that the USB cable is connected to the

computer. When the serial cable and power cable are properly attached to the board it will look like this:

Notice that when plugged in, there should be a light in the left-most red light on the board as is also

shown above. Next, open MATLAB. The scripts that will be needed are given together with this document, see

Supplementary Data 2. They are: o Windows_open_valves.m o Mac_open_valves.m o toggleValves.m

Nature Protocols: doi:10.1038/nprot.2015.079

Page 11: Nature Protocols: doi:10.1038/nprot.2015€¦ · over the connections and heated to protect the connections. Next, wait for the soldering iron to become hot enough and cover the wire

10

The Tripp-Lite Serial-to-USB converter comes with a CD containing a driver. We have tested the system on a handful of computers. Often, it works as “plug-and-play”, but it may be necessary to install the USA-19HS driver. Simply follow the instructions that come with the CD on how to install the driver. The driver should be installed before the USB cable is connected to the computer.

When plugging in the USB cable on a Mac, the following message may appear.

Click “cancel”. The valves should work as “plug-and-play” (but if not, then install the driver). Then

open MATLAB, navigate to the folder with all three scripts and then run “Mac_open_valves.m”. The following output should appear:

If there is an error while running the script, it is likely because you have to install a driver. The

Serial-to-USB converter comes with a CD. Use this CD to install the driver and then try again. If you are instead running a Windows-based computer, run the script

“Windows_open_valves.m” instead. Notice, that there is now a serial connection established under the name “s1”. To close the serial connection again use: fclose(s1).

If there is an error when running “Windows_open_valves.m” script, for example, such as below it is because the correct COM port was not chosen:

In this case, the serial connection is established through COM port 8. So we need to change this in

the script “Windows_open_valves.m”. Open up this script. The code is shown below:

% start serial connection

Nature Protocols: doi:10.1038/nprot.2015.079

Page 12: Nature Protocols: doi:10.1038/nprot.2015€¦ · over the connections and heated to protect the connections. Next, wait for the soldering iron to become hot enough and cover the wire

11

s1 = serial('COM3'); fopen(s1) get(s1,{'Status','Type','Name','Port','BaudRate','Parity','DataBits','StopBits'})

Change the second line to COM8 as shown below:

% start serial connection s1 = serial('COM8'); fopen(s1) get(s1,{'Status','Type','Name','Port','BaudRate','Parity','DataBits','StopBits'})

Re-running the script, it should now work without problems. Once the serial connection has been opened, the valves can now be toggled using the function

“toggleValves.m”. As we also discuss in Box 1 of the main paper, the valves are programmed by sending ASCII characters from MATLAB to the board. This is a two-step procedure. First, using ASCII character 254, we enter command mode which allows us to switch ON or OFF any single valve. Second, a specific ASCII character between 0-15 is used to switch ON or OFF a single valve. For example, the sequence “254 – 2”, enters command mode and then turns valve 3 OFF. Similarly, the sequence “254 – 11”, enters command mode and then turns valve 5 ON.

We have written the function “toggleValves.m” to either function on a single valve (if two

inputs are given) or on all valves (if three inputs are given). The following examples illustrate the use of the function:

For example to switch ON all valves use: >> toggleValves([0,0,1],s1)

Or to switch OFF all valves use: >> toggleValves([0,0,0],s1)

To switch ON/OFF a single valve use (e.g. turn valve 3 ON): >> toggleValves([3,1],s1)

Or to turn valve 4 OFF use: >> toggleValves([4,0],s1)

When any individual valve is turned ON, a right light will appear on the board. For example:

>> toggleValves([0,0,0],s1); %all OFF >> toggleValves([0,0,1],s1); %all ON

Note, that when valves are in the OFF position, medium flows through the left inlet. When valves

are in the ON position, medium flows through the right inlet.

Nature Protocols: doi:10.1038/nprot.2015.079

Page 13: Nature Protocols: doi:10.1038/nprot.2015€¦ · over the connections and heated to protect the connections. Next, wait for the soldering iron to become hot enough and cover the wire

12

Thus, by using the “toggleValves.m” function, control sequences of arbitrary function can be generated. We find it useful to use the “pause” function in MATLAB to incorporate delays (in seconds).

As an example, below is a program we use for “duration modulation” experiments: for a constant 1-

NM-PP1 concentration, we ask how gene expression depends on the duration of the pulse. The program below delivers the following pulses:

o Valve 2: 50 min o Valve 3: 20 min o Valve 4: 10 min o Valve 5: 30 min o Valve 6: 40 min

The actual code is shown below for illustration purposes:

% Start Experiment: tic; %0 min - turn everything ON with delay toggleValves([2,1],s1); %turn 2 ON disp(['Time: ', num2str(toc/60), ' min']); pause(27); toggleValves([3,1],s1); %turn 3 ON disp(['Time: ', num2str(toc/60), ' min']); pause(27); toggleValves([4,1],s1); %turn 4 ON disp(['Time: ', num2str(toc/60), ' min']); pause(27); toggleValves([5,1],s1); %turn 5 ON disp(['Time: ', num2str(toc/60), ' min']); pause(27); toggleValves([6,1],s1); %turn 6 ON disp(['Time: ', num2str(toc/60), ' min']); pause(546); toggleValves([4,0],s1); %turn 4 OFF disp(['Time: ', num2str(toc/60), ' min']); pause(573); toggleValves([3,0],s1); %turn 3 OFF disp(['Time: ', num2str(toc/60), ' min']); pause(654); toggleValves([5,0],s1); %turn 5 OFF disp(['Time: ', num2str(toc/60), ' min']); pause(627); toggleValves([6,0],s1); %turn 6 OFF disp(['Time: ', num2str(toc/60), ' min']); pause(492); toggleValves([2,0],s1); %turn 2 OFF disp(['Time: ', num2str(toc/60), ' min']); toc; fclose(s1);

We use a 27 second delay between switching each valve ON to account for the delay due to imaging

time. It takes ~27 s to image two stage positions in each microfluidic channel with our settings and this delay has to be incorporated into the exposure program. We find it helpful to close the valves at the end of a script (fclose(s1)) to avoid the script running twice if you accidentally hit the run button twice. If this line is included, just remember to open the valves again after the experiment (fopen(s1)).

While the above code illustrates how to use a list of toggleValves calls and pause sequences to

control the valves over time, it is a very inefficient way of writing the code. In general, it can be useful to write a function that converts a list of pulse sequences into a full control script. Writing the pulse sequences by hand such as above is also much more prone to errors.

The most convenient form of the script will depend on the specific purpose. But to provide some intuition, the brief script below illustrates how to adjust the pulse duration, pulse interval and pause time for

Nature Protocols: doi:10.1038/nprot.2015.079

Page 14: Nature Protocols: doi:10.1038/nprot.2015€¦ · over the connections and heated to protect the connections. Next, wait for the soldering iron to become hot enough and cover the wire

13

oscillatory input: clear; clc; close all; %Define pulse sequence parameters pulse_duration = 300; %duration of pulse in seconds (5 min) pulse_interval = 450; %duration of the interval between pulses (7.5 min) pulse_number = 5; %the number of pulses to be delivered pause_time = 27; %time to pause between each microfluidic channel channel_number = 5; %number of microfluidic channels, i.e. 5. % Start Experiment: tic; for i=1:pulse_number %Turn ON each valve and add the delay for j=2:channel_number+1 toggleValves([j,1],s1); %turn valve ON disp(['Time: ', num2str(toc/60), ' min']); pause(pause_time); end %Calculate remaining time before valves should be turned OFF remaining_time = pulse_duration - channel_number*pause_time; %Now pause for this time before turning valves OFF pause(remaining_time); %Turn OFF each valve and add the delay for j=2:channel_number+1 toggleValves([j,0],s1); %turn valve OFF disp(['Time: ', num2str(toc/60), ' min']); pause(pause_time); end %Calculate remaining time of this pulse sequence remaining_time = pulse_interval - channel_number*pause_time; %Now pause for this time before repeating the for loop pause(remaining_time); end %Finish the experiment toc; fclose(s1);

Nature Protocols: doi:10.1038/nprot.2015.079

Page 15: Nature Protocols: doi:10.1038/nprot.2015€¦ · over the connections and heated to protect the connections. Next, wait for the soldering iron to become hot enough and cover the wire

1

SUPPLEMENTARY TUTORIAL 2 Anders S. Hansen, Nan Hao & Erin K. O’Shea

COMPUTATIONAL ANALYSIS OF TIME-LAPSE MOVIES

Introduction In this supplementary tutorial, we provide a step-by-step protocol for computational analysis of

time-lapse movies in MATLAB aimed at someone without previous image analysis experience, but with a basic knowledge of MATLAB.

All code is provided under the GNU General Public License version 3 for free software as a service to the community and you can redistribute and modify it according to the GNU license. We hope that you will find the code useful, but it is distributed without any warranty and without any guarantee that it will work for any particular purpose. For the GNU General Public License please see: http://www.gnu.org/licenses

In this tutorial, we illustrate the steps with an example movie composed of just three frames and just

two image channels. We use the same example movie as is shown in Figure 2a of the main paper. To keep the file size small, the TIFF images are just 99x99 pixels and we just use three frames. When this tutorial has been completed, the three frames should be segmented and the cells tracked as shown below:

File organization The main script for segmentation and tracking of cells is “time_lapse_tutorial.m”. This script

requires a series of functions to run. After unpacking the folder provided as Supplementary Data 3, make sure that the folder contains the following files and folders:

o best_ellipse_generator.m o ellipse_generator_radians.m o ellipse_library_diploids_radians.mat o imoverlay.m o pixels_inside_ellipse_radians.m o save_func.m o tiffread.m o time_lapse_tutorial.m o TIFF_images – a folder containing all the images

Assuming that all of these files are contained in the folder, the main script “time_lapse_tutorial.m”

should run without errors. The script takes less than 3 min to run in serial (on a 2011 MacBook Pro laptop running MATLAB R2011a), but will run significantly faster in parallel (the default setting). Please note that though the default setting is for the script to run in parallel, if a computer without the parallel computing

Nature Protocols: doi:10.1038/nprot.2015.079

Page 16: Nature Protocols: doi:10.1038/nprot.2015€¦ · over the connections and heated to protect the connections. Next, wait for the soldering iron to become hot enough and cover the wire

2

toolbox or a computer without multiple cores is used, three lines in the code should be changed to allow the code to run in serial.

Preamble – overview of the image analysis process

This tutorial will illustrate the basics of image analysis. The scripts and functions provided here will illustrate the process and can furthermore be adapted for any particular purpose of interest to the user. Many labs that use time-lapse microscopy have invested significant amounts of time to develop their own custom-written image analysis code, but this code is rarely available. This is likely because labs tend to develop code that works very well for their particular purpose, but which for exactly this reason might not generalize to other purposes well without major modification. Our full image analysis code reported previously1, which is available upon request, is no different: we developed it with our image analysis needs in mind and it requires significant modification to work for other purposes. Since the time it takes to modify existing code often exceeds the time to develop new code, many labs end up writing their own code in the end.

Nonetheless, in addition to this tutorial, we also refer the reader to other publications by labs which have provided their code and guidance on how to use it for the community2-8. A very helpful and detailed discussion about image analysis for budding yeast is also provided by Ferry et al.9. In this Supplementary Tutorial 2 we will first give a general overview of image analysis and introduce the basic concepts and considerations. Second, we will go through our example using our provided image analysis code in MATLAB and example images. Third and finally, we will discuss extensions of this example.

The basic goal of image analysis is to determine which pixels belong to a cell in each frame of a time-lapse movie. If this is known, a large number of properties of the cell can be calculated such as the cell size, cell shape, fluorescence intensity of gene expression reporters and the subcellular localization of fluorescently tagged molecules. Segmentation involves determining which pixels belong to a cell in an individual frame by determining the boundary between what is inside and outside of the cell. Cell segmentation is illustrated in main Figure 2a, where green ellipses establish the boundary between the inside and outside of a cell. Once all the cells have been segmented in each frame, they must be connected between frames as illustrated in the example images shown above where each cell is assigned a number. The main advantage of time-lapse microscopy over other single-cell techniques such as flow cytometry is that individual cells can be followed over time. Therefore, it is crucial that tracking errors are avoided. Finally, once cells have been segmented and tracked, the property of interest must be quantified. It is very difficult to provide specific scripts for this, since this will depend entirely on the question the user is interested in. However, once cells have been segmented and tracked, quantification of the property of interest (e.g. total fluorescence in cells), it typically very straightforward.

Cell segmentation and tracking involves distinguishing true cells from background and will invariably involve setting thresholds or quality control requirements to exclude real events from false events. While these thresholds have to be optimized for each research problem in question, it is important to make sure that they do not bias what is being studied. For example, our ellipse segmentation method matches real cells to a library of “allowed” ellipse shapes. In other words, any cell whose dimensions do not fit into this library will be excluded. We have made sure that this library matches the full distributions of cell sizes that we experimentally observe. But if for example one were to study yeast mutants with abnormal cell size or shape, this ellipse library would bias detection against abnormal cell size and shapes and therefore bias the analysis. Therefore, if one were to study cell size and shape mutants, it would be essential to use image analysis code that does not bias cell detection based on a pre-defined list of “allowed” ellipse shapes. Furthermore, if a different objective was used (e.g. 40x or 100x instead of our current 63x objective), the cell size distribution would now be different and the library should be updated accordingly. As another example, our tracking algorithm assumes relatively modest cell movement between frames and gives up on cells that show too high movement between frames. Thus, if one were to study cell movement (e.g. chemotaxis), it would be essential to adopt a tracking algorithm that does not bias against more mobile cells – in this chemotaxis example, our current tracking algorithm would underestimate cell movement by not counting the most mobile cells. We hope that these examples illustrate some of the common pitfalls in computational image

Nature Protocols: doi:10.1038/nprot.2015.079

Page 17: Nature Protocols: doi:10.1038/nprot.2015€¦ · over the connections and heated to protect the connections. Next, wait for the soldering iron to become hot enough and cover the wire

3

analysis and why it is so important to carefully consider the research question and whether the chosen image analysis algorithm is appropriate to that question.

Returning to image analysis in MATLAB, the first step in any type of image analysis is to convert

images from an image file format to a matrix in MATLAB. The most common format for microscopy images is greyscale 16-bit tif images. Such images are matrices of pixels where each element takes a value between 0 and 65535. The MATLAB function tiffread.m (attached as Supplementary Data 3) developed by Francois Nedelec takes a tif image and converts it to a MATLAB matrix. For time-lapse movies, it is useful to convert each image channel to a 3D-matrix where the third dimension corresponds to the number of timepoints.

Once images have been read into MATLAB as matrices we can now perform various operations on them. The first step is background subtraction, which is a crucial and necessary step to avoid bias in fluorescence-based calculations. We use the most frequent value (the mode2) for pixels not currently occupied by cells as the background in each channel.

Once images have been read and the background subtracted, the next step is segmentation. There are many approaches to budding yeast segmentation, but they generally rely on the fact that under phase contrast microscopy each yeast cell wall appears as a bright white phase ring around the cell (in greyscale images, “white” refers to pixels of high intensity and “black” refers to pixels of low intensity). The simplest approach to cell segmentation is to simply threshold the phase images. The MATLAB function imhist is useful for this. E.g. if one is working on an image matrix called img the command:

>> imhist(img) will diplay a histrogram of all pixel intensity values which can inform which value to use for

thresholding. For all but the most rudimentary applications, we do not recommend segmentation-by-thresholding since in our experience this is not robust. For segmentation of the nucleus however, if a bright nuclear marker such as NHP6a-iRFP1 is used, segmentation by thresholding is normally sufficiently robust provided that a smoothing filter is applied to the image prior to thresholding.

Our segmentation algorithm goes through a library of 637 ellipses, scores each one based on how

well it matches the phase ring and saves the best one for each cell pixel. This is computationally expensive, but quite robust. Certainly much more time-efficient algorithms are available, but the segmentation can be run in parallel on a computing cluster and if this is done the segmentation takes two or so hours for a typical movie and is thus not prohibitively slow. In this example we will use a smaller time-lapse movie (fewer frames and smaller images) and the whole script should therefore only take about three minutes to run on a laptop computer if it is run in serial. Although it is possible to just search all pixels in an image this is extremely inefficient and for our segmentation approach to work efficiently, it is ideal to have a fluorescent channel that does not change much or at the very least does not exhibit a lot of cell-to-cell variability to threshold and thereby determine the approximate location of each cell. In this tutorial the CFP images serve this purpose, but this is important to keep in mind if this approach is used for another purpose. Even if say an experiment involves changes in RFP levels over time in a cell labeled with a red fluorescent protein, images can still be collected in a CFP, YFP or GFP channel and the autofluorescence inherent to cells should be sufficient to threshold and locate the approximate cell positions such as is done using CFP in this tutorial.

Following segmentation, an ellipse is chosen for each cell and cells are tracked between the three frames. This part of the script is time-efficient and should at most take a couple of seconds. In the following section we will describe each individual step in more detail and directly refer to the code and lines in the MATLAB script time_lapse_tutorial.m. Running the time_lapse_tutorial.m script to segment and track cells

First, open MATLAB and navigate to the folder containing the files mentioned above. Open the script “time_lapse_tutorial.m” and press run. The code contains detailed comments explaining all of the steps involved.

If an error occurs at line 183 (matlabpool open), this is likely because the computer lacks the

Nature Protocols: doi:10.1038/nprot.2015.079

Page 18: Nature Protocols: doi:10.1038/nprot.2015€¦ · over the connections and heated to protect the connections. Next, wait for the soldering iron to become hot enough and cover the wire

4

parallel computing toolbox from MATLAB or does not have multiple cores available. To run the script in serial instead, make the following changes to lines 183, 186 and 199:

Parallel computing version:

Serial version:

To make these changes comment out lines 183 and 199 by inserting a percentage sign (%) and change parfor in line 186 to for. The script should then run by itself and produce a series of images and a MATLAB workspace containing all the relevant information named workspace.mat.

Below, we will go through each subpart of the time_lapse_tutorial.m master script in more

detail.

Reading in TIFF images (lines 35-58) Using the function “tiffread.m”, the script reads in the 16-bit TIFF images and converts them to

matrices. E.g. all the phase contrast images are contained in the 3D matrix “phase”, where the third dimension corresponds to the number of time points. The same is true for CFP. To adapt this part of the code, simply add or remove additional channels as is relevant to your experiment.

Background subtraction (lines 60-127)

To accurately quantify fluorescence it is critical to subtract background fluorescence from each image and each time-point since the background can change over time, especially if cells are close together. The script does a rough-and-dirty thresholding of the CFP images to identify where the cells are and then uses the surrounding pixels for background subtraction. We use the mode, i.e. the most frequent value (the peak of the histogram), as the background. The values used for the rough threshold of CFP thresholding

Nature Protocols: doi:10.1038/nprot.2015.079

Page 19: Nature Protocols: doi:10.1038/nprot.2015€¦ · over the connections and heated to protect the connections. Next, wait for the soldering iron to become hot enough and cover the wire

5

values will clearly have to be optimized for any particular purpose. But in general, it is advisable to first apply a smoothing filter (e.g. fspecial('gaussian', [9 9], 2);) to get rid of pixel-to-pixel noise and then apply a threshold. When we apply a threshold to an image (e.g. CFP_thres = CFP_smoothed > 20000;), we generate a binary image. That is, CFP_thres will be a binary image where each pixel will be 1 (and therefore white) if the element was above 20000 and all other pixels will be 0 (and therefore black). For purposes of illustration, the lines below plot the phase image and thresholded CFP image side-by-side and saves the output as a PNG:

figure; subplot(1,2,1); imshow(imadjust(phase(:,:,n))); subplot(1,2,2); imshow(CFP_thres); title('Thresholding CFP to find cell location');

print('-dpng',['CFP_threshold_for_background_subtraction_', num2str(n)]); Once the thresholding values been optimized, it is clearly a nuisance to have these images pop up,

but for purposes of illustration and understanding the logic, we believe it is helpful to include them in this tutorial. It can also be helpful to play around with the threshold and see how that affects the binary CFP thresholded image. An example of one of these images is shown below:

After thresholding, we then use the mode from all the ‘black’ pixels in the image above as a measure

of the background. The mode is much more robust and accurate than the mean or median in our experience and has also been used previously by others2.

Finally, in lines 116-126, a PNG image summarizing the background in each fluorescent channel (in this example only CFP) is saved for reference. This can be helpful to ensure that the background subtraction is working well. If there is a lot of variability in background from frame-to-frame this generally indicates that something went wrong during the image acquisition (e.g. an air bubble could have appeared).

Segmentation preamble (lines 130-179)

The ellipse segmentation algorithm requires knowledge of the rough location of cell centroids, i.e. the centre of the ellipse, which has to be fit to the phase ring around the cell. To obtain this, we perform a rough identification through CFP thresholding and then save the pixels for subsequent use in the matrix img_to_search. For parallel computing to work, each core has to work independently and not simultaneously try to access the same variable as another core. We therefore convert the pixels from img_to_search into temp_pixels. The slightly cumbersome temp_pixels loop is just to ensure that everything works for parallel processing.

We repeat the CFP thresholding because it is helpful to apply a more stringent filter and threshold to reduce the number of pixels. The ellipse segmentation algorithm takes an amount of time, which is proportional to the number of pixels that the algorithm has to search. Therefore, it is highly desirable to limit the number of pixels that the algorithm has to search. Here again, we plot output images to show the thresholding. This is just to illustrate the process – as before, the images are useful for optimizing the threshold value (60000 in this example), but the line plotting the images can be commented out once the correct threshold has been determined. As an example, an image of the more stringent threshold is shown below.

Nature Protocols: doi:10.1038/nprot.2015.079

Page 20: Nature Protocols: doi:10.1038/nprot.2015€¦ · over the connections and heated to protect the connections. Next, wait for the soldering iron to become hot enough and cover the wire

6

Ellipse segmentation Part I (lines 179-200)

Using the list of pixels from above (temp_pixels), the best_ellipse_generator.m function from above will use the library “ellipse_library_diploids_radians.mat” of ellipse a, b and θ values and find the highest scoring ellipse for each ellipse centroid pixel. The ellipse scoring works by considering how well the ellipse fits the phase ring around the cell. The angle is in units of radians rather than degrees. Very briefly, the best_ellipse_generator.m function will take a phase image and an ellipse and go through each pixel in the ellipse perimenter and determine the phase image intensity in this perimeter and use this to score how well the ellipse matches the phase ring. Since the phase ring is much brighter than background and since out-of-focus cells have less bright phase rings, this function makes sure that in-focus cells are preferentially segmented.

For each frame, a list of the best ellipses for each pixel is saved as a mat file, e.g. ellipse_2.mat is the mat file for frame 2. This part is the most computationally intensive part of the script and might take around 2-3 min if run in serial, but it will be much faster if run in parallel. We run all segmentation on a computing cluster where we have access to multiple cores. Rather than storing the ellipse information in-script, we output it as .mat files because this implementation works with parallel computing and because this is the most time-intensive part of the script, so if one is optimizing an unrelated part of the script it is convenient to not have to wait for Ellipse Segmentation Part I during each iteration. As mentioned above, if an error occurs when attempting to run the script in parallel, change it to serial by commenting out lines 183 and 186 and changing parfor in line 189 to for and try running it again.

Ellipse segmentation Part II and tracking (lines 201-394)

Tracking and ellipse segmentation Part II is linked. We use a series of constraints that should be optimized for any particular purpose – the current values work for this example, but for any other purposes the thresholds and QC values will almost certainly need to be re-optimized. The values used here are optimized for diploid yeast cells, so if a different magnification is used etc. the constraints will have to be changed.

We use a while loop to keep picking ellipses from the scored ellipse library from Ellipse Segmentation Part I until the quality drops too much or until all ellipses have been tested. To verify that a high-scoring ellipse matches a cell, we take the following QC steps:

o Minimum distance: the distance between two closest cell centroids should be at least 23 pixels.

o Maximum overlap: it will occasionally happen that some ellipse boundaries overlap, but they should not do so by more than 5%.

o Small change in size. The size and shape of a cell should not change by a lot between frames. In this step we set the maximally allowed change in the ellipse a and b values to 2 pixels.

Once an ellipse has satisfied all of these requirements, we save it in the variable verified_cells. Tracking simply takes place by matching closest cells between frames. To avoid tracking errors, the script gives up on cells if there is no cell nearby in a previous frame. Again, we use a cut-off of 15 pixels, but this

Nature Protocols: doi:10.1038/nprot.2015.079

Page 21: Nature Protocols: doi:10.1038/nprot.2015€¦ · over the connections and heated to protect the connections. Next, wait for the soldering iron to become hot enough and cover the wire

7

will have to be optimized for any particular purpose. Finally, all verified cells for a given time-point is saved in the structured array, cell_list.

Plot cell segmentation (line 395-417)

It is convenient to have images of how well the segmentation worked. Occasionally, if there is a severe segmentation error, then by knowing the identification number of that cell it can be excluded from downstream analysis. Using a program like ImageJ, the segmented_cells images can further be imported as an image sequence if a movie of the segmentation is desired.

Finally, the time_lapse_tutorial.m script outputs a MATLAB workspace workspace.mat

containing all the images in a convenient matrix form and variables with tracking and segmentation information.

Downstream analysis of segmentation output

As mentioned above, it is hard to provide general guidelines here because the downstream analysis will depend entirely on the research question. Here we therefore provide some general suggestions for how to take the output from the above MATLAB script and how to do some common types of analysis and provide some code for these examples.

To perform analysis, clear the workspace in MATLAB and then load the file workspace.mat into MATLAB (e.g. by dragging-and-dropping it into the command window). The following variables should appear in the workspace window:

The variables CFP and phase are 3D matrices containing the raw images in matrix format. The

variable cell_tracker contains all relevant cell tracking information and the structured array cell_list contains all relevant information for each cell such as centroid coordinates and pixels. Using the information stored in cell_list and in cell_tracker essentially any analysis should be possible. Below, we will therefore explain these variables in more detail.

Each row in cell_tracker is a single cell. The numbers in each row corresponds to which number in the cell_list variable the cell is in each frame. Therefore, to quantify a particular cell throughout a movie, we can write a loop that takes the number from each column in a row of cell_tracker and reads out the number and then goes through cell_list to determine for example which pixels were contained by the cell in each frame. To illustrate this, the script below (“CFP_quantification_example.m”) goes through each successfully tracked cell and quantifies the mean CFP fluorescence in each cell throughout the movie:

%%%%%%%%%%%%%%%%% DETERMINE PER-CELL FLUORESCENCE %%%%%%%%%%%%%%%%%%%%%%%%% %determine how many cells were successfully tracked all the way to the %end of the time-lapse movie by determining the number of non-zero %elements in cell_tracker in the last frame: cells_tracked = nnz(cell_tracker(:,end)); cells_indices = find(cell_tracker(:,end)>0)'; %variable for storing CFP fluorescence per cell CFP_cell = zeros(cells_tracked, timepoints); tic; for i=1:timepoints for j=1:cells tracked

Nature Protocols: doi:10.1038/nprot.2015.079

Page 22: Nature Protocols: doi:10.1038/nprot.2015€¦ · over the connections and heated to protect the connections. Next, wait for the soldering iron to become hot enough and cover the wire

8

current_cell = cells_indices(j); %Next determine the centroid coordinates and the a, b and theta %values of each cell in each frame %Generate a list of pixels using a-3 and b-3 as the ellipse shapes %This is because the phase ring actually extends beyond the %cell, so for fluorescence don't use the whole cell ring. cell_x = cell_list(cell_tracker(current_cell,i),i).centroid(1,1); cell_y = cell_list(cell_tracker(current_cell,i),i).centroid(1,2); cell_a = cell_list(cell_tracker(current_cell,i),i).a_b_theta(1,1)-3; cell_b = cell_list(cell_tracker(current_cell,i),i).a_b_theta(1,2)-3; cell_theta = cell_list(cell_tracker(current_cell,i),i).a_b_theta(1,3); %Now determine the pixels in this smaller ellipse Reporter_pixels = pixels_inside_ellipse_radians(cell_x, cell_y, cell_a, cell_b, cell_theta); %Remove any pixels which are outside the image because the ellipse was too big Reporter_pixels(any(Reporter_pixels>size(phase,1),2),1) = []; Reporter_pixels(any(Reporter_pixels>size(phase,2),2),2) = []; %Remove any pixels below 1 which are outside the image Reporter_pixels(any(Reporter_pixels<1,2),:) = []; %save the cell size cell_size(j,i) = size(Reporter_pixels,1); %If you are quantifying nuclear localization use the entire cell. %E.g. in main Figure 2a, where we quantify Msn2-mCherry nuclear %localization we use the full ellipse for quantification of nuclear %localization. cell_pixels = cell_list(cell_tracker(current_cell,i),i).pixels; %%%%%%%%%%%%%%% QUANTIFY CFP FLUORESCENCE PER CELL %%%%%%%%%%%%%%%% temp_CFP = zeros(length(Reporter_pixels),1); for k = 1:length(Reporter_pixels) temp_CFP(k,1) = CFP(Reporter_pixels(k,1), Reporter_pixels(k,2),i); end CFP_cell(j,i) = mean(temp_CFP); %take the average fluorescence per cell end clear temp_sum temp_val temp_CFP cell_pixels Reporter_pixels end toc;

Note that for quantification of mean-cell fluorescence we use the segmented ellipse a and b values

minus 3. This is also illustrated in the main Figure 2a, where we used the full ellipse for quantification of how much Msn2-mCherry is nuclear, but smaller ellipses for determining the mean-cell fluorescence of the CFP and YFP gene expression reporters.

As mentioned, we use the 15 brightest pixels per cell for quantification of nuclear localization. Once, the pixels contained by the cell in the RFP image has been determined, determining the intensity of the brightest pixels is straightforward. For example, the loop below is a simple way of achieving this:

%%%%%%%%%%%%% QUANTIFY MSN2-mCherry FLUORESCENCE %%%%%%%%%%%%%% temp_RFP_cell = zeros(length(cell_pixels),1); for k = 1:length(cell_pixels) temp_RFP_cell(k,1) = RFP(cell_pixels(k,1), cell_pixels(k,2),i); end temp_sum = 0; %use the 15 brightest pixels to quantify nuclear localization for k = 1:15 [temp_val temp_index] = max(temp_RFP_cell); temp_RFP_cell(temp_index,1) = 0; temp_sum = temp_sum + temp_val; end RFP nuc(j,i) = temp sum/15;

Nature Protocols: doi:10.1038/nprot.2015.079

Page 23: Nature Protocols: doi:10.1038/nprot.2015€¦ · over the connections and heated to protect the connections. Next, wait for the soldering iron to become hot enough and cover the wire

9

This way, the amount of Msn2 in the nucleus in each cell in each frame can be determined. The above loop was used to calculate Msn2-mCherry localization for the plot in main Figure 2b.

Nature Protocols: doi:10.1038/nprot.2015.079

Page 24: Nature Protocols: doi:10.1038/nprot.2015€¦ · over the connections and heated to protect the connections. Next, wait for the soldering iron to become hot enough and cover the wire

10

REFERENCES 1. Hansen, A.S. & O'Shea, E.K. Promoter decoding of transcription factor dynamics involves a trade-off

between noise and control of gene expression. Molecular systems biology 9(2013). 2. Gordon, A. et al. Single-cell quantification of molecules and rates using open-source microscope-based

cytometry. Nature Methods 4, 175-181 (2007). 3. Lamprecht, M.R., Sabatini, D.M. & Carpenter, A.E. CellProfiler(TM): free, versatile software for automated

biological image analysis. Biotechniques 42, 71-75 (2007). 4. Doncic, A., Eser, U., Atay, O. & Skotheim, J.M. An Algorithm to Automate Yeast Segmentation and

Tracking. Plos One 8(2013). 5. Pelet, S., Dechant, R., Lee, S.S., van Drogen, F. & Peter, M. An integrated image analysis platform to quantify

signal transduction in single cells. Integrative Biology 4, 1274-1282 (2012). 6. Zopf, C.J. & Maheshri, N. Acquiring Fluorescence Time-lapse Movies of Budding Yeast and Analyzing

Single-cell Dynamics using GRAFTS. Jove-Journal of Visualized Experiments (2013). 7. Young, J.W. et al. Measuring single-cell gene expression dynamics in bacteria using fluorescence time-lapse

microscopy. Nature protocols 7, 80-88 (2012). 8. Kvarnstrom, M., Logg, K., Diez, A., Bodvard, K. & Kall, M. Image analysis algorithms for cell contour

recognition in budding yeast. Optics Express 16, 12943-12957 (2008). 9. Ferry, M.S., Razinkov, I.A. & Hasty, J. Microfluidics for Synthetic Biology: From Design to Execution.

Methods in Enzymology, Vol 497: Synthetic Biology, Methods for Part/Device Characterization and Chassis Engineering, Pt A 497, 295-372 (2011).

Nature Protocols: doi:10.1038/nprot.2015.079