2
$\begingroup$

Do proper .fcs flow-cytometry files already have the gating hierarchy, so one may calculate cell-counts without extra work?

https://github.com/whitews/FlowKit/

# setup some file paths for our data
base_dir = "data/8_color_data_set"

sample_path = os.path.join(base_dir, "fcs_files")
wsp_path = os.path.join(base_dir, "8_color_ICS.wsp")
session = fk.Session(sample_path)
session.import_flowjo_workspace(wsp_path)
# that's it, let's see what sample groups were loaded
session.get_sample_groups()
['default', 'All Samples', 'DEN']
# I happen to know all the "real" analysis is within the "DEN" group
sample_group = 'DEN'
# and the sample that are included in the group
session.get_group_sample_ids(sample_group)
['101_DEN084Y5_15_E03_009_clean.fcs',
 '101_DEN084Y5_15_E01_008_clean.fcs',
 '101_DEN084Y5_15_E05_010_clean.fcs']
# so what is the gating hierarchy for this group
print(session.get_gate_hierarchy(sample_group))
root
╰── Time
    ╰── Singlets
        ╰── aAmine-
            ╰── CD3+
                ├── CD4+
                │   ├── CD107a+
                │   ├── IFNg+
                │   ├── IL2+
                │   ╰── TNFa+
                ╰── CD8+
                    ├── CD107a+
                    ├── IFNg+
                    ├── IL2+
                    ╰── TNFa+
# looks good, let's go ahead and analyze them (using verbose mode to see each gate as it's processed)
session.analyze_samples(sample_group, verbose=True)
#### Processing gates for 3 samples (multiprocessing is enabled - 3 cpus) ####
101_DEN084Y5_15_E03_009_clean.fcs: processing gate Time
101_DEN084Y5_15_E03_009_clean.fcs: processing gate Singlets
101_DEN084Y5_15_E03_009_clean.fcs: processing gate aAmine-
101_DEN084Y5_15_E01_008_clean.fcs: processing gate Time
101_DEN084Y5_15_E01_008_clean.fcs: processing gate Singlets
101_DEN084Y5_15_E01_008_clean.fcs: processing gate aAmine-
101_DEN084Y5_15_E05_010_clean.fcs: processing gate Time
101_DEN084Y5_15_E03_009_clean.fcs: processing gate CD3+
101_DEN084Y5_15_E05_010_clean.fcs: processing gate Singlets
101_DEN084Y5_15_E05_010_clean.fcs: processing gate aAmine-
101_DEN084Y5_15_E03_009_clean.fcs: processing gate CD4+
101_DEN084Y5_15_E01_008_clean.fcs: processing gate CD3+
101_DEN084Y5_15_E01_008_clean.fcs: processing gate CD4+
101_DEN084Y5_15_E05_010_clean.fcs: processing gate CD3+
101_DEN084Y5_15_E03_009_clean.fcs: processing gate CD8+
101_DEN084Y5_15_E05_010_clean.fcs: processing gate CD4+
101_DEN084Y5_15_E01_008_clean.fcs: processing gate CD8+
101_DEN084Y5_15_E03_009_clean.fcs: processing gate CD107a+
101_DEN084Y5_15_E05_010_clean.fcs: processing gate CD8+
101_DEN084Y5_15_E01_008_clean.fcs: processing gate CD107a+
101_DEN084Y5_15_E03_009_clean.fcs: processing gate IFNg+
101_DEN084Y5_15_E05_010_clean.fcs: processing gate CD107a+
101_DEN084Y5_15_E01_008_clean.fcs: processing gate IFNg+
101_DEN084Y5_15_E03_009_clean.fcs: processing gate IL2+
101_DEN084Y5_15_E05_010_clean.fcs: processing gate IFNg+
101_DEN084Y5_15_E01_008_clean.fcs: processing gate IL2+
101_DEN084Y5_15_E03_009_clean.fcs: processing gate TNFa+
101_DEN084Y5_15_E05_010_clean.fcs: processing gate IL2+
101_DEN084Y5_15_E01_008_clean.fcs: processing gate TNFa+
101_DEN084Y5_15_E03_009_clean.fcs: processing gate CD107a+
101_DEN084Y5_15_E05_010_clean.fcs: processing gate TNFa+
101_DEN084Y5_15_E01_008_clean.fcs: processing gate CD107a+
101_DEN084Y5_15_E03_009_clean.fcs: processing gate IFNg+
101_DEN084Y5_15_E05_010_clean.fcs: processing gate CD107a+
101_DEN084Y5_15_E01_008_clean.fcs: processing gate IFNg+
101_DEN084Y5_15_E03_009_clean.fcs: processing gate IL2+
101_DEN084Y5_15_E05_010_clean.fcs: processing gate IFNg+
101_DEN084Y5_15_E01_008_clean.fcs: processing gate IL2+
101_DEN084Y5_15_E03_009_clean.fcs: processing gate TNFa+
101_DEN084Y5_15_E05_010_clean.fcs: processing gate IL2+
101_DEN084Y5_15_E01_008_clean.fcs: processing gate TNFa+
101_DEN084Y5_15_E05_010_clean.fcs: processing gate TNFa+
# and a look a the results
session.get_group_report(sample_group)
sample  gate_path   gate_name   gate_type   quadrant_parent parent  count   absolute_percent    relative_percent    level
0   101_DEN084Y5_15_E03_009_clean.fcs   (root,) Time    RectangleGate   None    None    283968  99.999648   99.999648   1
1   101_DEN084Y5_15_E03_009_clean.fcs   (root, Time)    Singlets    PolygonGate None    Time    236780  83.382341   83.382635   2
2   101_DEN084Y5_15_E03_009_clean.fcs   (root, Time, Singlets)  aAmine- PolygonGate None    Singlets    161823  56.986150   68.343188   3
3   101_DEN084Y5_15_E03_009_clean.fcs   (root, Time, Singlets, aAmine-) CD3+    PolygonGate None    aAmine- 132200  46.554377   81.694197   4
4   101_DEN084Y5_15_E03_009_clean.fcs   (root, Time, Singlets, aAmine-, CD3+)   CD4+    PolygonGate None    CD3+    81855   28.825330   61.917549   5
5   101_DEN084Y5_15_E03_009_clean.fcs   (root, Time, Singlets, aAmine-, CD3+)   CD8+    PolygonGate None    CD3+    46965   16.538777   35.525719   5
6   101_DEN084Y5_15_E03_009_clean.fcs   (root, Time, Singlets, aAmine-, CD3+, CD4+) CD107a+ RectangleGate   None    CD4+    59  0.020777    0.072079    6
10  101_DEN084Y5_15_E03_009_clean.fcs   (root, Time, Singlets, aAmine-, CD3+, CD8+) CD107a+ RectangleGate   None    CD8+    814 0.286651    1.733206    6
7   101_DEN084Y5_15_E03_009_clean.fcs   (root, Time, Singlets, aAmine-, CD3+, CD4+) IFNg+   RectangleGate   None    CD4+    598 0.210586    0.730560    6
11  101_DEN084Y5_15_E03_009_clean.fcs   (root, Time, Singlets, aAmine-, CD3+, CD8+) IFNg+   RectangleGate   None    CD8+    1224    0.431033    2.606196    6
8   101_DEN084Y5_15_E03_009_clean.fcs   (root, Time, Singlets, aAmine-, CD3+, CD4+) IL2+    RectangleGate   None    CD4+    64  0.022538    0.078187    6
12  101_DEN084Y5_15_E03_009_clean.fcs   (root, Time, Singlets, aAmine-, CD3+, CD8+) IL2+    RectangleGate   None    CD8+    127 0.044723    0.270414    6
9   101_DEN084Y5_15_E03_009_clean.fcs   (root, Time, Singlets, aAmine-, CD3+, CD4+) TNFa+   RectangleGate   None    CD4+    288 0.101420    0.351842    6
13  101_DEN084Y5_15_E03_009_clean.fcs   (root, Time, Singlets, aAmine-, CD3+, CD8+) TNFa+   RectangleGate   None    CD8+    821 0.289116    1.748110    6
0   101_DEN084Y5_15_E01_008_clean.fcs   (root,) Time    RectangleGate   None    None    290166  99.997932   99.997932   1
1   101_DEN084Y5_15_E01_008_clean.fcs   (root, Time)    Singlets    PolygonGate None    Time    239001  82.365287   82.366990   2
2   101_DEN084Y5_15_E01_008_clean.fcs   (root, Time, Singlets)  aAmine- PolygonGate None    Singlets    164655  56.743931   68.893017   3
3   101_DEN084Y5_15_E01_008_clean.fcs   (root, Time, Singlets, aAmine-) CD3+    PolygonGate None    aAmine- 133670  46.065782   81.181865   4
4   101_DEN084Y5_15_E01_008_clean.fcs   (root, Time, Singlets, aAmine-, CD3+)   CD4+    PolygonGate None    CD3+    82484   28.425899   61.707189   5
5   101_DEN084Y5_15_E01_008_clean.fcs   (root, Time, Singlets, aAmine-, CD3+)   CD8+    PolygonGate None    CD3+    47165   16.254153   35.284656   5
6   101_DEN084Y5_15_E01_008_clean.fcs   (root, Time, Singlets, aAmine-, CD3+, CD4+) CD107a+ RectangleGate   None    CD4+    68  0.023434    0.082440    6
10  101_DEN084Y5_15_E01_008_clean.fcs   (root, Time, Singlets, aAmine-, CD3+, CD8+) CD107a+ RectangleGate   None    CD8+    73  0.025157    0.154776    6
7   101_DEN084Y5_15_E01_008_clean.fcs   (root, Time, Singlets, aAmine-, CD3+, CD4+) IFNg+   RectangleGate   None    CD4+    4   0.001378    0.004849    6
11  101_DEN084Y5_15_E01_008_clean.fcs   (root, Time, Singlets, aAmine-, CD3+, CD8+) IFNg+   RectangleGate   None    CD8+    2   0.000689    0.004240    6
8   101_DEN084Y5_15_E01_008_clean.fcs   (root, Time, Singlets, aAmine-, CD3+, CD4+) IL2+    RectangleGate   None    CD4+    6   0.002068    0.007274    6
12  101_DEN084Y5_15_E01_008_clean.fcs   (root, Time, Singlets, aAmine-, CD3+, CD8+) IL2+    RectangleGate   None    CD8+    10  0.003446    0.021202    6
9   101_DEN084Y5_15_E01_008_clean.fcs   (root, Time, Singlets, aAmine-, CD3+, CD4+) TNFa+   RectangleGate   None    CD4+    21  0.007237    0.025459    6
13  101_DEN084Y5_15_E01_008_clean.fcs   (root, Time, Singlets, aAmine-, CD3+, CD8+) TNFa+   RectangleGate   None    CD8+    8   0.002757    0.016962    6
0   101_DEN084Y5_15_E05_010_clean.fcs   (root,) Time    RectangleGate   None    None    284846  99.844369   99.844369   1
1   101_DEN084Y5_15_E05_010_clean.fcs   (root, Time)    Singlets    PolygonGate None    Time    235331  82.488345   82.616923   2
2   101_DEN084Y5_15_E05_010_clean.fcs   (root, Time, Singlets)  aAmine- PolygonGate None    Singlets    160955  56.418031   68.395154   3
3   101_DEN084Y5_15_E05_010_clean.fcs   (root, Time, Singlets, aAmine-) CD3+    PolygonGate None    aAmine- 131305  46.025097   81.578702   4
4   101_DEN084Y5_15_E05_010_clean.fcs   (root, Time, Singlets, aAmine-, CD3+)   CD4+    PolygonGate None    CD3+    81135   28.439483   61.791249   5
5   101_DEN084Y5_15_E05_010_clean.fcs   (root, Time, Singlets, aAmine-, CD3+)   CD8+    PolygonGate None    CD3+    46546   16.315328   35.448764   5
6   101_DEN084Y5_15_E05_010_clean.fcs   (root, Time, Singlets, aAmine-, CD3+, CD4+) CD107a+ RectangleGate   None    CD4+    70  0.024536    0.086276    6
10  101_DEN084Y5_15_E05_010_clean.fcs   (root, Time, Singlets, aAmine-, CD3+, CD8+) CD107a+ RectangleGate   None    CD8+    306 0.107259    0.657414    6
7   101_DEN084Y5_15_E05_010_clean.fcs   (root, Time, Singlets, aAmine-, CD3+, CD4+) IFNg+   RectangleGate   None    CD4+    9   0.003155    0.011093    6
11  101_DEN084Y5_15_E05_010_clean.fcs   (root, Time, Singlets, aAmine-, CD3+, CD8+) IFNg+   RectangleGate   None    CD8+    348 0.121981    0.747647    6
8   101_DEN084Y5_15_E05_010_clean.fcs   (root, Time, Singlets, aAmine-, CD3+, CD4+) IL2+    RectangleGate   None    CD4+    8   0.002804    0.009860    6
12  101_DEN084Y5_15_E05_010_clean.fcs   (root, Time, Singlets, aAmine-, CD3+, CD8+) IL2+    RectangleGate   None    CD8+    65  0.022784    0.139647    6
9   101_DEN084Y5_15_E05_010_clean.fcs   (root, Time, Singlets, aAmine-, CD3+, CD4+) TNFa+   RectangleGate   None    CD4+    28  0.009815    0.034510    6
13  101_DEN084Y5_15_E05_010_clean.fcs   (root, Time, Singlets, aAmine-, CD3+, CD8+) TNFa+   RectangleGate   None    CD8+    336 0.117775    0.721867    6
$\endgroup$

1 Answer 1

0
$\begingroup$

The flow cytometry standard (FCS) file specification does not include gating information. There is a separate specification, GatingML, that does provide gating definitions, though few applications adhere strictly to that standard. As the author of FlowKit, we wanted to provide a tool for the Python bioinformatics community that reads and creates valid GatingML documents for FCS data.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.