The FlowJo X Script Editor allows the user to automate and extend the features in FlowJo (Java version only).
When creating FlowJo scripts, it will be helpful to know some javascript, here is a reference tutorial, and here is the FlowJo X Script Editor manual page.
Sample Sorting by Collection Date
In FlowJo Tech Support, every now and then a users writes in wanting to sort the Samples in the FlowJo X Workspace by the collection order. The different cytometers can use different formats for the Date keyword, however one can write a script in FlowJo to standardize the date into a sortable format like:
yyyymmdd HH:MM:SS
The simple script below is an example that creates a new keyword and assigns it values derived from the $DATE and $BTIM Sample keywords to allow Sample sorting by collection date.
Here is the script in the above picture for reference:
var samples = workspace.samples;
var numOfSamples = samples.length;
/* Iterate over all samples */
for (var i=0; i<numOfSamples; i++)
{
/* show each samples name and cytometer in console */
console.log("sample is: " + samples[i].name + ' ' + samples[i].keywords['$CYT']);
if (samples[i].keywords['$CYT'] == 'FACSCanto' ) /* check Cytometer */
{
var date = samples[i].keywords['$DATE'];
console.log("$date keyword is " + date);
var year = date.substring(11, 7); /* start after 7th character, end at 11th */
var month = date.substring(6, 3);
if (month == 'JUN') /* change date text into sortable date number */
{
month = '06';
}
var day = date.substring(2, 0);
var collectionDate = (year + month + day + " " + samples[i].keywords['$BTIM']);
/* create CDATE keyword and assign it the sortable collection date value */
samples[i].keywords['CDATE'] = collectionDate;
console.log("cdate keyword is: " + samples[i].keywords['CDATE']);
}
}
Once the sortable date keyword values are assigned by the script, one can double click the CDATE column title in the workspace to sort ascending (or double click again to sort decending).
Index Sorting
As another example, here is a time saving script written by one of our application scientists to help a customer automate some Index Sorting data:
/** --- Iterate samples --- **/
var samples = workspace.samples;
var size = samples.length;
for (var i=0; i<size; i++)
{
var sample = workspace.samples[i];
var fields = [];
console.log(sample.name);
/** --- Go through all of the index sorting keywords and compile them --- **/
for (var j=1; j<8; j++)
{
var keyName = "INDEX SORTING LOCATIONS_"+j;
var locationsKey = sample.keywords[keyName];
if (!locationsKey)
break;
var lastindex = locationsKey.lastIndexOf(";");
var usableStr = locationsKey.substring(0, lastindex);
fields = fields.concat(usableStr.split(";"));
/** fields = fields.replace(", ", ""); **/
}
console.log("Item count: " + fields.length);
console.log("Items: " + fields);
/** --- Create a gate for each cell, with the well location as the name --- **/
for (var j=0; j<fields.length; j++)
{
var field = fields[j];
var begin = j;
var end = j+1;
var gate = sample.gating.range(field, "Event #", begin, end);
}
gate.update();
}
I have a FACS user who is having trouble with the script when analyzing influx derived index sort data using flowjo 10.1. He gets this error:
--- Index sort gating - Influx ---
TypeError: Cannot call method "split" of undefined (line 18, column 0)
His Flowjo and java data is as follows:
FlowJo 10.1r5
Operating System: Mac OS X
Java Version: 1.6.0_65-b14-468-11M4833
Build number: 45380
Any insight as to how to bypass this error?
Also, within each well, is their a way to visualize only the sorted event graphically? I've gotten the script to work in your recommended version 10.0.8 and see that when a particular well is selected all events found prior to the sort is viewable. Well A1 for instance might have a couple 1000 events viewable as opposed to only the sorted event.
I sincerely appreciate the help!
Posted by: Brandon Carter | July 19, 2016 at 02:12 PM
Hello,
Give our technical support team a call at 541-201-0022 or techsupport@flowjo.com!
Thanks
Posted by: FlowJo, LLC | July 19, 2016 at 02:52 PM
Hi,
I have done some index sorting with 384-well plates... is it possible to post some script that enables me to make a heat-map with 384-well plates? :)
If not, do you have any suggestions on how I can make one myself?
Josh
Posted by: Josh | June 15, 2017 at 07:23 AM