Read FCS files#

In this notebook, we load an fcs file into the anndata format, move the forward scatter (FCS) and sideward scatter (SSC) information to the .obs section of the anndata file and perform compensation on the data.

import readfcs
import pytometry as pm

Read data from readfcs package example.

path_data = readfcs.datasets.example()
adata = pm.io.read_fcs(path_data)
adata
AnnData object with n_obs × n_vars = 65016 × 16
    var: 'channel', 'marker'
    uns: 'meta'
adata.var
channel marker
FSC-A FSC-A
FSC-H FSC-H
SSC-A SSC-A
KI67 B515-A KI67
CD3 R780-A CD3
CD28 R710-A CD28
CD45RO R660-A CD45RO
CD8 V800-A CD8
CD4 V655-A CD4
CD57 V585-A CD57
VIVID / CD14 V450-A VIVID / CD14
CCR5 G780-A CCR5
CD19 G710-A CD19
CD27 G660-A CD27
CCR7 G610-A CCR7
CD127 G560-A CD127

The .var section of the AnnData object contains the channel information. We set the marker names as var_names by default. In addition, we save the channel information in the "channel" column.

adata.var
channel marker
FSC-A FSC-A
FSC-H FSC-H
SSC-A SSC-A
KI67 B515-A KI67
CD3 R780-A CD3
CD28 R710-A CD28
CD45RO R660-A CD45RO
CD8 V800-A CD8
CD4 V655-A CD4
CD57 V585-A CD57
VIVID / CD14 V450-A VIVID / CD14
CCR5 G780-A CCR5
CD19 G710-A CD19
CD27 G660-A CD27
CCR7 G610-A CCR7
CD127 G560-A CD127

The .uns['meta'] section contains the header information from the FCS file.

adata.uns["meta"]
{'filename': '100715.fcs',
 'sys': 'Windows XP 5.1',
 'total_events': 65016,
 'tube_name': 'Tube_025',
 'exp_name': '070717_AB02_tb',
 'cytometer': 'Main Aria (FACSAria)',
 'creator': 'LYSYS',
 'operator': 'Administrator',
 'cst_pass': False,
 'threshold': {'channel': 'FSC', 'threshold': '27000'},
 'processing_date': '2007-07-17T15:38:06',
 'spill':                   KI67       CD3      CD28    CD45RO       CD8       CD4  \
 KI67          1.000000  0.000000  0.000000  0.000088  0.000249  0.000645   
 CD3           0.000000  1.000000  0.071188  0.148448  0.338903  0.009717   
 CD28          0.000000  0.331405  1.000000  0.061965  0.120979  0.004053   
 CD45RO        0.000000  0.088621  0.389424  1.000000  0.029759  0.065553   
 CD8           0.000000  0.136618  0.010757  0.000000  1.000000  0.000156   
 CD4           0.000000  0.000124  0.019463  0.218206  0.004953  1.000000   
 CD57          0.000000  0.000000  0.000000  0.000000  0.001056  0.002287   
 VIVID / CD14  0.000000  0.000000  0.000000  0.000000  0.000000  0.008118   
 CCR5          0.003122  0.008526  0.001024  0.001163  0.125401  0.018142   
 CD19          0.002015  0.069645  0.194715  0.001008  0.151611  0.001270   
 CD27          0.001685  0.054340  0.277852  0.343008  0.061753  0.077523   
 CCR7          0.000000  0.008713  0.048213  0.073190  0.150563  0.386293   
 CD127         0.001684  0.000000  0.000000  0.000095  0.003463  0.015712   
 
                   CD57  VIVID / CD14      CCR5      CD19      CD27      CCR7  \
 KI67          0.007198           0.0  0.000000  0.000131  0.000067  0.000582   
 CD3           0.000000           0.0  0.301380  0.007478  0.012354  0.000000   
 CD28          0.000000           0.0  0.109117  0.100314  0.005832  0.000000   
 CD45RO        0.000000           0.0  0.031294  0.039306  0.091375  0.000396   
 CD8           0.000000           0.0  0.483235  0.014858  0.000000  0.000000   
 CD4           0.003583           0.0  0.001311  0.029646  0.408902  0.006506   
 CD57          1.000000           0.0  0.000389  0.000194  0.000000  0.062551   
 VIVID / CD14  0.170066           1.0  0.000000  0.000000  0.000000  0.000000   
 CCR5          0.193646           0.0  1.000000  0.066898  0.161456  0.286823   
 CD19          0.007133           0.0  1.150032  1.000000  0.016077  0.014674   
 CD27          0.004263           0.0  0.497488  0.743923  1.000000  0.010329   
 CCR7          0.101896           0.0  0.370277  0.613490  1.218024  1.000000   
 CD127         0.174122           0.0  0.023802  0.049474  0.132511  0.239216   
 
                  CD127  
 KI67          0.002520  
 CD3           0.000000  
 CD28          0.000000  
 CD45RO        0.000057  
 CD8           0.000000  
 CD4           0.000119  
 CD57          0.132484  
 VIVID / CD14  0.000000  
 CCR5          1.238037  
 CD19          0.055352  
 CD27          0.037635  
 CCR7          0.065211  
 CD127         1.000000  }