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

Issue with accessing data in .fcs files #9

Closed JLautin closed 8 years ago

JLautin commented 8 years ago

Hello!

I have an issue regarding accessing the data segment of my .fcs files with FlowCytometryTools. While accessing the meta data and channels works fine, as soon as I try to access the data, for example through sample.data or transformations I receive the error

"ValueError: item #0 of names is of type unicode and not string"

However, the testfile works just fine. My files are from a Partec Cube 8, in the FCS3.0 format.

Im quite new to the python language, so any help is appreciated.

Regards JLautin

eyurtsev commented 8 years ago

Could you attach your FCS file, so I could debug?

Could you also confirm that you're using using python 2.7 rather than python >3?

At the command terminal you can type the following:

python --version
JLautin commented 8 years ago

I'm running Python 2.7.10 64-bit on a mac (os x Yosemite).

I've attached a zipped file below, since it didn't support to attach .fcs files. Hope it doesn't mess with your AV too much.

Regards JLautin LMO_bacteria.fcs.zip

eyurtsev commented 8 years ago

Thanks! I will take a look at this over the weekend.

On Thu, Dec 17, 2015 at 9:28 AM, JLautin notifications@github.com wrote:

I'm running Python 2.7.10 64-bit on a mac (os x Yosemite).

I've attached a zipped file below, since it didn't support to attach .fcs files. Hope it doesn't mess with your AV too much.

Regards JLautin LMO_bacteria.fcs.zip https://github.com/eyurtsev/FlowCytometryTools/files/65467/LMO_bacteria.fcs.zip

— Reply to this email directly or view it on GitHub https://github.com/eyurtsev/FlowCytometryTools/issues/9#issuecomment-165465201 .

Eugene Yurtsev

Personal Website: http://eyurtsev.mit.edu

eyurtsev commented 8 years ago

Looks like this is caused by an issue with numpy https://github.com/numpy/numpy/issues/2407

I'll try and release a fix within the next few days

If you need a fix quicker than that you can try and do the following:

1) locate the directory for the fcsparser package

import fcsparser
fcsparser.__path__

2) go to that directory and open api.py

3) Make the following change in the code:

@@ -353,7 +353,8 @@ class FCSParser(object):
             # values saved in mixed data formats
             dtype = ','.join(par_numeric_type_list)
             data = numpy.fromfile(file_handle, dtype=dtype, count=num_events)
-            data.dtype.names = self.get_channel_names()
+            names = self.get_channel_names()
+            data.dtype.names = [name.encode('ascii', errors='ignore') for name in names]
         else:
             # values saved in a single data format
             dtype = par_numeric_type_list[0]

where a (-) is remove, and a (+) is add

eyurtsev commented 8 years ago

Fixed in this commit: https://github.com/eyurtsev/fcsparser/commit/398b6b081da599c64ad7b49416bfd921c3a5a061

Please install the newest version of fcsparser (and FlowCytometryTools)

pip install fcsparser==0.1.2
pip install FlowCytometryTools==0.4.5
JLautin commented 8 years ago

Thank you for solving it!

/JLautin