The Panel object#
The panel has to be provided as a table.
There are two obligatory columns: ‘fcs_colname’ and ‘antigens’.
‘fcs_colname’ corresponds to the channel names as written in the .fcs file (e.g. BV421-A). ‘antigens’ contains a list of the markers used (e.g. CD3).
Here, we read in an example panel as a normal dataframe via the pandas library:
[1]:
import pandas as pd
panel_file = pd.read_csv("../Tutorials/spectral_dataset/panel.txt", sep = "\t")
panel_file.head()
[1]:
| fcs_colname | antigens | |
|---|---|---|
| 0 | FJComp-BUV395-A | CD38 |
| 1 | FJComp-BUV496-A | NKG2C_(CD159c) |
| 2 | FJComp-BUV563-A | CD3 |
| 3 | FJComp-BUV615-A | CD16 |
| 4 | FJComp-BUV661-A | CD161 |
Create panel from a pandas dataframe#
In order to create a FACSPy-readable Panel object, we use the fp.dt.Panel class where ‘fp’ is the alias for FACSPy and ‘dt’ stands for dataset.
In this scenario, we use the panel table that we read via the pandas library from above. We pass the table via the panel parameter.
A Panel object is created with 28 channels.
[2]:
import FACSPy as fp
[3]:
panel = fp.dt.Panel(panel = panel_file)
panel
[3]:
Panel(28 channels, loaded as provided dataframe)
Note that the prefixes (‘FJComp’) from the original table have been removed:
[4]:
panel.to_df().head()
[4]:
| fcs_colname | antigens | |
|---|---|---|
| 0 | BUV395-A | CD38 |
| 1 | BUV496-A | NKG2C_(CD159c) |
| 2 | BUV563-A | CD3 |
| 3 | BUV615-A | CD16 |
| 4 | BUV661-A | CD161 |
Create panel from a .csv file#
We can also read the panel table directly from the hard drive. In order to do that, we pass the path to the fp.dt.Panel class. Any file format that can be accessed by pd.read_csv() can be used.
[5]:
panel = fp.dt.Panel("../Tutorials/spectral_dataset/panel.txt")
panel
[5]:
Panel(28 channels, loaded as provided file)
Access the panel table#
The underlying table is stored in the .dataframe attribute and can be accessed and modified.
Use the method .to_df() to return the underlying table or directly access the table via .dataframe as shown here.
[6]:
df = panel.dataframe
df.head()
[6]:
| fcs_colname | antigens | |
|---|---|---|
| 0 | BUV395-A | CD38 |
| 1 | BUV496-A | NKG2C_(CD159c) |
| 2 | BUV563-A | CD3 |
| 3 | BUV615-A | CD16 |
| 4 | BUV661-A | CD161 |
[7]:
df = panel.to_df()
df.head()
[7]:
| fcs_colname | antigens | |
|---|---|---|
| 0 | BUV395-A | CD38 |
| 1 | BUV496-A | NKG2C_(CD159c) |
| 2 | BUV563-A | CD3 |
| 3 | BUV615-A | CD16 |
| 4 | BUV661-A | CD161 |
Access the channels#
In order to retrieve the channels stored in the Panel object, use the .get_channels() method. For antigens, use the .get_antigens() method.
[8]:
panel.get_channels()
[8]:
['BUV395-A',
'BUV496-A',
'BUV563-A',
'BUV615-A',
'BUV661-A',
'BUV737-A',
'BUV805-A',
'BV421-A',
'V450-A',
'BV480-A',
'BV510-A',
'BV570-A',
'BV605-A',
'BV650-A',
'BV711-A',
'BV750-A',
'BV786-A',
'FITC-A',
'Alexa Fluor 532-A',
'BB700-A',
'PerCP-Cy5.5-A',
'PE-A',
'PE-Dazzle594-A',
'PE-Cy7-A',
'Alexa Fluor 647-A',
'Alexa Fluor 700-A',
'Zombie NIR-A',
'APC-Fire 750-A']
[9]:
panel.get_antigens()
[9]:
['CD38',
'NKG2C_(CD159c)',
'CD3',
'CD16',
'CD161',
'CD32',
'CD56',
'41BB_(CD137)',
'CD4',
'CD64',
'KLRG1',
'CD45',
'HLA_DR',
'CD19',
'NKp44',
'CD69',
'TIGIT',
'CD57',
'CD8',
'CD14',
'CD27',
'NKG2A_(CD159a)',
'CTLA-4_(CD152)',
'TRAIL_(CD253)',
'PD-1_(CD279) ',
'CD18',
'Zombie_NIR',
'CD66b']
Rename a channel#
In order to rename a channel, we use the .rename_channel() method. This will replace the given name in ‘fcs_colname’.
[10]:
panel.rename_channel("BUV395-A", "BUV395")
panel.dataframe.head()
[10]:
| fcs_colname | antigens | |
|---|---|---|
| 0 | BUV395 | CD38 |
| 1 | BUV496-A | NKG2C_(CD159c) |
| 2 | BUV563-A | CD3 |
| 3 | BUV615-A | CD16 |
| 4 | BUV661-A | CD161 |
Rename an antigen#
In order to rename an antigen, we use the .rename_antigen() method. This will replace the name in ‘antigens’
[11]:
panel.rename_channel("CD38", "cyclic ADP ribose hydrolase")
panel.dataframe.head()
[11]:
| fcs_colname | antigens | |
|---|---|---|
| 0 | BUV395 | CD38 |
| 1 | BUV496-A | NKG2C_(CD159c) |
| 2 | BUV563-A | CD3 |
| 3 | BUV615-A | CD16 |
| 4 | BUV661-A | CD161 |
Write the panel to the hard drive#
In order to write the panel table to the hard drive, use the .write() method, specifying a file-path with the file name.
[12]:
panel.write("../Tutorials/spectral_dataset/vignette_panel.csv")