-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearch.json
128 lines (128 loc) · 34.1 KB
/
search.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
[
{
"objectID": "index.html",
"href": "index.html",
"title": "Flow Cytometry Analysis using R - cytoverse",
"section": "",
"text": "The cytoverse is a collection of open source R based tools developed by the founders of Ozette Technologies which facilitate programmatic analysis of flow cytometry data.\nA number of packages make up the cytoverse. flowCore, flowWorkspace, openCyto, and ggcyto make up the core of the cytoverse. These packages are, by and large, powerful and sufficient to create robust and reproducible analysis workflows for flow cytometry data. Additional available packages such as flowClust, flowStats, CytoQC, or CytoML can be further utilized for niche applications including, model based clustering of flow cytometry data, QC and standardization of set of FCS files, even parsing of workspaces from FlowJo or cytobank.\n\n\nThe aim of this workshop is to empower flow cytometry users and analysts towards reproducible and programmatic analysis.\nBy the end of this workshop, the attendees will be able to\n\nImport flow cytometry data\nUnderstand the difference between uncompensated, compensated, and transformed data,\nIdentify sub-populations by manual or semi-automated gating of markers,\nAccess and extract expression matrix from a gated data,\nBe aware of csv-templating of Gating to perform large-scale gating\nIdentify and generate important plots to assess the data and quality,\nGenerate plots summarizing the expression of markers and abundance of various sub-populations\n\n\n\n\n\n\n\nActivity\nTime\n\n\n\n\nIntroduction and use of docker container\n– minutes\n\n\nBasics of working with FCS files\n30 minutes\n\n\nSpillover, Transformation\n25 minutes\n\n\nGating Cells in the cytoverse\n40 minutes\n\n\nVisualization using ggcyto\n– minutes\n\n\nReporting\n– minutes\n\n\nWrap-up\n10 minutes\n\n\n\n\n\n\n\nSome R knowledge\nBasic flow cytometry knowledge\n\n\n\n\nFor this workshop, we will use subset of a public data set: FR-FCM-Z5PC that can be found in flowrepository.org. The dataset was published in the following paper."
},
{
"objectID": "index.html#learning-goals",
"href": "index.html#learning-goals",
"title": "Flow Cytometry Analysis using R - cytoverse",
"section": "",
"text": "The aim of this workshop is to empower flow cytometry users and analysts towards reproducible and programmatic analysis.\nBy the end of this workshop, the attendees will be able to\n\nImport flow cytometry data\nUnderstand the difference between uncompensated, compensated, and transformed data,\nIdentify sub-populations by manual or semi-automated gating of markers,\nAccess and extract expression matrix from a gated data,\nBe aware of csv-templating of Gating to perform large-scale gating\nIdentify and generate important plots to assess the data and quality,\nGenerate plots summarizing the expression of markers and abundance of various sub-populations"
},
{
"objectID": "index.html#workshop-schedule",
"href": "index.html#workshop-schedule",
"title": "Flow Cytometry Analysis using R - cytoverse",
"section": "",
"text": "Activity\nTime\n\n\n\n\nIntroduction and use of docker container\n– minutes\n\n\nBasics of working with FCS files\n30 minutes\n\n\nSpillover, Transformation\n25 minutes\n\n\nGating Cells in the cytoverse\n40 minutes\n\n\nVisualization using ggcyto\n– minutes\n\n\nReporting\n– minutes\n\n\nWrap-up\n10 minutes"
},
{
"objectID": "index.html#prerequisitesassumptions",
"href": "index.html#prerequisitesassumptions",
"title": "Flow Cytometry Analysis using R - cytoverse",
"section": "",
"text": "Some R knowledge\nBasic flow cytometry knowledge"
},
{
"objectID": "index.html#data",
"href": "index.html#data",
"title": "Flow Cytometry Analysis using R - cytoverse",
"section": "",
"text": "For this workshop, we will use subset of a public data set: FR-FCM-Z5PC that can be found in flowrepository.org. The dataset was published in the following paper."
},
{
"objectID": "vignettes/1_Import_fcs.html",
"href": "vignettes/1_Import_fcs.html",
"title": "Basics of working with FCS files",
"section": "",
"text": "Flow cytometry data (regardless of the type of instrument used) is generally saved as a .fcs file. This file is populated with raw data, fluorescence intensity (for optics based technologies) and abundance (for mass cytrometry), as well as various metadata including: user id, instrument id, dynamic range of instrument, etc. It is important to be able to interact with and manipulate the .fcs file as it gives the users/analysts fine grain control."
},
{
"objectID": "vignettes/1_Import_fcs.html#introduction",
"href": "vignettes/1_Import_fcs.html#introduction",
"title": "Basics of working with FCS files",
"section": "",
"text": "Flow cytometry data (regardless of the type of instrument used) is generally saved as a .fcs file. This file is populated with raw data, fluorescence intensity (for optics based technologies) and abundance (for mass cytrometry), as well as various metadata including: user id, instrument id, dynamic range of instrument, etc. It is important to be able to interact with and manipulate the .fcs file as it gives the users/analysts fine grain control."
},
{
"objectID": "vignettes/1_Import_fcs.html#installingloading-required-libraries",
"href": "vignettes/1_Import_fcs.html#installingloading-required-libraries",
"title": "Basics of working with FCS files",
"section": "Installing/loading required libraries",
"text": "Installing/loading required libraries\nYou can install all the cytoverse packages as follows:\n\ninstall.packages(\"BiocManager\")\nBiocManager::install(\"cytolib\")\nBiocManager::install(\"flowCore\")\nBiocManager::install(\"flowWorkspace\")\nBiocManager::install(\"ggcyto\")\nBiocManager::install(\"openCyto\")\nBiocManager::install(\"flowStats\")\nBiocManager::install(\"CytoML\")\n\nFor the moment, we only need to load flowCore and flowWorkspace.\n\nlibrary(flowCore)\nlibrary(flowWorkspace)"
},
{
"objectID": "vignettes/1_Import_fcs.html#flowrepository-workshop-data",
"href": "vignettes/1_Import_fcs.html#flowrepository-workshop-data",
"title": "Basics of working with FCS files",
"section": "FlowRepository workshop data",
"text": "FlowRepository workshop data\nIn this workshop we will demonstrate the use of cytoverse packages to analyse publicly available datasets hosted on FlowRepository. The first dataset FR-FCM-Z5PC contains FCS files from a study assessing the post recovery immune phenotypes from patients infected with COVID-19. We are using a subset of the FCS files. The second dataset FR-FCM-ZZ36 contains FCS files for OMIP-018, a study designed to phenotype T cells for expression of various chemokine receptors.\nThe data required for this workshop, including subsets extracted from the FlowRepository datasets are made available inside vignettes/data folder."
},
{
"objectID": "vignettes/1_Import_fcs.html#cytoverse-data-structures-for-.fcs-files",
"href": "vignettes/1_Import_fcs.html#cytoverse-data-structures-for-.fcs-files",
"title": "Basics of working with FCS files",
"section": "cytoverse data structures for .fcs files",
"text": "cytoverse data structures for .fcs files\nThere are four main data structures that represent flow cytometry data in cytoverse: cytoframe, cytoset, GatingHierarchy and GatingSet.\n\ncytoframe: a single .fcs file,\ncytoset: a list like object that can store multiple .fcs files,\nGatingHierarchy: a list like object that allows building and attaching gates and filter to a cytoframe\nGatingSet: a list like object that allows building and attaching gates and filter to a cytoset\n\nSome of these have overlapping functionality, and we’ll eventually explain when you would prefer one data structure to another as we continue through this workshop.\nNote:\n\nThere are additional legacy data structures called flowFrame and flowSet in cytoverse that are analogous to cytoframe and cytoset in function. We will not use these data structures in this workshop."
},
{
"objectID": "vignettes/1_Import_fcs.html#reading-in-fcs-files",
"href": "vignettes/1_Import_fcs.html#reading-in-fcs-files",
"title": "Basics of working with FCS files",
"section": "Reading in FCS files",
"text": "Reading in FCS files\nThere are two preferred approaches to read in .fcs file(s) into R:\n\nRead in individual .fcs files as cytoframe,\nRead in a set of .fcs files as cytoset,\n\n(Additionally, you can read a workspace generated with another tool, such as FlowJo, using the CytoML package.)\nThe function load_cytoframe_from_fcs is used to read in individual file as a cytoframe object.\n\ncf <- load_cytoframe_from_fcs(\"data/fcs-data/4000_BDC-CR1.fcs\")\n\n# a cytoframe object\ncf\n\ncytoframe object '4000_BDC-CR1.fcs'\nwith 912254 cells and 33 observables:\n name desc range minRange maxRange\n$P1 FSC-A NA 262143 0.000 262143\n$P2 FSC-H NA 262143 0.000 262143\n$P3 SSC-A NA 262143 0.000 262143\n$P4 B515-A CADM1 FITC 262143 -110.386 262143\n$P5 B610-A CD141 BB630 262143 -111.000 262143\n... ... ... ... ... ...\n$P29 V710-A CD86 BV711 262143 -111 262143\n$P30 V750-A CX3CR1 BV750 262143 -111 262143\n$P31 V785-A HLA-DR BV786 262143 -111 262143\n$P32 remove_from_FS_FM QC 262143 0 262143\n$P33 Time NA 92 0 92\n327 keywords are stored in the 'description' slot\nrow names(0):\n\n\nThe cytoframe object has 3 slots where various data is stored.\n\nexprs(cf) stores the expression matrix (i.e. the collected data),\nparameters(cf) stores information pertaining to channels: channel name, marker description,and data ranges as an AnnotatedDataFrame,\nkeyword(cf) stores additional information extracted from the .fcs file header. The file header follow ISAC guidelines. Visit here for more information."
},
{
"objectID": "vignettes/1_Import_fcs.html#working-with-cytoframe-objects",
"href": "vignettes/1_Import_fcs.html#working-with-cytoframe-objects",
"title": "Basics of working with FCS files",
"section": "Working with cytoframe objects",
"text": "Working with cytoframe objects\nA few useful definitions that help us get oriented with the underlying data in the cytoframe object.\n\nChannels: Instrument derived labels of various parameters that were measured. Channels are the column names of the cytoframe. Any data generated from the same instrument will have the same (similar) Channel names.\nMarkers: User provided labels for various parameters that were measured. For example: Channel name: B710-A, Marker name: CD3 (in cf). Marker names are set by the users and may not be unique across experiments/users. Not all channels are markers – some are physical parameters such as the forward scatter or side scatter. These channels will have their marker names set to NA.\nExpression: Measured values. A matrix where every row is an event (frequently a cell) and every column is a channel.\n\nWorking with a cytoframe object is very similar to working with a data.frame in R, where a “row” is a cell and a “column” is a channel. In particular, subsetting with square brackets cf[i,j] or cf$ works as you might hope. An important difference, however, is that unlike most other functions in R, the subset and assignment operations DO NOT create a new copy of the data but simply provides an updated “view” of the data. Because this is quite unlike the rest of R, we will perseverate on this point.\n\nExamples\n\nAccessing parameter summary and metadata\nSummary of measured parameters.\n\n# parameters\nparameters(cf) |> pData() # show as a dataframe\n\n name desc range minRange maxRange\n$P1 FSC-A <NA> 262143 0.00000 262143\n$P2 FSC-H <NA> 262143 0.00000 262143\n$P3 SSC-A <NA> 262143 0.00000 262143\n$P4 B515-A CADM1 FITC 262143 -110.38593 262143\n$P5 B610-A CD141 BB630 262143 -111.00000 262143\n$P6 B660-A CD123 BB660 262143 -111.00000 262143\n$P7 B710-A FcER1a BB700 262143 -111.00000 262143\n$P8 B780-A IgD BB790 262143 -111.00000 262143\n$P9 G575-A IFNAR2 PE 262143 -111.00000 262143\n$P10 G610-A CD88 PE-Dazzle594 262143 -111.00000 262143\n$P11 G660-A CD3 PE-Cy5 262143 -111.00000 262143\n$P12 G710-A CD5 PE-Cy55 262143 -111.00000 262143\n$P13 G780-A CCR1 PE-Cy7 262143 -111.00000 262143\n$P14 R670-A CD11c APC 262143 -111.00000 262143\n$P15 R730-A CD27 APC-R700 262143 -111.00000 262143\n$P16 R780-A XCR1 APC-Fire750 262143 -111.00000 262143\n$P17 U390-A CCR3 BUV395 262143 -111.00000 262143\n$P18 U450-A Live Dead UV Blue 262143 -102.92210 262143\n$P19 U500-A CD40 BUV496 262143 -111.00000 262143\n$P20 U570-A CD56 BUV563 262143 -100.80198 262143\n$P21 U660-A CD21 BUV661 262143 -111.00000 262143\n$P22 U740-A CD163 BUV737 262143 -111.00000 262143\n$P23 U785-A CD20 BUV805 262143 -111.00000 262143\n$P24 V450-A CCR2 BV421 262143 -111.00000 262143\n$P25 V510-A CD14 BV510 262143 -106.44221 262143\n$P26 V570-A CD16 BV570 262143 -111.00000 262143\n$P27 V605-A CD38 BV605 262143 -93.17506 262143\n$P28 V655-A CCR5 BV650 262143 -111.00000 262143\n$P29 V710-A CD86 BV711 262143 -111.00000 262143\n$P30 V750-A CX3CR1 BV750 262143 -111.00000 262143\n$P31 V785-A HLA-DR BV786 262143 -111.00000 262143\n$P32 remove_from_FS_FM QC 262143 0.00000 262143\n$P33 Time <NA> 92 0.00000 92\n\n\nVarious metadata present in the .fcs files.\n\n# keywords\nkeyword(cf) |> head(10) # only show the first 10\n\n$FCSversion\n[1] \"3\"\n\n$`$FIL`\n[1] \"4000_BDC-CR1.fcs\"\n\n$`$TOT`\n[1] \"912254\"\n\n$`$PAR`\n[1] \"33\"\n\n$`$BYTEORD`\n[1] \"4,3,2,1\"\n\n$`$DATATYPE`\n[1] \"F\"\n\n$FJ_FCS_VERSION\n[1] \"3\"\n\n$`$BEGINANALYSIS`\n[1] \"0\"\n\n$`$BEGINSTEXT`\n[1] \"0\"\n\n$`$BTIM`\n[1] \"10:29:03\"\n\n\n\n\nChannels, Expression, and Subsets\n\n# channels\ncolnames(cf)\n\n [1] \"FSC-A\" \"FSC-H\" \"SSC-A\" \n [4] \"B515-A\" \"B610-A\" \"B660-A\" \n [7] \"B710-A\" \"B780-A\" \"G575-A\" \n[10] \"G610-A\" \"G660-A\" \"G710-A\" \n[13] \"G780-A\" \"R670-A\" \"R730-A\" \n[16] \"R780-A\" \"U390-A\" \"U450-A\" \n[19] \"U500-A\" \"U570-A\" \"U660-A\" \n[22] \"U740-A\" \"U785-A\" \"V450-A\" \n[25] \"V510-A\" \"V570-A\" \"V605-A\" \n[28] \"V655-A\" \"V710-A\" \"V750-A\" \n[31] \"V785-A\" \"remove_from_FS_FM\" \"Time\" \n\n# markernames\nmarkernames(cf)\n\n B515-A B610-A B660-A B710-A \n \"CADM1 FITC\" \"CD141 BB630\" \"CD123 BB660\" \"FcER1a BB700\" \n B780-A G575-A G610-A G660-A \n \"IgD BB790\" \"IFNAR2 PE\" \"CD88 PE-Dazzle594\" \"CD3 PE-Cy5\" \n G710-A G780-A R670-A R730-A \n \"CD5 PE-Cy55\" \"CCR1 PE-Cy7\" \"CD11c APC\" \"CD27 APC-R700\" \n R780-A U390-A U450-A U500-A \n \"XCR1 APC-Fire750\" \"CCR3 BUV395\" \"Live Dead UV Blue\" \"CD40 BUV496\" \n U570-A U660-A U740-A U785-A \n \"CD56 BUV563\" \"CD21 BUV661\" \"CD163 BUV737\" \"CD20 BUV805\" \n V450-A V510-A V570-A V605-A \n \"CCR2 BV421\" \"CD14 BV510\" \"CD16 BV570\" \"CD38 BV605\" \n V655-A V710-A V750-A V785-A \n \"CCR5 BV650\" \"CD86 BV711\" \"CX3CR1 BV750\" \"HLA-DR BV786\" \n remove_from_FS_FM \n \"QC\" \n\n# instrument channel ranges\nrange(cf, type = \"instrument\")\n\n FSC-A FSC-H SSC-A B515-A B610-A B660-A B710-A B780-A G575-A G610-A\nmin 0 0 0 -110.3859 -111 -111 -111 -111 -111 -111\nmax 262143 262143 262143 262143.0000 262143 262143 262143 262143 262143 262143\n G660-A G710-A G780-A R670-A R730-A R780-A U390-A U450-A U500-A\nmin -111 -111 -111 -111 -111 -111 -111 -102.9221 -111\nmax 262143 262143 262143 262143 262143 262143 262143 262143.0000 262143\n U570-A U660-A U740-A U785-A V450-A V510-A V570-A V605-A\nmin -100.802 -111 -111 -111 -111 -106.4422 -111 -93.17506\nmax 262143.000 262143 262143 262143 262143 262143.0000 262143 262143.00000\n V655-A V710-A V750-A V785-A remove_from_FS_FM Time\nmin -111 -111 -111 -111 0 0\nmax 262143 262143 262143 262143 262143 92\n\n# expression\nexprs(cf)[1:5, 1:5]\n\n FSC-A FSC-H SSC-A B515-A B610-A\n[1,] 37806.11 33978.14 517.8660 136.6147 27.66158\n[2,] 105788.00 91726.41 550.5819 230.8201 331.49930\n[3,] 119658.92 96086.12 980.8203 275.5523 4240.47754\n[4,] 65660.55 57019.41 795.2517 407.6333 244.19577\n[5,] 119732.59 95060.98 555.4248 382.0113 648.48053\n\n# number of events\nnrow(cf)\n\n[1] 912254\n\n# number of channels \nncol(cf)\n\n[1] 33\n\n\nNotice that there is a correspondence between channels, markers, and the expression matrix. i.e. the names of the named vector markernames(cf) are a subset of the columns of the expression matrix exprs(cf) as well as the columns of the cytoframe.\n\n# interested marker: CD4\n# easy to find which channel is mapped to CD4\nCD4_chan <- flowCore::getChannelMarker(\n frm = cf,\n name = \"CD4\"\n)$name\n\nWarning in flowCore::getChannelMarker(frm = cf, name = \"CD4\"): CD4 is partially\nmatched with U500-ACD40 BUV496\n\n# inspect CD4_chan\nCD4_chan\n\n[1] \"U500-A\"\n\n# extract expression of cd4\ne_cd4 <- exprs(cf[, CD4_chan])\nhead(e_cd4)\n\n U500-A\n[1,] 1422.2137\n[2,] 199.7638\n[3,] 344.7379\n[4,] 2167.5317\n[5,] 285.1899\n[6,] 152.0994\n\n# subset cytorame by column\ns_cf <- cf[, CD4_chan]\ns_cf\n\ncytoframe object '4000_BDC-CR1.fcs'\nwith 912254 cells and 1 observables:\n name desc range minRange maxRange\n$P19 U500-A CD40 BUV496 262143 -111 262143\n327 keywords are stored in the 'description' slot\nrow names(0):\ncytoframe has been subsetted and can be realized through 'realize_view()'.\n\n# subset cytoframe by row\ns2_cf <- cf[1:100, ]\ns2_cf\n\ncytoframe object '4000_BDC-CR1.fcs'\nwith 100 cells and 33 observables:\n name desc range minRange maxRange\n$P1 FSC-A NA 262143 0.000 262143\n$P2 FSC-H NA 262143 0.000 262143\n$P3 SSC-A NA 262143 0.000 262143\n$P4 B515-A CADM1 FITC 262143 -110.386 262143\n$P5 B610-A CD141 BB630 262143 -111.000 262143\n... ... ... ... ... ...\n$P29 V710-A CD86 BV711 262143 -111 262143\n$P30 V750-A CX3CR1 BV750 262143 -111 262143\n$P31 V785-A HLA-DR BV786 262143 -111 262143\n$P32 remove_from_FS_FM QC 262143 0 262143\n$P33 Time NA 92 0 92\n327 keywords are stored in the 'description' slot\nrow names(0):\ncytoframe has been subsetted and can be realized through 'realize_view()'.\n\n\nNotice that the subset ([]) operation can be applied directly to the cytoframe object so that information regarding the file is preserved. Also, as indicated above, these operations provide an aliased view of the data without creating a copy.\nBelow, we show examples of how to manipulate the cytoframe object and create a copy using realize_view():\n\n# create a new markername\nnew_name <- c(\"U785-A\" = \"test\")\n\n# create a new cytoframe subset\ncf_sub <- cf[1:150, ] |> realize_view() # realize_view creates a new cytoframe, distinct from the original\n\n# old markernames\nmarkernames(cf_sub)\n\n B515-A B610-A B660-A B710-A \n \"CADM1 FITC\" \"CD141 BB630\" \"CD123 BB660\" \"FcER1a BB700\" \n B780-A G575-A G610-A G660-A \n \"IgD BB790\" \"IFNAR2 PE\" \"CD88 PE-Dazzle594\" \"CD3 PE-Cy5\" \n G710-A G780-A R670-A R730-A \n \"CD5 PE-Cy55\" \"CCR1 PE-Cy7\" \"CD11c APC\" \"CD27 APC-R700\" \n R780-A U390-A U450-A U500-A \n \"XCR1 APC-Fire750\" \"CCR3 BUV395\" \"Live Dead UV Blue\" \"CD40 BUV496\" \n U570-A U660-A U740-A U785-A \n \"CD56 BUV563\" \"CD21 BUV661\" \"CD163 BUV737\" \"CD20 BUV805\" \n V450-A V510-A V570-A V605-A \n \"CCR2 BV421\" \"CD14 BV510\" \"CD16 BV570\" \"CD38 BV605\" \n V655-A V710-A V750-A V785-A \n \"CCR5 BV650\" \"CD86 BV711\" \"CX3CR1 BV750\" \"HLA-DR BV786\" \n remove_from_FS_FM \n \"QC\" \n\n# set new markername\nmarkernames(cf_sub) <- new_name\nmarkernames(cf_sub)\n\n B515-A B610-A B660-A B710-A \n \"CADM1 FITC\" \"CD141 BB630\" \"CD123 BB660\" \"FcER1a BB700\" \n B780-A G575-A G610-A G660-A \n \"IgD BB790\" \"IFNAR2 PE\" \"CD88 PE-Dazzle594\" \"CD3 PE-Cy5\" \n G710-A G780-A R670-A R730-A \n \"CD5 PE-Cy55\" \"CCR1 PE-Cy7\" \"CD11c APC\" \"CD27 APC-R700\" \n R780-A U390-A U450-A U500-A \n \"XCR1 APC-Fire750\" \"CCR3 BUV395\" \"Live Dead UV Blue\" \"CD40 BUV496\" \n U570-A U660-A U740-A U785-A \n \"CD56 BUV563\" \"CD21 BUV661\" \"CD163 BUV737\" \"test\" \n V450-A V510-A V570-A V605-A \n \"CCR2 BV421\" \"CD14 BV510\" \"CD16 BV570\" \"CD38 BV605\" \n V655-A V710-A V750-A V785-A \n \"CCR5 BV650\" \"CD86 BV711\" \"CX3CR1 BV750\" \"HLA-DR BV786\" \n remove_from_FS_FM \n \"QC\" \n\n# manipulating expression values\n# notice the data range \nrange(cf_sub[, \"U785-A\"])\n\n U785-A\nmin -111\nmax 262143\n\n# visualise original channel ditribution\nplot(\n density(\n exprs(cf_sub[, \"U785-A\"])\n ),\n main = \"U785-A\"\n)\n\n\n\n# asinh transform\nexprs(cf_sub)[, \"U785-A\"] <- asinh(exprs(cf_sub)[, \"U785-A\"])\n\n# notice the data range after transformation\nrange(\n cf_sub[, \"U785-A\"],\n type = \"instrument\"\n)\n\n U785-A\nmin -111\nmax 262143\n\n# visualise channel distribution\nplot(\n density(\n exprs(cf_sub[, \"U785-A\"])\n ),\n main = \"U785-A\"\n)\n\n\n\n\nNotice that the data range summary was not updated when we used <- to change the underlying expression matrix. A good practice is to use transform function to transform the underlying expression matrix. Importantly, transform also updates the data range summary. Moreover, transform can also be used to add new columns to the cytoframe.\nNote: We will go over transformations in a later section."
},
{
"objectID": "vignettes/1_Import_fcs.html#reading-in-a-set-of-fcs-files-as-a-cytoset",
"href": "vignettes/1_Import_fcs.html#reading-in-a-set-of-fcs-files-as-a-cytoset",
"title": "Basics of working with FCS files",
"section": "Reading in a set of FCS files as a cytoset",
"text": "Reading in a set of FCS files as a cytoset\nIn a experimental sense, a single .fcs file is not very interesting, since this represents only a single sample. To draw any conclusions, we’ll want replicates. When there are a set of .fcs files they can be loaded into R either as a cytoset.\ncytoset: A collection of .fcs files, preferably, but not necessarily from the same panel/experiment.\n\ncs <- load_cytoset_from_fcs(path = \"data/fcs-data/\")\ncs\n\nA cytoset with 6 samples.\n\n column names:\n FSC-A, FSC-H, SSC-A, B515-A, B610-A, B660-A, B710-A, B780-A, G575-A, G610-A, G660-A, G710-A, G780-A, R670-A, R730-A, R780-A, U390-A, U450-A, U500-A, U570-A, U660-A, U740-A, U785-A, V450-A, V510-A, V570-A, V605-A, V655-A, V710-A, V750-A, V785-A, remove_from_FS_FM, Time\n\n\nA cytoset can also be indexed with square brackets cs[i,j], however now the row index i selects samples (individual FCS files) rather than cells. A cytoset also behaves like a list – a double bracket cs[[i]] selects a single sample as a cytoframe.\nGenerally, each FCS file replicate has unique metadata properties that can (and should) be supplied to the cytoset. These can be added after loading the cytoset by using pData(x) <- data.frame. The rownames of the data.frame must match the sampleNames of the cytoset.\n\n# prior to providing metadata\npData(cs)\n\n name\n4000_BDC-CR1.fcs 4000_BDC-CR1.fcs\n4000_TNK-CR1.fcs 4000_TNK-CR1.fcs\n4001_BDC-CR1.fcs 4001_BDC-CR1.fcs\n4001_TNK-CR1.fcs 4001_TNK-CR1.fcs\n4002_TNK-CR1.fcs 4002_TNK-CR1.fcs\n4003_TNK-CR1.fcs 4003_TNK-CR1.fcs\n\n# create metadata\nmetadata <- data.frame(\n Treatment = rep(c(\"Untreated\",\"Treated\"),\n length.out = length(cs)\n ),\n panel = ifelse(\n grepl(\n pattern = \"TNK\",\n x = sampleNames(cs)\n ),\n \"T Cell Panel\",\n \"Myeloid Panel\"\n )\n)\n\nLet’s see what happens when rownames do not match!\n\n# try to add metadata -- this leads to an error\npData(cs) <- metadata\n\nError: Invalid input type, expected 'character' actual 'integer'\n\n\nNow, we ensure that rownames of data.frame matches sampleNames of the cytoset.\n\n# now it works\nrow.names(metadata) <- sampleNames(cs)\npData(cs) <- metadata\npData(cs)\n\n panel Treatment\n4000_BDC-CR1.fcs Myeloid Panel Untreated\n4000_TNK-CR1.fcs T Cell Panel Treated\n4001_BDC-CR1.fcs Myeloid Panel Untreated\n4001_TNK-CR1.fcs T Cell Panel Treated\n4002_TNK-CR1.fcs T Cell Panel Untreated\n4003_TNK-CR1.fcs T Cell Panel Treated\n\n\nThe benefit of having metadata is that we can use many of the sub-setting operations in a metadata specific manner.\nThis is much more convenient than going back and forth between the full set of files.\n\n# subset by files that have myeloid staining panel without creating a copy of the data\ncs_myeloid <- cs[pData(cs)[[\"panel\"]] == \"Myeloid Panel\",]\n\ncs_myeloid\n\nA cytoset with 2 samples.\n\n column names:\n FSC-A, FSC-H, SSC-A, B515-A, B610-A, B660-A, B710-A, B780-A, G575-A, G610-A, G660-A, G710-A, G780-A, R670-A, R730-A, R780-A, U390-A, U450-A, U500-A, U570-A, U660-A, U740-A, U785-A, V450-A, V510-A, V570-A, V605-A, V655-A, V710-A, V750-A, V785-A, remove_from_FS_FM, Time\n\npData(cs_myeloid)\n\n panel Treatment\n4000_BDC-CR1.fcs Myeloid Panel Untreated\n4001_BDC-CR1.fcs Myeloid Panel Untreated\n\n\n\nCytoset views and aliasing\nMany of the sub-setting operation for cytoframe are also applicable for cytoset. Similar to cytoframe sub-setting operations only create a new “view” of the data. For a complete copy of the data, realize_view should be used.\nBelow is an example of cytoset sub-setting which also highlights how the operations performed on cytoset affects the underlying data.\n\n# demonstrate how cs point to the same underlying data\nrange(cs[[1, \"B515-A\"]])\n\n B515-A\nmin -110.3859\nmax 262143.0000\n\n# subset and show prior to transformation\ncs_small <- cs[1]\nrange(cs_small[[1, \"B515-A\"]])\n\n B515-A\nmin -110.3859\nmax 262143.0000\n\n# create a transformList\ntrans <- transformList(\"B515-A\",asinh)\n\n# transform\ncs_small <- transform(cs_small,trans)\n\n# after transformation\nrange(cs_small[[1, \"B515-A\"]])\n\n B515-A\nmin -5.397151\nmax 13.169792\n\n# whole cs \nrange(cs[[1, \"B515-A\"]])\n\n B515-A\nmin -5.397151\nmax 13.169792\n\n\nAs you see, the transformation was applied to a subset cs_small however the original cs was also altered highlighting that both objects were pointing to the same data. To confirm this, you can use cs_get_uri or cf_get_uri:\n\ncs_get_uri(cs_small)\n\n[1] \"/private/var/folders/8g/qvx6xyzs72q3wv286d96s_y91yzgmv/T/RtmppVYSJD/2a7318c7-7174-4b35-9ecd-d7cceb46ed1e\"\n\ncs_get_uri(cs)\n\n[1] \"/private/var/folders/8g/qvx6xyzs72q3wv286d96s_y91yzgmv/T/RtmppVYSJD/2a7318c7-7174-4b35-9ecd-d7cceb46ed1e\"\n\n\nTo perform a deep copy we can use realize_view()\n\n# look at underlying expression\nrange(cs[[2, \"B515-A\"]])\n\n B515-A\nmin -15.63437\nmax 262143.00000\n\n# subset and show prior to transformation\ncs_small2 <- realize_view(cs[2])\nrange(cs_small2[[1, \"B515-A\"]])\n\n B515-A\nmin -15.63437\nmax 262143.00000\n\n# create a transformList\ntrans <- transformList(\"B515-A\",asinh)\n\n# transform\ncs_small2 <- transform(cs_small2,trans)\n\n# after transformation\nrange(cs_small2[[1, \"B515-A\"]])\n\n B515-A\nmin -3.44364\nmax 13.16979\n\n# whole cs \nrange(cs[[2, \"B515-A\"]])\n\n B515-A\nmin -15.63437\nmax 262143.00000\n\n\nNotice that cs is left unchanged."
},
{
"objectID": "vignettes/1_Import_fcs.html#adding-additional-.fcs-files-to-cytoset",
"href": "vignettes/1_Import_fcs.html#adding-additional-.fcs-files-to-cytoset",
"title": "Basics of working with FCS files",
"section": "Adding additional .fcs files to cytoset",
"text": "Adding additional .fcs files to cytoset\nLastly, we can also add additional .fcs files to a cytoset using cs_add_cytoframe.\n\n# add to cytoset\ncs_small <- realize_view(cs[1]) # cs[1] subsets cs into a cytoset while realize_view leads to a deep_copy into a new cytoset\ncs_small\n\nA cytoset with 1 samples.\n\n column names:\n FSC-A, FSC-H, SSC-A, B515-A, B610-A, B660-A, B710-A, B780-A, G575-A, G610-A, G660-A, G710-A, G780-A, R670-A, R730-A, R780-A, U390-A, U450-A, U500-A, U570-A, U660-A, U740-A, U785-A, V450-A, V510-A, V570-A, V605-A, V655-A, V710-A, V750-A, V785-A, remove_from_FS_FM, Time\n\n# no need to assign back to cs_small, because this function operates by reference and returns NULL anyways.\ncs_add_cytoframe(\n cs = cs_small,\n sn = \"Sample Name\",\n cf = cs[[3]] # cs[[3]] results in a cytoframe\n) \ncs_small\n\nA cytoset with 2 samples.\n\n column names:\n FSC-A, FSC-H, SSC-A, B515-A, B610-A, B660-A, B710-A, B780-A, G575-A, G610-A, G660-A, G710-A, G780-A, R670-A, R730-A, R780-A, U390-A, U450-A, U500-A, U570-A, U660-A, U740-A, U785-A, V450-A, V510-A, V570-A, V605-A, V655-A, V710-A, V750-A, V785-A, remove_from_FS_FM, Time"
},
{
"objectID": "vignettes/1_Import_fcs.html#from-cytoset-to-cytoframe",
"href": "vignettes/1_Import_fcs.html#from-cytoset-to-cytoframe",
"title": "Basics of working with FCS files",
"section": "From cytoset to cytoframe",
"text": "From cytoset to cytoframe\nIt is possible that you may want to extract a cytoframe or extract all files as a list of cytoframe. We can either use [[ to directly grab a cytoframe or cytoset_to_list.\n\n# extract a single cytoframe by using cs[[index/samplename]]\nsingle_cf <- cs[[1]]\n\n# convert to a list\nlist_of_cf <- cytoset_to_list(cs)"
},
{
"objectID": "vignettes/1_Import_fcs.html#list-like-operation-with-cytoset",
"href": "vignettes/1_Import_fcs.html#list-like-operation-with-cytoset",
"title": "Basics of working with FCS files",
"section": "List like operation with cytoset",
"text": "List like operation with cytoset\nAs indicated previously, a cytoset behaves like a list. To leverage this behaviour we can use fsApply to iterate through the samples in a cytoset. By default, output is attempted to be coerced to a single array like object. (Set simplify = FALSE to return another list.)\n\n# getting number of rows (cells) of individual cytoframes\nn_cell_events <- fsApply(cs, nrow)\nn_cell_events\n\n [,1]\n4000_BDC-CR1.fcs 912254\n4000_TNK-CR1.fcs 102015\n4001_BDC-CR1.fcs 924474\n4001_TNK-CR1.fcs 92703\n4002_TNK-CR1.fcs 372224\n4003_TNK-CR1.fcs 146150"
},
{
"objectID": "vignettes/1_Import_fcs.html#saving-your-data",
"href": "vignettes/1_Import_fcs.html#saving-your-data",
"title": "Basics of working with FCS files",
"section": "Saving your data",
"text": "Saving your data\nSaving your data is easy.\n\n# save cytoframe\ncf_write_disk(cf, \"path/to/my_new_cf\")\n\n# save cytoset\nsave_cytoset(cs, path = \"path/to/my/cs\")\n\nLoading it back is just as easy.\n\n# load cytoframe\nload_cytoframe(\"path/to/my_cf\")\n\n# load cytoset\nload_cytoset(\"path/to/my/cs\")"
},
{
"objectID": "vignettes/1_Import_fcs.html#conclusion",
"href": "vignettes/1_Import_fcs.html#conclusion",
"title": "Basics of working with FCS files",
"section": "Conclusion",
"text": "Conclusion\nWe went through multiple ways to import, interact with, and manipulate .fcs files using the cytoverse tools. It is important to note additional functionality, which we will not going to go over at this workshop for the sake of time, for further manipulation and even creation of .fcs files exist with the cytoverse. We encourage you to explore them further at your leisure by calling browseVignettes(\"flowWorkspace\")."
}
]