fcsy is developed based on Data File Standard for Flow Cytometry Version FCS 3.1
$ pip install fcsy
for working with s3:
$ pip install fcsy[s3]
>>> import pandas as pd
>>> from fcsy import DataFrame
>>> data = [[1.0,2.0,3.0],[4.0,5.0,6.0]]
>>> columns = pd.MultiIndex.from_tuples(list(zip('abc', 'ABC')), names=["short", "long"])
>>> df = DataFrame(data, columns=columns)
>>> df
short a b c
long A B C
0 1.0 2.0 3.0
1 4.0 5.0 6.0
>>> df.to_fcs('sample.fcs')
>>> df = DataFrame.from_fcs('sample.fcs', channel_type='multi')
>>> df
short a b c
long A B C
0 1.0 2.0 3.0
1 4.0 5.0 6.0
Read fcs channels
>>> from fcsy import read_channels
>>> read_channels('sample.fcs', channel_type='multi')
MultiIndex([('a', 'A'),
('b', 'B'),
('c', 'C')],
names=['short', 'long'])
Rename channels
>>> from fcsy import rename_channels, read_channels
>>> rename_channels('sample.fcs', {'a': 'a_1', 'b': 'b_1'}, channel_type='short')
>>> read_channels('sample.fcs', channel_type='multi')
MultiIndex([('a_1', 'A'),
('b_1', 'B'),
( 'c', 'C')],
names=['short', 'long'])
>>> rename_channels('sample.fcs', {'A': 'A_1', 'C': 'C_1'}, channel_type='long')
>>> read_channels('sample.fcs', channel_type='multi')
MultiIndex([('a_1', 'A_1'),
('b_1', 'B'),
( 'c', 'C_1')],
names=['short', 'long'])
Read events number
>>> from fcsy import read_events_num
>>> read_events_num('sample.fcs')
2
All apis support s3 url with the format: s3://{bucket}/{key}
.
Write and read
>>> df.to_fcs('s3://sample-bucket/sample.fcs')
>>> df.from_fcs('s3://sample-bucket/sample.fcs', channel_type='multi')
short a b c
long A B C
0 1.0 2.0 3.0
1 4.0 5.0 6.0
Read channels
>>> read_channels('s3://sample-bucket/sample.fcs', channel_type='multi')
MultiIndex([('a', 'A'),
('b', 'B'),
('c', 'C')],
names=['short', 'long'])
Read events number
>>> read_events_num('s3://sample-bucket/sample.fcs')
2
The documentation is available on https://fcsy.readthedocs.io/
- Free software: MIT license
Consult the Releases page for fixes and enhancements of each version.