File Exchange

image thumbnail

Flow Cytometry Data Reader and Visualization

version (189 KB) by

Flow Cytometry Data Reader and Visualization Example

12 Ratings



View License

This includes a function to read in the standard flow cytometry FCS format data and examples of how to visualize the data.

Comments and Ratings (19)

Arthur Barker

I also get the error;

'Error using reshape
Size arguments must be real integers.

Error in fcsread (line 81)
textHeader = reshape(textCell,2,numel(textCell)/2);'

with both 2.0, 3.0 and 3.1 files.
Any suggestions on how to solve this issue?

Ariosto Silva

Rebecca, I am having the same issue as you with a version 3.0 file. Were you able to find a workaround?
Thank you

Rebecca Grant

I get this error when trying to read my file in 2.0 and 3.0 format - any help?

Error using reshape
Size arguments must be real integers.

Error in fcsread (line 81)
textHeader = reshape(textCell,2,numel(textCell)/2)';

Thanks for this code.
I would like to plot not in log scale the Y value (not for FACS data) but this does not show what I expected. The Y scale is Strange. Could you help me?

Hector Munoz

For anyone who is getting errors when trying to change marker size/markers, there is a mismatch in the switch-case structure starting at line 78.

case 5 should match up with 'marker' in okargs, but instead relates to contourFlag. I removed the case for contourFlag and renumbered the rest of the cases.

case 5
contourFlag = pval;
case 6
marker = pval;
case 7
msize = pval;
case 8
filled = pval;

case 5
marker = pval;
case 6
msize = pval;
case 7
filled = pval;

It would be interesting to have both an absolute and relative colorbar, that tell you how many values or % of values there are for every color respectively. The [0,1] default colorbar doesn't seem to give much information. For the rest, it works fine.

Thanks for the nice code. In the color bar the range I am getting is 0 to 1. Could you please tell me what this 1 means? One more thing I need to get a contour enclosing 50% of data points, can any one help? Thanks.


very good,

Will the fcsread function work for fcs3.0 file type?

I get this error

Error using reshape
Size arguments must be real integers.

Error in fcsread (line 81)
textHeader = reshape(textCell,2,numel(textCell)/2)';

Chad Greene

Chad Greene (view profile)

The dscatter function is insanely fast and well written. It's beautifully documented and easy to use.

I used dscatter on a 1.5 million point dataset and the only bottleneck in processing is Matlab's scatter command. So I replaced the line of code which calls scatter and instead I'm using Aslak Grinsted's fastscatter, which is available on File Exchange. Here's what I replaced it with:

h = fastscatter(X,Y,col,'markersize',msize);

Now, dscatter takes 0.37 seconds to calculate and plot 1.5 million points. That's quite good.

The input parser wasn't detecting my request to set the marker size, so I added this to line 105:

tmp = strcmpi(varargin,'msize');
if any(tmp)
msize = varargin{find(tmp)+1};
msize = 10;

Thanks for writing and sharing this clever, efficient code, Robert!

I am getting an error, when using the dscatter function:
Error using histc
Edge vector must be monotonically non-decreasing

Any idea on what might be causing it?


Ruben (view profile)


The file return errors for input with NaN values (not necessary a bad thing).

F Poelwijk

F Poelwijk


arnold (view profile)

cool, but I cannot seem to set the marker size or non filled markers. Works fine with 'plot' mesh or grid, but not with 'msize:
>> h = dscatter(X, Y, 'msize', 20);
Error using scatter (line 53)
Too many input arguments.

Error in dscatter (line 170)
h =

It would also be nice if one could generate a gapless 2D image/array with the "density" as entries. Like the 2d projection of what ('plot', 'surf') actualy gives you.

On top of that I'd recommend catching the input "error" of horizontal vectors instead of vertical. It gives the user an error about equal sizes, you should just check for that and rotate the vectors if necessary ;)

Raz Shimoni

Sean Wang

Finally! I've been waiting for a long time


Updated license


Add BSD license

MATLAB Release
MATLAB 7.0.4 (R14SP2)

Inspired: Ratiometric FRET, FlowPlot, TACTICS Toolbox

MATLAB Online Live Editor Challenge

Win cash prizes and have your live script featured on our website

Learn more

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video