-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGresham Lab Flow Cytometry Analysis.Rmd
More file actions
executable file
·499 lines (372 loc) · 21.8 KB
/
Gresham Lab Flow Cytometry Analysis.Rmd
File metadata and controls
executable file
·499 lines (372 loc) · 21.8 KB
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
---
title: "Gresham Lab Flow Core Guide"
author: '`r Sys.info()[7]`'
date: '`r Sys.Date()`'
output:
html_document:
fig_caption: yes
keep_md: yes
number_sections: yes
toc: yes
---
**Experiment overview**
Write a detailed description of your experiment here including the goal of the analysis and your interpretation of the results.
If you still see this text it means that you have not described the experiment and whatever follows is meaningless.
###############################
> This code is designed for use with the Accuri flow cytometer, which is equiped with the following lasers and filters
* Blue laser (488 nm)
+ FL1 filter = 514/20nm GFP
+ FL3 filter = 575/25nm YFP
* Yellow/green laser (552 nm)
+ FL2 filter = 610/20nm mCherry, dtomato
+ FL4 filter = 586/15nm DsRed
**Requirements**
In order to run this code you need:
+ to predefine your gates using the **gating.R** script
+ the **gates.Rdata** workspace, which contains the gates used in this script
+ the path of the directory(ies), given the variable names **dir1**, **dir2**... that contain .fcs files named A01.fcs, A02.fcs, A03.fcs...
+ a tab delimited sample sheet in each directory with the following rows: <Well> <Strain> <Genotype> <Ploidy> <Media> <Experiment>
+ the variable names are changed in chunk 2 named "Variable Names"
**Output**
This script generates a summary of results followed by quality control plots.
#Step 1: Load relevant libraries
```{r Libraries, eval=TRUE}
# This is a function that just makes sure you have a package, or installs it for you without prompting
requireInstall <- function(packageName,isBioconductor=F) {
if ( !try(require(packageName,character.only=T)) ) {
print(paste0("You don't have ",packageName," accessible, ",
"I'm gonna install it"))
if (isBioconductor) {
source("http://bioconductor.org/biocLite.R")
biocLite(packageName)
} else {
install.packages("packageName", repos = "http://cran.us.r-project.org")
}
}
return(1)
}
#Load libraries
requireInstall("flowCore",isBioconductor=T)
requireInstall("flowViz",isBioconductor=T)
requireInstall("flowStats")
requireInstall("Hmisc")
requireInstall("reshape2")
requireInstall("ggplot2")
requireInstall("flowWorkspace")
requireInstall("ggcyto", isBioconductor=T)
requireInstall("gridExtra")
```
#Step 2: Read in .fcs files, an Rdata file containing the gates sample sheet(s) that contains four columns with
* column1 = Well
* column2 = Strain
* column3 = Staining
* column4 = Media
* column5 = Userdefined
```{r Variable definitions}
#Read in all data for analysis. Data should be in individual directories that contain .fcs files and a corresponding sample sheet with a generic format. FCS file names should be unaltered e.g AO1.fcs, A02.fcs, ...H12.fcs
#An abitrary number of directories can be used named dir1, dir2, dir3...with a corresponding flowData.1, flowData.2, flowData.3...and sample.sheet.1, sample.sheet.2, sample.sheet.3...
#load the Rdata file containing the gates
load("gates.Rdata")
#Define the directory, or directories, containing your .fcs files using absolute path names
dir1 <- "/Users/David/Google Drive/Gresham Lab_David/flow/flow cytometry"
dir2 <- "/Users/David/Google Drive/Gresham Lab_David/flow/flow cytometry"
#Read in all the fcs files in the directory, with alter.names changing "-" to "."
flowData.1 <- read.flowSet(path = dir1, pattern=".fcs", alter.names=TRUE)
flowData.2 <- read.flowSet(path = dir2, pattern=".fcs", alter.names=TRUE)
#Read in the sample sheet that should be in each directory that contains the .fcs files.
sample.sheet.1 <- read.delim(paste(dir1, "SampleSheet.txt", sep="/"))
sample.sheet.2 <- read.delim(paste(dir2, "SampleSheet2.txt", sep="/"))
#Change names of samples to those specified in the sample sheets
sampleNames(flowData.1) <- paste(sample.sheet.1[,1], sample.sheet.1[,2], sample.sheet.1[,3], sample.sheet.1[,4], sample.sheet.1[,5], sample.sheet.1[,6], sep=" ")
sampleNames(flowData.2) <- paste(sample.sheet.2[,1], sample.sheet.2[,2], sample.sheet.2[,3], sample.sheet.2[,4], sample.sheet.2[,5], sample.sheet.2[,6], sep=" ")
```
```{r flowSet summaries}
#Check how many cells were counted in each fcs file
fsApply(flowData.1, each_col, length)[1:6]
fsApply(flowData.2, each_col, length)[1:6]
total.1 <- fsApply(flowData.1, each_col, length)[1:6] #total counts per sample
total.2 <- fsApply(flowData.1, each_col, length)[1:6] #total counts per sample
#Print the medians of data values for each measurement
fsApply(flowData.1, each_col, median)
fsApply(flowData.2, each_col, median)
#combine all flowSets into a single flowset
flowData <- rbind2(flowData.1, flowData.2)
total <- fsApply(flowData, each_col, length)[1:12] #total number of measurements per sample
fsApply(flowData, each_col, median)
samples.num <- length(flowData)
```
#Step 3: apply filters to data and generate plots showing the effect on filtering
```{r Application of Gates}
##Subset the data by applying sequential gates##
#apply doublet gate
flowData.singlets <- Subset(flowData, pg.singlets)
fsApply(flowData.singlets, each_col, length)[1:samples.num]
singlets <- fsApply(flowData.singlets, each_col, length)[1:samples.num]
barplot(singlets/total, ylim=c(0,1), ylab = "Proportion singlet cells", las=2, cex.names = 0.5, names.arg=sampleNames(flowData))
#apply debris gate
filteredData <- Subset(flowData.singlets, pg.nondebris)
fsApply(filteredData, each_col, length)[1:samples.num]
non.debris <- fsApply(filteredData, each_col, length)[1:samples.num]
barplot(non.debris/total, ylim=c(0,1), ylab = "Proportion singlet and nondebris cells", las=2, cex.names = 0.5, names.arg=sampleNames(flowData))
#########
#filteredData is the variable name for the data filtered of doublets and debris that are used for all subsequent analyses
##########
#this gate defines nongfp cells
gfp.neg <- Subset(filteredData, pg.nongfp)
fsApply(gfp.neg, each_col, length)[1:samples.num]
non.gfp <- fsApply(gfp.neg, each_col, length)[1:samples.num]
barplot(non.gfp/non.debris, ylim=c(0,1), ylab = "Proportion cells with no GFP", las=2, cex.names = 0.5, names.arg=sampleNames(flowData))
#this gate defines gfp cells
gfp.pos <- Subset(filteredData, pg.gfp)
fsApply(gfp.pos, each_col, length)[1:samples.num]
gfp.cells <- fsApply(gfp.pos, each_col, length)[1:samples.num]
barplot(gfp.cells/non.debris, ylim=c(0,1), ylab = "Proportion cells with GFP", las=2, cex.names = 0.5, names.arg=sampleNames(flowData))
#this gate defines high GFP cells
gfp.hi <- Subset(filteredData, pg.hi.gfp)
fsApply(gfp.hi, each_col, length)[1:samples.num]
hi.gfp.cells <- fsApply(gfp.hi, each_col, length)[1:samples.num]
barplot(hi.gfp.cells/non.debris, ylim=c(0,1), ylab = "Proportion cells with high GFP", las=2, cex.names = 0.5, names.arg=sampleNames(flowData))
```
#Step 4: Data analysis
##diagnostic values can be defined for plotting purposes
```{r Definition of diagnostic values}
#define critical values that can superimposed on plots for easy visual comparison
gfp.bg <- 3.9 #a background value for GFP
gfp.wt <- 5.9 #a value for wildtype GFP expression
red.bg <- 3.03 #a background value for the red channel
red.wt <- 3.75 #a value for wildtype Red expression
haploid.fsc <- 6e5 #an empirical value for forward scatter for haploids
diploid.fsc <- 7e5 #an empirical value for forward scatter for diploids
gfp.norm <- 0.935 #an empricial value for gfp expression normalized by forward scatter
red.norm <- 0.57 #an empricial value for red expression normalized by forward scatter
gfp.red.norm <- 1.5 #an empricial value for gfp expression normalized by red channel
```
##Extract data from fcs files to generate statistics and boxplots
```{r Data extraction and plotting}
#record summary statistics for each sample in a matrix named summary.stats
summary.stats <- matrix(data = NA, nrow = length(filteredData), ncol = 18, dimnames = list(sampleNames(filteredData),c("FSC_median","FSC_mean", "FSC_sd","FL1_median", "FL1_mean","FL1_sd","normalizedGFP_median", "normalizedGFP_mean", "normalizedGFP_sd","FL2_median","FL2_mean","FL2_sd","normalizedRed_median","normalizedRed_mean", "normalizedRed_sd","GFPnormalizedByRed_median", "GFPnormalizedByRed_mean","GFPnormalizedByRed_sd")))
#use the sample containing the minimum number of points after filtering for doublets and debris to define the number of data points retained for all samples
sample.size <- min(fsApply(filteredData, each_col, length))
print(sample.size)
comparison.FSC <- matrix(data = NA, nrow = sample.size, ncol = length(filteredData), byrow = FALSE,dimnames = NULL)
comparison.FL1 <- matrix(data = NA, nrow = sample.size, ncol = length(filteredData), byrow = FALSE,dimnames = NULL)
comparison.FL2 <- matrix(data = NA, nrow = sample.size, ncol = length(filteredData), byrow = FALSE,dimnames = NULL)
comparison.FL1NormFsc <- matrix(data = NA, nrow = sample.size, ncol = length(filteredData), byrow = FALSE,dimnames = NULL)
comparison.FL2NormFsc <- matrix(data = NA, nrow = sample.size, ncol = length(filteredData), byrow = FALSE,dimnames = NULL)
comparison.FL1NormFL2 <- matrix(data = NA, nrow = sample.size, ncol = length(filteredData), byrow = FALSE,dimnames = NULL)
#for each sample plot a histogram of the normalized data, raw FSC and raw GFP per row
par(mfrow=c(1,2), mar=c(5.1,2.1,2.1,2.1), oma=c(1.5,2,1,1))
#extract data from flowFrames to plot histograms of values and record summary statistics
for (i in 1:length(filteredData)){
temp <- exprs(filteredData[[i]]) #exprs() extracts a matrix of the values from the flowframe
##########################################
#record summary statistics for the sample#
##########################################
#FSC
summary.stats[i,1] <- median(temp[,1])
summary.stats[i,2] <-mean(temp[,1])
summary.stats[i,3] <- sd(temp[,1])
#FL1
summary.stats[i,4] <- median(temp[,3])
summary.stats[i,5] <-mean(temp[,3])
summary.stats[i,6] <- sd(temp[,3])
#FL1 (GFP) divided by FSC
summary.stats[i,7] <- median(temp[,3]/temp[,1])
summary.stats[i,8] <-mean(temp[,3]/temp[,1])
summary.stats[i,9] <- sd(temp[,3]/temp[,1])
#FL2
summary.stats[i,10] <- median(temp[,4])
summary.stats[i,11] <-mean(temp[,4])
summary.stats[i,12] <- sd(temp[,4])
#FL2 (Red) divided by FSC
summary.stats[i,13] <- median(temp[,4]/temp[,1])
summary.stats[i,14] <-mean(temp[,4]/temp[,1])
summary.stats[i,15] <- sd(temp[,4]/temp[,1])
#FL1 (GFP) divided by FL2 (Red)
summary.stats[i,16] <- median(temp[,3]/temp[,4])
summary.stats[i,17] <-mean(temp[,3]/temp[,4])
summary.stats[i,18] <- sd(temp[,3]/temp[,4])
##############################################
#plot histograms of the channels of interest##
##############################################
###############
#Green channel#
###############
#FL1 (GFP)
hist(log10(temp[,3]), br=1000, xlab = "log10(FL1)", main = "FL1")
abline(v=gfp.bg, col="yellow", lty=2, lwd=2)
abline(v=gfp.wt, col="green", lty=2, lwd=2)
legend("topleft", legend=paste("median FL1 = ",round(median(temp[,3]), digits=4),sep=""))
#GFP divided by FSC
hist(temp[,3]/temp[,1], br=500, xlab = "FL1/FSC", main = "FL1/FSC")
abline(v=gfp.norm, col="green", lty=2, lwd=2 )
legend("topleft", legend=paste("median GFP / FSC=",round(median(temp[,3]/temp[,1]), digits=4),sep=""))
mtext(sampleNames(filteredData[i]), outer = TRUE, cex = 1.0)
###############
#Red channel#
###############
#FL2 (Red)
hist(log10(temp[,4]), br=500, xlab = "log10(FL2)", main = "FL2")
abline(v=red.bg, col="yellow", lty=2, lwd=2)
abline(v=red.wt, col="red", lty=2, lwd=2)
legend("topleft", legend=paste("median FL2=",round(median(temp[,4]), digits=4),sep=""))
#FL2 divided by FSC
hist(temp[,4]/temp[,1], br=500, xlab = "FL2/FSC", main = "FL2/FSC")
abline(v=red.norm, col="red", lty=2, lwd=2 )
legend("topleft", legend=paste("median FL2 / FSC=",round(median(temp[,4]/temp[,1]), digits=4),sep=""))
mtext(sampleNames(filteredData[i]), outer = TRUE, cex = 1.0)
###############
#Other#########
###############
#FL1 divided by FL2
hist(temp[,4]/temp[,3], br=500, xlab = "FL2/FL1", main = "FL1/FL2")
abline(v=gfp.red.norm, col="purple", lty=2, lwd=2)
legend("topleft", legend=paste("median FL1 / FL2=",round(median(temp[,4]/temp[,3]), digits=4),sep=""))
#FSC
hist(log10(temp[,1]), br=500, xlab = "log10(FSC)", main = "FSC", xlim=c(4,8))
abline(v=haploid.fsc, col="blue", lty=2, lwd=2)
abline(v=diploid.fsc, col="grey", lty=2, lwd=2)
legend("topleft", legend=paste("median FSC=",round(median(temp[,1]), digits=4),sep=""))
mtext(sampleNames(filteredData[i]), outer = TRUE, cex = 1.0)
print("-------------------------------------------------------")
print("-----------------------------------")
print("----------------------")
############################################################
#keep the data set for generating boxplots comparing values#
############################################################
#Note that the amount of data kept for each sample is defined by the lowest count among all the samples.
comparison.FSC[1:sample.size,i] <- temp[1:sample.size,1] #FSC
comparison.FL1[1:sample.size,i] <- temp[1:sample.size,3] #FL1 (GFP)
comparison.FL1NormFsc[1:sample.size,i] <- temp[1:sample.size,3]/temp[1:sample.size,1] #GFP/FSC
comparison.FL2[1:sample.size,i] <- temp[1:sample.size,4] #FL2
comparison.FL2NormFsc[1:sample.size,i] <- temp[1:sample.size,4]/temp[1:sample.size,1] #FL2/FSC
comparison.FL1NormFL2[1:sample.size,i] <- temp[1:sample.size,3]/temp[1:sample.size,4] #FL1/FL2
}
par(mfrow=c(1,1)) #change number of plots per row back to standard
```
##Overview of data distributions
```{r Overall data distributions}
par(mar=c(8.1,4.1,4.1,2.1)) #create more space at lower margin
boxplot(comparison.FSC, names=sampleNames(filteredData), notch = TRUE, col = "gray", ylab="FSC", cex.axis=0.5,las=2, outline=F)
abline(h=haploid.fsc, lty=2, col=2)
abline(h=diploid.fsc, lty=2, col=3)
boxplot(comparison.FL1, names=sampleNames(filteredData), notch = TRUE, col = "lightgreen", ylab="FL1", cex.axis=0.5,las=2, outline=F)
abline(h=gfp.bg ,lty=2, lwd=3, col="yellow")
abline(h=gfp.wt, lty = 2, lwd=3, col="green")
boxplot(comparison.FL1NormFsc, names=sampleNames(filteredData), notch = TRUE, col = "green", ylab="FL1/FSC", cex.axis=0.5,las=2, outline=F)
abline(h=gfp.norm, lty=2, lwd=3, col="blue")
boxplot(comparison.FL2, names=sampleNames(filteredData), notch = TRUE, col = "pink", ylab="FL2", cex.axis=0.5,las=2, outline=F)
abline(h=red.bg, lty=2, lwd=3, col="pink")
abline(h=red.wt, lty=2, lwd=3, col="red")
boxplot(comparison.FL2NormFsc, names=sampleNames(filteredData), notch = TRUE, col = "red", ylab="FL2/FSC", cex.axis=0.5,las=2, outline=F)
abline(h=red.norm, lty=2, lwd=3, col="red")
boxplot(comparison.FL1NormFL2, names=sampleNames(filteredData), notch = TRUE, col = "purple", ylab="FL1/FL2", cex.axis=0.5,las=2, outline=F)
abline(h=gfp.red.norm, lty=2, lwd=3, col="purple")
par(mar=c(5.1,4.1,4.1,2.1)) #reset margins to default
#generate a summary table containing all the recorded statistics
print(summary.stats)
summary.stats <- as.data.frame(summary.stats)
```
##Quantitation of relative FL1 signal
```{r}
baseline.FL1 <- summary.stats$FL1_median[1]
barplot(summary.stats$FL1_median/baseline.FL1, ylab="Relative FL1 median expression", las=2, cex.names = 0.5, names.arg=sampleNames(filteredData))
```
##Quantitation of forward scatter
```{r}
baseline.FSC <- summary.stats$FSC_median[1]
barplot(summary.stats$FSC_median/baseline.FSC, ylab="Relative median FSC", las=2, cex.names = 0.5, names.arg=sampleNames(filteredData))
```
##Population composition
```{r}
pop.composition <- rbind(non.gfp/non.debris,gfp.cells/non.debris,hi.gfp.cells/non.debris)
barplot(pop.composition, ylab="Proportion of population", legend=c("No GFP", "Normal GFP", "High GFP"),las=2, cex.names = 0.5,names.arg=sampleNames(filteredData))
```
#Step 5: Quality control
##Gates
```{r}
###First flowset
#Singlets gate
xyplot(FSC.A~FSC.H, data=flowData.1, xlim=c(0,3e6), ylim=c(0,3e6), filter=pg.singlets, smooth=F, xbin=1024, stat=T, pos=0.5, abs=T, main = "First flowset - singlets gate")
#Debris gate
xyplot(SSC.A ~ FSC.A, data=flowData.1, displayFilter=TRUE, xlim=c(0,3e6), ylim=c(0,3e5), filter=pg.nondebris, smooth=F, xbin=1024, stat=T, pos=0.5, abs=T, main = "First flowset - nondebris gate")
#Non-fluorescent population gate
xyplot(FL1.A~FSC.A,data=flowData.1, displayFilter=TRUE, xlim=c(0,5e6), ylim=c(0,5e4), filter=pg.nongfp, smooth=F, xbin=1024, stat=T, pos=0.5, abs=T, main = "First flowset - non GFP gate")
#Fluorescent population gate
xyplot(FL1.A~FSC.A,data=flowData.1, displayFilter=TRUE, xlim=c(0,5e6), ylim=c(0,5e4), filter=pg.gfp, smooth=F, xbin=1024, stat=T, pos=0.5, abs=T, main = "First flowset - GFP gate")
#High fluorescing gate
xyplot(FL1.A~FSC.A,data=flowData.1, xlim=c(0,5e6), ylim=c(0,5e4), filter=pg.hi.gfp, smooth=F, xbin=1024, stat=T, pos=0.5, abs=T, main = "First flowset - high GFP gate")
################
###Second flowset
#Singlets gate
xyplot(FSC.A~FSC.H, data=flowData.2, xlim=c(0,3e6), ylim=c(0,3e6), filter=pg.singlets, smooth=F, xbin=1024, stat=T, pos=0.5, abs=T, main = "Second flowset - singlets gate")
#Debris gate
xyplot(SSC.A ~ FSC.A, data=flowData.2, displayFilter=TRUE, xlim=c(0,3e6), ylim=c(0,3e5), filter=pg.nondebris, smooth=F, xbin=1024, stat=T, pos=0.5, abs=T, main = "Second flowset - nondebris gate")
#Non-fluorescent population gate
xyplot(FL1.A~FSC.A,data=flowData.2, displayFilter=TRUE, xlim=c(0,5e6), ylim=c(0,5e4), filter=pg.nongfp, smooth=F, xbin=1024, stat=T, pos=0.5, abs=T, main = "Second flowset - non GFP gate")
#Fluorescent population gate
xyplot(FL1.A~FSC.A,data=flowData.2, displayFilter=TRUE, xlim=c(0,5e6), ylim=c(0,5e4), filter=pg.gfp, smooth=F, xbin=1024, stat=T, pos=0.5, abs=T, main = "Second flowset - GFP gate")
#High fluorescing gate
xyplot(FL1.A~FSC.A,data=flowData.2, xlim=c(0,5e6), ylim=c(0,5e4), filter=pg.hi.gfp, smooth=F, xbin=1024, stat=T, pos=0.5, abs=T, main = "Second flowset - high GFP gate")
#####Attempted as loop below to plot each one individually and is not working
for (i in 1:length(filteredData)){
#Singlets gate
xyplot(FSC.A~FSC.H, data=flowData[i], xlim=c(0,3e6), ylim=c(0,3e6), filter=pg.singlets, smooth=F, xbin=1024, stat=T, pos=0.5, abs=T, main = sampleNames(flowData)[i])
#Debris gate
xyplot(SSC.A ~ FSC.A, data=flowData[i], displayFilter=TRUE, xlim=c(0,3e5), ylim=c(0,3e6), filter=pg.nondebris, smooth=F, xbin=1024, stat=T, pos=0.5, abs=T, main = sampleNames(flowData)[i])
#Non-fluorescent population gate
xyplot(FL1.A~FSC.A,data=flowData[i], displayFilter=TRUE, xlim=c(0,5e6), ylim=c(0,5e4), filter=pg.nongfp, smooth=F, xbin=1024, stat=T, pos=0.5, abs=T, main = sampleNames(flowData)[i])
#Fluorescent population gate
xyplot(FL1.A~FSC.A,data=flowData[i], displayFilter=TRUE, xlim=c(0,5e6), ylim=c(0,5e4), filter=pg.gfp, smooth=F, xbin=1024, stat=T, pos=0.5, abs=T, main = sampleNames(flowData)[i])
#High fluorescing gate
xyplot(FL1.A~FSC.A,data=flowData[i], xlim=c(0,5e6), ylim=c(0,5e4), filter=pg.hi.gfp, smooth=F, xbin=1024, stat=T, pos=0.5, abs=T, main = sampleNames(flowData)[i])
}
```
##Data transformation for visualization
```{r}
#In order to look at QC plots the data is transformed using the logicle transform, which is a log transform for high values that transitions to a linear transformation near zero values
#This is simply for visualization purposes
lgcl <- logicleTransform(w = 0.5, t= 10000, m=4.5) #the parameters w,t, and m define the transformation parameters
#Dataset 1 tranformation applied to every channel except width and time
dataLGCLTransform <- transform(filteredData,'FSC.A' = lgcl(`FSC.A`), 'SSC.A' =lgcl(`SSC.A`), 'FL1.A' = lgcl(`FL1.A`), 'FL2.A' = lgcl(`FL2.A`), 'FL3.A' = lgcl(`FL3.A`), 'FL4.A' = lgcl(`FL4.A`),'FSC.H' = lgcl(`FSC.H`),'SSC.H' = lgcl(`SSC.H`),'FL1.H' = lgcl(`FL1.H`),'FL2.H' = lgcl(`FL2.H`),'FL3.H' = lgcl(`FL3.H`),'FL4.H' = lgcl(`FL4.H`))
```
##Effect of time
```{r}
#The effect of time on signal (of which there shouldn't be any)
i <- 1
xyplot(FL1.A ~ Time, data=dataLGCLTransform[i], smooth=F, stat=T, pos=0.5, abs=T, xlim=c(150,250), main = sampleNames(filteredData)[i])
i <- 2
xyplot(FL1.A ~ Time, data=dataLGCLTransform[i], smooth=F, stat=T, pos=0.5, abs=T, xlim=c(150,250), main = sampleNames(filteredData)[i])
i <- 3
xyplot(FL1.A ~ Time, data=dataLGCLTransform[i], smooth=F, stat=T, pos=0.5, abs=T, xlim=c(150,250), main = sampleNames(filteredData)[i])
####Attempted as loop and will not work
for (i in 1:length(filteredData)){
xyplot(FL1.A ~ Time, data=dataLGCLTransform[i], smooth=F, stat=T, pos=0.5, abs=T, xlim=c(150,250), main = sampleNames(filteredData)[i])
}
```
##Plots of FL1 versus FSC
```{r}
i <- 1
xyplot(FL1.A ~ FSC.A, data=dataLGCLTransform[i], smooth=F, stat=T, pos=0.5, abs=T, xlim=c(4,8), sampleNames(filteredData)[i])
i <- 2
xyplot(FL1.A ~ FSC.A, data=dataLGCLTransform[i], smooth=F, stat=T, pos=0.5, abs=T, xlim=c(4,8), sampleNames(filteredData)[i])
i <- 3
xyplot(FL1.A ~ FSC.A, data=dataLGCLTransform[i], smooth=F, stat=T, pos=0.5, abs=T, xlim=c(4,8), sampleNames(filteredData)[i])
####Attempted as loop and will not work
for (i in 1:length(filteredData)){
xyplot(FL1.A ~ FSC.A, data=dataLGCLTransform[i], smooth=F, stat=T, pos=0.5, abs=T, xlim=c(4,8), ylim=c(2,6), sampleNames(filteredData)[i])
}
```
##Plots of FSC versus SSC
```{r}
i <- 1
xyplot(SSC.A ~ FSC.A, data=dataLGCLTransform[i], smooth=F, stat=T, pos=0.5, abs=T, xlim=c(4,8), ylim=c(4,8), sampleNames(filteredData)[i])
i <- 2
xyplot(SSC.A ~ FSC.A, data=dataLGCLTransform[i], smooth=F, stat=T, pos=0.5, abs=T, xlim=c(4,8), ylim=c(4,8), sampleNames(filteredData)[i])
i <- 3
xyplot(SSC.A ~ FSC.A, data=dataLGCLTransform[i], smooth=F, stat=T, pos=0.5, abs=T, xlim=c(4,8), ylim=c(4,8), sampleNames(filteredData)[i])
####Attempted as loop and will not work
for (i in 1:length(filteredData)){
xyplot(SSC.A ~ FSC.A, data=dataLGCLTransform[i], smooth=F, stat=T, pos=0.5, abs=T, xlim=c(4,8), ylim=c(4,8), sampleNames(filteredData)[i])
}
```