File Exchange

image thumbnail

FCS data reader

version 2017.06.01 (18.5 KB) by

Read FCS 2.0, FCS 3.0 and FCS3.1 format flow cytometry files

4.28571
7 Ratings

35 Downloads

Updated

View License

[fcsdat, fcshdr, fcsdatscaled, fcsdat_comp] = fca_readfcs(filename);
Read FCS 2.0, FCS 3.0 and FCS 3.1 type flow cytometry data file and creates fcsdat array with the size of [NumOfPar TotalEvents].
 Some important header data are also stored in the fcshdr structure:
 TotalEvents, NumOfPar, starttime, stoptime and specific info for parameters
 as name, range, bitdepth, logscale(yes-no) and number of decades.
 [fcsdat, fcshdr] = fca_readfcs;
 Without filename input the user can select the desired file using the standard open file dialog box.

[fcsdat, fcshdr, fcsdatscaled] = fca_readfcs(filename);
Supplying the third output the fcsdatscaled array contains also the scaled parameters. It might be useful for logscaled parameters.

[fcsdat, fcshdr, fcsdatscaled, fcsdat_comp] = fca_readfcs(filename);
In that case the script calculates the compensated fluorescence
intensities (fcsdat_comp) as well, if spillover data exist in the header

The program should work also in the case of Becton EPics DLM FCS2.0, CyAn Summit FCS3.0, FACSDiva, BD LSR-II, Partec, Accuri and Luminex type list mode files.

If you find unsupported LM file type please email me.

You can also find a complex flow cytometry data evaluation toolbox(GUI) at the FileExchane area including this function and containing more specific options:

http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=8480&objectType=file

Comments and Ratings (15)

romain kinet

FCS 3.0 data from Attune NxT flow cytometer cannot be read either

romain kinet

Hi every one! Is somebody was able to open an FCS 3.1 format file from the Attune NxT ? I applied correction provided by Matteo below but it doesn't work. fca_readfcs results in an empty matrix. Thank you

Laszlo Balkay

Laszlo Balkay (view profile)

Hi Matteo! I'v never tested the FCS 3.1 format with the fca_readfcs.m. If you could send a test file I'm going to try it. (via balkay.laszlo@med.unideb.hu or any cluod).

Matteo Ferla

I have a FCS3.1 file and it works perfectly once I opened the file (`>> open fca_readfcs`) and did search for `strcmp(fcsheader_type,'FCS3.0')` and adding a `|| strcmp(fcsheader_type,'FCS3.0')` after it on both instances.

Laszlo Balkay

Laszlo Balkay (view profile)

Hi Ariel! I have not worked with fcs file including multiple data set. If you sent (or share with) me your file I going to try to fix this.

Ariel L

Should this code be able to extract multiple data sets from the FCS file? I can only get it to extract the first data set in a FCS 3.0 file. Thank you.

William

Thank you for this code.

I had some trouble with it, because I had an FCS 3.0 file that had some parameters which were 16 bit and some which were 32 bit. As far as I can tell, that kind of mixing is allowed FCS 3.0, so I tried to change the code to handle it correctly.

In the part that actually reads the data, I changed

            fcsdat = fread(fid,[fcshdr.NumOfPar fcshdr.TotalEvents],'uint16',machineformat)';

to

            fcsdat = fread(fid,[sum([fcshdr.par.bit]/16) fcshdr.TotalEvents],'uint16',machineformat)';

and that seemed to take care of it. You may want to upgrade the other datatypes to use that same method, or some other even better method.

Also, my file used linefeed, ASCII code 10, as the mnemonic separator.

Thanks again!

Thanks a lot for the script!
I was wondering if it is suitable for reading fcs files exported with the FlowJo software. Somehow I have difficulties reading them. Once read, the data looks different from what I actually see in FlowJo.
Cheers!

Sushant

I found the script very readable & well commented. Thank you!

If you have some time, I have a question; I have what seems to be a clear-cut header file off a MoFlo XPD. I didn't think the necessary tweaks to the script were iffy in any sense. Still, I'm having trouble reconciling the parsed output with the proprietary MoFlo software's values. There are orders of magnitude differences.

Again, I don't think it's an issue with your script at all.. I'm just a little lost.

I don't want to spam the thread (any further, that is), so I will only PM you more details if you reply.

I was initially unable to get this code to read BD Influx FCS files created with Sortware software. I found that the mnemonic_separator is 'LF' (line feed) and the data precision is 'uint16'. I modified the get_mnemonic_value subfunction and the section that reads events. It now works well, although I think some header information is missing. Thanks for some very helpful code.

Avaneesh

This code can't be used to read Accuri C6 FCS3.0 files. I find that the mnemonic separator is '/'. Made the required changes in the code, works great.
Great code!

Quanyuan He

It works well, Thank you.

* *

*

Brian Harms

Overall nice file. One small error in the code: in line 181 (which converts log-scale FACS data to linear-scale data), the variable "fscdat" needs to be changed from uint16 to double in order for the code to work properly.

Ivan Cao-Berg

I find it is an excellent script. But I do have one comment.
In line 64 you can find the following code

fid = fopen(filename,'r','ieee-be');

If you are using a Windows, Matlab will not have a problem. If you are using Linux you should change the line to

fid = fopen(filename,'r','b');

Technically 'ieee-be' and 'b' are to suppose to be the same option. But I had problems and I fixed it that way.

Updates

2017.06.01

The code was modified to read FCS 3.1 file.

1.12

The FCS 3.0 standard enables the mixture of word lengths in the data, this upgrade modified the code according to. The linefeed (ASCII code 10) as
the mnemonic separator was also added.
Thanks for William Peria /Fred Hutchinson Cancer Researc

1.11

More accurate compensation correction, gain scaling and appropriate reading for large file size are added. Thanks for Rachel Finck; Garry Nolan's lab at Stanford University and Andrea Pagnani; Politecnico Torino, Human Genetics Foundation.

1.9

The fluorescence compensation has been implemeted into the code. Thanks for Rick Stanton, J. Craig Venter Institute, La Jolla, San Diego

1.8

The fluorescence compensation has been implemented into the code. Thanks for Rick Stanton, J. Craig Venter Institute, La Jolla, San Diego

1.6

Updated to read Luminex 100 data file. Thanks for Ofir Goldberger, Stanford University

1.5

Additional minor changes on the help section.

1.3

The help section of the m file was modified.

1.2

Updated to read the Partec CyFlow format file. Thanks for
Gavin A Price

1.1

Updated to read the Partec CyFlow format file. Thanks for
Gavin A Price

Refreshing the code according to the user comments and updating the description.

Repairing the code suggested by Brian Harms and Ivan Cao-Berg at the user reviews. Thanks the comments!

Updated to read Becton EPics DLM FCS2.0 and CyAn Summit FCS3.0 type list mode files

MATLAB Release
MATLAB 7.10 (R2010a)
Acknowledgements

Inspired: Ratiometric FRET, Gating-ML

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

» Watch video