################################################### ### chunk number 1: cellnum ################################################### #line 141 "vignettes/flowQ/inst/doc/DataQualityAssessment.Rnw" library(flowQ) data(GvHD) GvHD <- GvHD[1:10] dest <- file.path(tempdir(), "flowQ") qp1 <- qaProcess.cellnumber(GvHD, outdir=dest, cFactor=0.75) ################################################### ### chunk number 2: cellnumfig ################################################### #line 148 "vignettes/flowQ/inst/doc/DataQualityAssessment.Rnw" img <- qp1@summaryGraph@fileNames[2] to <- paste(flowQ:::guid(), "pdf", sep=".") f <- file.copy(img, to) cat(sprintf("\\myincfig{%s}{0.5\\textwidth}{%s}{%s}\n", to, paste("Summary graphics for the cell number QA criterion produced", "by the \\Rfunction{qaProcess.cellnumber} function."), "cellnum")) ################################################### ### chunk number 3: margin ################################################### #line 172 "vignettes/flowQ/inst/doc/DataQualityAssessment.Rnw" qp2 <- qaProcess.marginevents(GvHD, channels=c("FSC-H", "SSC-H"), outdir=dest, pdf=FALSE) ################################################### ### chunk number 4: marginsumfig ################################################### #line 176 "vignettes/flowQ/inst/doc/DataQualityAssessment.Rnw" img <- qp2@summaryGraph@fileNames[2] to <- paste(flowQ:::guid(), "jpg", sep=".") f <- file.copy(img, to) cat(sprintf("\\myincfig{%s}{0.8\\textwidth}{%s}{%s}\n", to, paste("Summary graphics of the FSC-H channel for the boundary event", "QA criterion produced by the \\Rfunction{qaProcess.marginevent}", "function."), "marginsum")) ################################################### ### chunk number 5: margindetfig ################################################### #line 185 "vignettes/flowQ/inst/doc/DataQualityAssessment.Rnw" img <- qp2@frameProcesses[[1]]@frameGraphs[[1]]@fileNames[[2]] to <- paste(flowQ:::guid(), "jpg", sep=".") f <- file.copy(img, to) cat(sprintf("\\myincfig{%s}{0.6\\textwidth}{%s}{%s}\n", to, paste("Detailed sample-specific graphics of the FSC-H channel", "for the boundary event QA criterion produced by the", "\\Rfunction{qaProcess.marginevent}function."), "margindet")) ################################################### ### chunk number 6: time ################################################### #line 213 "vignettes/flowQ/inst/doc/DataQualityAssessment.Rnw" GvHD <- transform(GvHD, "FL1-H"=asinh(`FL1-H`), "FL2-H"=asinh(`FL2-H`)) qp3 <- qaProcess.timeline(GvHD, channel="FL1-H", outdir=dest, cutoff=1) qp4 <- qaProcess.timeflow(GvHD, outdir=dest, cutoff=2) ################################################### ### chunk number 7: timefig ################################################### #line 218 "vignettes/flowQ/inst/doc/DataQualityAssessment.Rnw" img <- qp3@summaryGraph@fileNames[2] to <- paste(flowQ:::guid(), "jpg", sep=".") f <- file.copy(img, to) cat(sprintf("\\myincfig{%s}{0.6\\textwidth}{%s}{%s}\n", to, paste("Summary graphics of the FL1-H channel for the time line", "QA criterion produced by the \\Rfunction{qaProcess.timeline}", "function."), "timeline")) ################################################### ### chunk number 8: htmlreport ################################################### #line 249 "vignettes/flowQ/inst/doc/DataQualityAssessment.Rnw" url <- writeQAReport(GvHD, processes=list(qp1, qp2, qp3, qp4), outdir=dest) ################################################### ### chunk number 9: browse eval=FALSE ################################################### ## #line 255 "vignettes/flowQ/inst/doc/DataQualityAssessment.Rnw" ## browseURL(url) ################################################### ### chunk number 10: loadPackage ################################################### #line 295 "vignettes/flowQ/inst/doc/DataQualityAssessment.Rnw" library(RColorBrewer) library(latticeExtra) ################################################### ### chunk number 11: Read_Transform ################################################### #line 307 "vignettes/flowQ/inst/doc/DataQualityAssessment.Rnw" data(qData) qData[[1]][[1]] ################################################### ### chunk number 12: transformData ################################################### #line 335 "vignettes/flowQ/inst/doc/DataQualityAssessment.Rnw" tData <- lapply(qData, function(x) transformList(colnames(x)[3:7], asinh) %on% x) ################################################### ### chunk number 13: Plot1_TransformedData ################################################### #line 342 "vignettes/flowQ/inst/doc/DataQualityAssessment.Rnw" library(flowViz) plot(tData[[1]][[1]]) ################################################### ### chunk number 14: displayBoundaryData ################################################### #line 372 "vignettes/flowQ/inst/doc/DataQualityAssessment.Rnw" resBoundary <- qaProcess.BoundaryPlot(tData, dyes=c("FSC-A","CD3"), outdir=dest, cutoff=3, pdf=TRUE) imagePath <- resBoundary@summaryGraph@fileNames[2] #writeQAReport(tData[[1]], list(resBoundary), outdir=dest,pdf=TRUE) ################################################### ### chunk number 15: displayBoundImage ################################################### #line 385 "vignettes/flowQ/inst/doc/DataQualityAssessment.Rnw" to <- paste(flowQ:::guid(), "jpg", sep=".") f <- file.copy(imagePath, to) cat('\\includegraphics[width=1.0\\textwidth]{', to, '}\n', sep="") ################################################### ### chunk number 16: BoundaryEvents ################################################### #line 399 "vignettes/flowQ/inst/doc/DataQualityAssessment.Rnw" createBoundaryFilterList<-function(flowSet){ len <- length(colnames(flowSet)) tmp<-fsApply(flowSet,range) tmp<-lapply(tmp,function(x){ x[[colnames(x)[len]]]<-NULL x }) res<-lapply(tmp,function(y){ apply(y,2,function(x){ # 2*x-extendrange(r=x,0.1) c((x[1]+2*.Machine$double.eps),(x[2]-2*.Machine$double.eps)) }) }) filtList<-lapply(res,function(x){ rectangleGate(filterId="boundary",.gate=x) } ) return(filtList) } boundData<-list() for(i in seq_len(length(tData))){ wfNew <- workFlow(tData[[i]], name="panel") filtList<-createBoundaryFilterList(Data(wfNew[["base view"]])) flt<-filterList(x=filtList,filterId="boundary") add(wfNew,flt) boundData[[i]] <- Data(wfNew[["boundary+"]]) rm(wfNew) cat(i) cat(".") } ################################################### ### chunk number 17: Data Normalization ################################################### #line 455 "vignettes/flowQ/inst/doc/DataQualityAssessment.Rnw" library(flowStats) patientID=sampleNames(boundData[[1]]) ls <- length(patientID) #dupes <- locateDuplicatedParameters(boundData) #nData<-normalizeSets(flowList=boundData,dupes=dupes[-c(1,2)]) ## ignoring FSC-A, SSC-A nData<-normalizeSets(flowList=boundData,dupes=c("CD8","CD27","CD4")) ################################################### ### chunk number 18: getDistances ################################################### #line 487 "vignettes/flowQ/inst/doc/DataQualityAssessment.Rnw" getDistance<-function(res,dyes){ len<-length(res@frameProcesses) result<-data.frame() for( j in seq_len(length(dyes))){ for (i in seq_len(len)){ patName<-res@frameProcesses[[i]]@frameID dist <-res@frameProcesses[[i]]@frameAggregators@.Data[[j]]@x passed <-res@frameProcesses[[i]]@frameAggregators@.Data[[j]]@passed tempRes<-data.frame(Patient=patName,Parameter=dyes[j],Passed=passed, Distance=dist,check.names=F) result<-rbind(result,tempRes) } } return(result) } ################################################### ### chunk number 19: ECDF plots 1 ################################################### #line 508 "vignettes/flowQ/inst/doc/DataQualityAssessment.Rnw" dyes<- c("FSC-A","SSC-A") resFSCECDF <- qaProcess.ECDFPlot(nData,dyes=dyes,outdir=dest,alpha=0.4,pdf=TRUE) #ecdfUrl<-writeQAReport(nData[[1]], list(resFSCECDF), outdir=dest,pdf=TRUE) #browseURL(ecdfUrl) ################################################### ### chunk number 20: genTblECDF ################################################### #line 516 "vignettes/flowQ/inst/doc/DataQualityAssessment.Rnw" imagePath<-resFSCECDF@summaryGraph@fileNames[2] getDistance(resFSCECDF,dyes) ################################################### ### chunk number 21: produceFSCECDFimage ################################################### #line 523 "vignettes/flowQ/inst/doc/DataQualityAssessment.Rnw" to <- paste(flowQ:::guid(), "pdf", sep=".") f <- file.copy(imagePath, to) cat('\\includegraphics[width=1.0\\textwidth]{', to, '}\n', sep="") ################################################### ### chunk number 22: ECDF plots 2 ################################################### #line 529 "vignettes/flowQ/inst/doc/DataQualityAssessment.Rnw" resCD8ECDF <- qaProcess.ECDFPlot(nData,dyes=c("CD8","CD27"),outdir=dest,alpha=0.4,pdf=TRUE) ################################################### ### chunk number 23: genTblECDF2 ################################################### #line 533 "vignettes/flowQ/inst/doc/DataQualityAssessment.Rnw" imagePath<-resCD8ECDF@summaryGraph@fileNames[2] getDistance(resCD8ECDF,c("CD8","CD27")) ################################################### ### chunk number 24: produceCD8ECDFimage ################################################### #line 541 "vignettes/flowQ/inst/doc/DataQualityAssessment.Rnw" to <- paste(flowQ:::guid(), "jpg", sep=".") f <- file.copy(imagePath, to) cat('\\includegraphics[width=1.0\\textwidth]{', to, '}\n', sep="") ################################################### ### chunk number 25: Density plots 1 ################################################### #line 593 "vignettes/flowQ/inst/doc/DataQualityAssessment.Rnw" resDensityFSC <- qaProcess.DensityPlot(nData,dyes=c("FSC-A","SSC-A"),outdir=dest,alpha=0.2,pdf=TRUE) #densityUrl<-writeQAReport(nData[[1]], list(resDensity), outdir=dest) #browseURL(densityUrl) ################################################### ### chunk number 26: genTblDens1 ################################################### #line 599 "vignettes/flowQ/inst/doc/DataQualityAssessment.Rnw" imagePath<-resDensityFSC@summaryGraph@fileNames[2] getDistance(resDensityFSC,c("FSC-A","SSC-A")) ################################################### ### chunk number 27: produceDensityFSC ################################################### #line 606 "vignettes/flowQ/inst/doc/DataQualityAssessment.Rnw" to <- paste(flowQ:::guid(), "jpg", sep=".") f <- file.copy(imagePath, to) cat('\\includegraphics[width=1.0\\textwidth]{', to, '}\n', sep="") ################################################### ### chunk number 28: Density plots 2 ################################################### #line 613 "vignettes/flowQ/inst/doc/DataQualityAssessment.Rnw" resDensityCD8 <- qaProcess.DensityPlot(nData,dyes=c("CD8","CD27"),outdir=dest,alpha=0.2,pdf=TRUE) ################################################### ### chunk number 29: produceDensityCD27 ################################################### #line 625 "vignettes/flowQ/inst/doc/DataQualityAssessment.Rnw" to <- paste(flowQ:::guid(), "jpg", sep=".") f <- file.copy(imagePath, to) cat('\\includegraphics[width=1.0\\textwidth]{', to, '}\n', sep="") ################################################### ### chunk number 30: 2DSummary_mean ################################################### #line 692 "vignettes/flowQ/inst/doc/DataQualityAssessment.Rnw" par<-c("FSC-A","SSC-A","CD4","CD8") resMean <- qaProcess.2DStatsPlot(nData,dyes=par,outdir=dest,func=mean, outBound=0.28,pdf=TRUE) imagePath <- resMean@summaryGraph@fileNames[2] #summaryUrl<-writeQAReport(nData[[1]], list(resMean), outdir=dest,pdf=TRUE) #browseURL(summaryUrl) ################################################### ### chunk number 31: 2Dsummaryplot_mean ################################################### #line 705 "vignettes/flowQ/inst/doc/DataQualityAssessment.Rnw" to <- paste(flowQ:::guid(), "jpg", sep=".") f <- file.copy(imagePath, to) cat('\\includegraphics[width=1.0\\textwidth]{', to, '}\n', sep="") ################################################### ### chunk number 32: 2DSummary_median ################################################### #line 711 "vignettes/flowQ/inst/doc/DataQualityAssessment.Rnw" par<-c("FSC-A","SSC-A","CD4","CD8") resMedian <- qaProcess.2DStatsPlot(nData,dyes=par,outdir=dest,func=median, outBound=0.28,pdf=TRUE) imagePath <- resMedian@summaryGraph@fileNames[2] #summaryUrl<-writeQAReport(nData[[1]], list(resMedian), outdir=dest,pdf=TRUE) #browseURL(summaryUrl) ################################################### ### chunk number 33: 2Dsummaryplot_median ################################################### #line 723 "vignettes/flowQ/inst/doc/DataQualityAssessment.Rnw" to <- paste(flowQ:::guid(), "jpg", sep=".") f <- file.copy(imagePath, to) cat('\\includegraphics[width=1.0\\textwidth]{', to, '}\n', sep="") ################################################### ### chunk number 34: KL Distance plots ################################################### #line 775 "vignettes/flowQ/inst/doc/DataQualityAssessment.Rnw" resKLdist <- qaProcess.KLDistPlot(nData,dyes=c("SSC-A","CD8"),outdir=dest,alpha=0.05,pdf=TRUE) writeQAReport(nData[[1]], list(resKLdist), outdir=dest) imagePath <- resKLdist@summaryGraph@fileNames[2] #browseURL(klDistURL) ################################################### ### chunk number 35: KLDistanceplot ################################################### #line 783 "vignettes/flowQ/inst/doc/DataQualityAssessment.Rnw" to <- paste(flowQ:::guid(), "jpg", sep=".") f <- file.copy(imagePath, to) cat('\\includegraphics[width=1.0\\textwidth]{', to, '}\n', sep="")