eyurtsev / FlowCytometryTools

A python package for visualization and analysis of high-throughput flow cytometry data
https://eyurtsev.github.io/FlowCytometryTools/
MIT License
113 stars 46 forks source link

Unable to load fcs files #12

Closed ghost closed 7 years ago

ghost commented 8 years ago

I'm trying to use FCMeasurement to read binary fcs files, but I get the following error:

File "/usr/local/lib/python2.7/dist-packages/fcsparser/api.py", line 178, in read_text raise ParserFeatureNotImplementedError(msg) fcsparser.api.ParserFeatureNotImplementedError: The first two characters were: u'\$'. The last two characters were: u' C' Parser expects the same delimiter character in beginning and end of TEXT segment

Sorry if it's a basic question; first time using FC data on python. Thanks, CFBAN

eyurtsev commented 8 years ago

Likely this means that either the fcs file is corrupt or else the software that generated it did not follow the FCS specification. Could you attach the binary file, so I can take a look at it?

ghost commented 8 years ago

Sure. The data is from Pe'er's lab at Columbia and it's available here: http://www.c2b2.columbia.edu/danapeerlab/html/wanderlust-data.html I was able to open it with flowCore on R, but I strongly prefer working on python. Thanks!

eyurtsev commented 8 years ago

These files do not seem to follow the correct specification for FCS files. The flowCore parser probably is a bit more flexible and knows how to interpret slight mistakes in the specification.

Here are 2 solutions:

  1. If flowCore can export fcs files, then you could try importing it with flowCore and then exporting it. This might fix the specification.
  2. You may be able to fix the fcs files manually:

For example: http://www.c2b2.columbia.edu/danapeerlab/html/CYT/data/wanderlust/Bendall%20et%20al%20Cell%20Sample%20B_IL7.fcs

If you open this file with a text editor, the first line says the following:

FCS3.0 100 3893 3893 737093 0 0

Decrease the first 3893 by 1 to 3892.

To produce:

FCS3.0 100 3892 3893 737093 0 0

Be careful to only replace characters (don't add or delete anything even whitespace).

3892 = Denotes the end of the section in the file that describes all the parameters of the measurement 3893 = Denotes the beginning of the section in the file that contains all the numeric data.

These two numbers are supposed to be different.

For the other FCS files, you should be able to simply decrease the first of these numbers by 1, and the file should load.

I hope this helps.

Alternatively, you could try to fix this more properly and file a pull request here: https://github.com/eyurtsev/fcsparser/pulls

ghost commented 8 years ago

Exporting the data from flowCore worked. Thank you!

tpaixao commented 4 years ago

Hi, I have a similar problem but changing those numbers does not fix it. I get:

ParserFeatureNotImplementedError: The first two characters were:  $B. The last two characters were: up
Parser expects the same delimiter character in beginning and end of TEXT segment

the file is attached... BV786(Cells).zip

thanks for any help you may provide!

eyurtsev commented 4 years ago

@tpaixao -- according to the exception the FCS file doesn't follow standard FCS specification. You'll need to export it into a compliant FCS format using the flow cytometer's software.

tpaixao commented 4 years ago

Thanks. Yes, I realized that. I ended up loading them in flowCore (a R package from BioConductor) and saving them back and after that FlowCytometerTools reads them just fine...

Eugene Yurtsev wrote:

@tpaixao https://github.com/tpaixao -- according to the exception the FCS file doesn't follow standard FCS specification. You'll need to export it into a compliant FCS format using the flow cytometer's software.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/eyurtsev/FlowCytometryTools/issues/12?email_source=notifications&email_token=ADCRO3IYXGKQJ3OWS2D7FJDQVGNY5A5CNFSM4CAPXIE2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEE76ADQ#issuecomment-557834254,

or unsubscribe https://github.com/notifications/unsubscribe-auth/ADCRO3J73SEHELIPNAU2TK3QVGNY5ANCNFSM4CAPXIEQ.