Skip to content

SNPFISH Colocalization User Guide

Ian Mellis edited this page Dec 8, 2020 · 4 revisions

[TOC]

Introduction

This guide will quickly detail the steps needed to perform SNP-FISH colocalization. You can download a sample data set to play with here: SNP FISH Example Data

  1. First, segment and threshold your images as typical. See Worked Example.

YAML Files

You will need to make a YAML file with your experimental details and have this in your data directory. See the YAML Guide for more information.

Gaussian Fitting

In order to be precise, SNP-FISH requires sub-pixel resolution of the centroid of the RNA spot so that colocalization can be as precise as possible. So, the next thing to do is to add a Gaussian fitting processor the image objects.

(Note, you may want to save all the commands in a script in your data directory so that you can know exactly what you did later).

  1. Instantiating the Gaussian Fitter. When using SNP-FISH, you will need to fit three channels, one corresponding to the guide probe and the other two to the SNP probes. Typically, these channels are alexa, cy, and tmr. The code below creates the gaussian fitting object, improc2.nodeProcs.TwoStageSpotFitProcessedData(), and adds it to all objects in your directory. The update all command actually runs these objects, which performs the fitting. (Note, this take can take several hours/overnight depending on your data-set size).

The SNP Colocalizer Class

Once your image objects have completed the gaussian fitting, you are ready to create the SNPColocalizer class and add it to your image objects.

  1. Creating the snpMap.

The snpMap is a custom struct that tells the SNP Colocalizer the your experimental design. It consists of two fields, snpMap.names and snpMap.channels, as shown in the example below.

snpMap.channels = {'alexa', 'tmr', 'cy'};
snpMap.names = {GUIDE NAME, ...
                WT ALLELE, ...
                MUT ALLELE,};

Ideally, instead of hard coding this, you will load it from the YAML file. See the worked example at the bottom of this script.

The SNPMap pairs the channels with the corresponding names of the probes tested in your experiment, the order of the two SNP probes does not matter, but the first entry in the SNPMap should always be the guide probe.

  1. Adding the SNP Colocalizer

Add the SNPColocalizer in the same way the Gaussian fitter is added- note that it requires the snpMap.

dataAdder = improc2.processing.DataAdder();
dataAdder.addDataToObject(improc2.nodeProcs.SNPColocalizer(snpMap), snpMap.channels, 'snpColoc');
dataAdder.repeatForAllObjectsAndQuit();

improc2.processing.updateAll();

Congratulations! You are done. You can now extract the data any way you want and analyze it as you will. For your convenience, a sample script below shows all steps and can be used for your convenience.

  1. Sample Code
%% Worked Example Sample Analysis Script

% This sample contains a sample SNP FISH gene with two alleles.
% The gene in this case is Dusp6 in a mouse embryonic fibroblast.
% The guide probe is in the gfp wavelength, and the two alleles are
% in the Cy3 and Cy5 wavelengths. This sample was selected because you 
% can observe transcriptional bursting from both alleles, one colocalizing
% with one allele and the other with the other. 

%% Read YAML FILE
expData = ReadYaml('readme.yaml');



%% Sample snpMap Definition
snpMap.channels = {'gfp', 'tmr', 'cy'};
snpMap.names = {expData.channels.gfp.probe, ...
                expData.channels.tmr.probe, ...
                expData.channels.cy.probe,};

%% Gaussian Fitting

dataAdder = improc2.processing.DataAdder();
unprocessedFittedData = improc2.nodeProcs.TwoStageSpotFitProcessedData();

dataAdder.addDataToObject(unprocessedFittedData, 'gfp', 'gfp:Fitted')
dataAdder.addDataToObject(unprocessedFittedData, 'tmr', 'tmr:Fitted')
dataAdder.addDataToObject(unprocessedFittedData, 'cy', 'cy:Fitted')

dataAdder.repeatForAllObjectsAndQuit();

improc2.processing.updateAll()


%% Perform SNP Colocalization

dataAdder = improc2.processing.DataAdder();
dataAdder.addDataToObject(improc2.nodeProcs.SNPColocalizer(snpMap, ...
    'zAllow', 3), snpMap.channels, 'snpColoc');
dataAdder.repeatForAllObjectsAndQuit();

improc2.processing.updateAll();


%% Create MOLTEN Data tables for Export

tools = improc2.launchImageObjectTools();


cellCounts = [];
tools.iterator.goToFirstObject
cellID = 1;

guideAll = []; 
cyAll = [];
tmrAll = [];

while(tools.iterator.continueIteration)
    results = tools.objectHandle.getData('snpColoc');
    
    guide = struct2table(results.data.gfp);
    guide.cellID = ones(height(guide),1) * cellID;
    cy = struct2table(results.data.cy);
    cy.cellID = ones(height(cy),1) * cellID;
    tmr = struct2table(results.data.tmr);
    tmr.cellID = ones(height(tmr),1) * cellID;
    
    if isempty(guideAll)
    guideAll = guide;
    else
    guideAll = vertcat(guideAll, guide);
    end
    
    if isempty(cyAll)
    cyAll = cy;
    else
    cyAll = vertcat(cyAll, cy);
    end
    
    if isempty(tmrAll)
        tmrAll = tmr; 
    else
    tmrAll = vertcat(tmrAll, tmr);
    end
    
    tools.iterator.goToNextObject;
    cellID = cellID + 1;
end


%% Export to CSV

writetable(guideAll, 'sample_SNPFISH_genetable.csv')

Visual inspection of colocalized SNP spots

  1. Using SNPspotInspector

After you've completed spot colocalization, now it's time to convince yourself that the colocalizations you're detecting are real! Pick a few random cells from your dataset and note their array and object numbers. For example, in this example dataset, we're considering array 5, object 3. Navigate to your data folder and proceed:

Get the objectHandle for a cell to inspect


tools = improc2.launchImageObjectTools;
tools.navigator.tryToGoToArray(5);
tools.navigator.tryToGoToObj(3);

objectHandle = tools.objectHandle;

Now identify the SNPColocalizer class node name that you want to inspect. For example, in this dataset we're using a node named 'snpColocF'.


snpNode = 'snpColocF'; % change 'snpColocF' to 'snpColoc' if you ran the code exactly as above or to the name of your data's SNPColocalizer node label
SNPspotInspector(objectHandle, 15, snpNode) % the middle arg is the z plane initially displayed. (It shouldn't be greater than the height of the stack.)

Screen Shot 2016-06-30 at 11.32.05 AM.png

  • Use the "Up Z" and "Down Z" buttons to navigate between planes.
  • Use the magnifying glass icons on the tool panel to zoom in and out
  • Circles are bold when a called spot is most in focus in the viewed plane, and they are regular, or slimmer, when the spot is called but out of focus by one plane up or down.
  • Circles are overlaid on the guide and SNP channels when colocalized in the snpNode