Calculates the single color control matrix for a given quantile cutoffs and a given statistic
Source:R/Luciernaga_SingleColors.R
Luciernaga_SingleColors.Rd
Calculates the single color control matrix for a given quantile cutoffs and a given statistic
Usage
Luciernaga_SingleColors(
x,
sample.name,
removestrings,
subset,
PanelCuts,
stats,
SignatureView,
Verbose = FALSE,
returntype = "data"
)
Arguments
- x
A Gating Set Object
- sample.name
The Keyword for which the Fluorophore Name is stored
- removestrings
Values to remove from the name
- subset
A desired Gating Hierarchy level of cells to filter in
- PanelCuts
A .csv or dataframe containing columns Fluorophore, From and To Fluorophore name should match sample.name style
- stats
Whether to use "mean" or "median"
- SignatureView
Whether to also return a normalized signature plot.
- Verbose
Provides debugging for removestrings
- returntype
Allows to modify default "data" to instead return the "plots"
Examples
library(flowCore)
library(flowWorkspace)
library(openCyto)
library(data.table)
library(dplyr)
library(purrr)
library(stringr)
StorageLocation <- file.path(tempdir(), "LuciernagaTreeExample")
if (!dir.exists(StorageLocation)) {dir.create(StorageLocation)}
File_Location <- system.file("extdata", package = "Luciernaga")
FCS_Files <- list.files(path = File_Location, pattern = ".fcs",
full.names = TRUE)
CellSingleColorFiles <- FCS_Files[grep("Cells", FCS_Files)]
CellSingleColors <- CellSingleColorFiles[!str_detect("Unstained", CellSingleColorFiles)]
MyCytoSet <- load_cytoset_from_fcs(CellSingleColors,
truncate_max_range = FALSE,transformation = FALSE)
MyGatingSet <- GatingSet(MyCytoSet)
MyGates <- fread(file.path(path = File_Location, pattern = 'Gates.csv'))
MyGatingTemplate <- gatingTemplate(MyGates)
#> Adding population:singletsFSC
#> Adding population:singletsSSC
#> Adding population:singletsSSCB
#> Adding population:nonDebris
#> Adding population:lymphocytes
gt_gating(MyGatingTemplate, MyGatingSet)
#> Gating for 'singletsFSC'
#> done!
#> done.
#> Gating for 'singletsSSC'
#> done!
#> done.
#> Gating for 'singletsSSCB'
#> done!
#> done.
#> Gating for 'nonDebris'
#> done!
#> done.
#> Gating for 'lymphocytes'
#> The prior specification has no effect when usePrior=no
#> Using the serial version of flowClust
#> The prior specification has no effect when usePrior=no
#> Using the serial version of flowClust
#> The prior specification has no effect when usePrior=no
#> Using the serial version of flowClust
#> The prior specification has no effect when usePrior=no
#> Using the serial version of flowClust
#> The prior specification has no effect when usePrior=no
#> Using the serial version of flowClust
#> The prior specification has no effect when usePrior=no
#> Using the serial version of flowClust
#> The prior specification has no effect when usePrior=no
#> Using the serial version of flowClust
#> The prior specification has no effect when usePrior=no
#> Using the serial version of flowClust
#> The prior specification has no effect when usePrior=no
#> Using the serial version of flowClust
#> The prior specification has no effect when usePrior=no
#> Using the serial version of flowClust
#> The prior specification has no effect when usePrior=no
#> Using the serial version of flowClust
#> The prior specification has no effect when usePrior=no
#> Using the serial version of flowClust
#> The prior specification has no effect when usePrior=no
#> Using the serial version of flowClust
#> The prior specification has no effect when usePrior=no
#> Using the serial version of flowClust
#> The prior specification has no effect when usePrior=no
#> Using the serial version of flowClust
#> The prior specification has no effect when usePrior=no
#> Using the serial version of flowClust
#> The prior specification has no effect when usePrior=no
#> Using the serial version of flowClust
#> The prior specification has no effect when usePrior=no
#> Using the serial version of flowClust
#> The prior specification has no effect when usePrior=no
#> Using the serial version of flowClust
#> The prior specification has no effect when usePrior=no
#> Using the serial version of flowClust
#> The prior specification has no effect when usePrior=no
#> Using the serial version of flowClust
#> The prior specification has no effect when usePrior=no
#> Using the serial version of flowClust
#> The prior specification has no effect when usePrior=no
#> Using the serial version of flowClust
#> The prior specification has no effect when usePrior=no
#> Using the serial version of flowClust
#> The prior specification has no effect when usePrior=no
#> Using the serial version of flowClust
#> The prior specification has no effect when usePrior=no
#> Using the serial version of flowClust
#> The prior specification has no effect when usePrior=no
#> Using the serial version of flowClust
#> The prior specification has no effect when usePrior=no
#> Using the serial version of flowClust
#> The prior specification has no effect when usePrior=no
#> Using the serial version of flowClust
#> The prior specification has no effect when usePrior=no
#> Using the serial version of flowClust
#> done!
#> done.
#> finished.
UnstainedFCSFiles <- FCS_Files[grep("Unstained", FCS_Files)]
UnstainedCells <- UnstainedFCSFiles[-grep("Beads", UnstainedFCSFiles)]
MyUnstainedCytoSet <- load_cytoset_from_fcs(UnstainedCells[1],
truncate_max_range = FALSE,transformation = FALSE)
MyUnstainedGatingSet <- GatingSet(MyUnstainedCytoSet)
gt_gating(MyGatingTemplate, MyUnstainedGatingSet)
#> Gating for 'singletsFSC'
#> done!
#> done.
#> Gating for 'singletsSSC'
#> done!
#> done.
#> Gating for 'singletsSSCB'
#> done!
#> done.
#> Gating for 'nonDebris'
#> done!
#> done.
#> Gating for 'lymphocytes'
#> The prior specification has no effect when usePrior=no
#> Using the serial version of flowClust
#> done!
#> done.
#> finished.
removestrings <- c(".fcs", "(", ")", "Cells")
FileLocation <- system.file("extdata", package = "Luciernaga")
pattern = "AutofluorescentOverlaps.csv"
AFOverlap <- list.files(path=FileLocation, pattern=pattern, full.names = TRUE)
TheCellAF <- Luciernaga_QC(x=MyUnstainedGatingSet[[1]], subsets="nonDebris",
removestrings=removestrings, sample.name="GUID", unmixingcontroltype = "cells",
Unstained = TRUE, ratiopopcutoff = 0.001, Verbose = FALSE,
AFOverlap = AFOverlap, stats = "median", ExportType = "fcs",
Brightness=TRUE, SignatureReturnNow = TRUE, outpath = StorageLocation,
Increments=0.1, SecondaryPeaks=2, experiment = "FirstExperiment",
condition = "ILTPanel", Subtraction = "Internal", CellAF=TheCellAF,
SCData="subtracted",NegativeType="default", minimalfcscutoff=0.01)
#> Normalizing Data for Signature Comparison
MyGatingSet <- subset(MyGatingSet, !str_detect(name, "CD14"))
SingleColor_Data <- map(.x=MyGatingSet, .f=Luciernaga_QC,
subsets="lymphocytes", removestrings=removestrings, sample.name="GUID",
unmixingcontroltype = "cells", Unstained = FALSE, ratiopopcutoff = 0.001,
Verbose = FALSE, AFOverlap = AFOverlap, stats = "median", ExportType = "fcs",
Brightness=TRUE, SignatureReturnNow = FALSE,outpath = StorageLocation,
Increments=0.1, SecondaryPeaks=2, experiment = "FirstExperiment",
condition = "ILTPanel", Subtraction = "Internal", CellAF=TheCellAF,
SCData="subtracted",NegativeType="default", minimalfcscutoff=0.02)
#> No second peak
#> No second peak
#> No second peak
#> Only a single detector present. If this was not an autofluorescence overlap
#> fluourophore, it would suggest there was no antibody staining, or everything
#> was overstained. Please investigate further.
#> No second peak
#> No second peak
#> No second peak
Unstained_Data <- map(.x=MyUnstainedGatingSet, .f=Luciernaga_QC,
subsets="nonDebris", removestrings=removestrings, sample.name="GUID",
unmixingcontroltype = "cells", Unstained = TRUE, ratiopopcutoff = 0.001,
Verbose = FALSE, AFOverlap = AFOverlap, stats = "median", ExportType = "fcs",
Brightness=TRUE, SignatureReturnNow = FALSE, outpath = StorageLocation,
Increments=0.1, SecondaryPeaks=2, experiment = "FirstExperiment",
condition = "ILTPanel", Subtraction = "Internal", CellAF=TheCellAF,
SCData="subtracted",NegativeType="default", minimalfcscutoff=0.01)
PanelPath <- file.path(File_Location, "UnmixingPanel.csv")
MoveThese <- Luciernaga_Tree(BrightnessFilePath = StorageLocation,
PanelPath = PanelPath)
SortedStorageLocation <- file.path(tempdir(), "LuciernagaSelected")
if (!dir.exists(SortedStorageLocation)) {dir.create(SortedStorageLocation)}
UnmixingPanel <- read.csv(PanelPath, check.names=FALSE)
TheseFluorophores <- UnmixingPanel %>% pull(Fluorophore)
walk(.x=TheseFluorophores, .f=Luciernaga_Move, data=MoveThese,
input=StorageLocation, output=SortedStorageLocation)
MovedFiles <- list.files(SortedStorageLocation, pattern="fcs", full.names=TRUE)
UnmixingPanel <- read.csv(PanelPath, check.names=FALSE)
ThePanelCuts <- UnmixingPanel %>% select(-Detector) %>%
mutate(From=0.3) %>% mutate(To=1)
MovedFiles <- list.files(SortedStorageLocation,
pattern="fcs", full.names=TRUE)
Selected_CS <- load_cytoset_from_fcs(MovedFiles[1],
truncate_max_range = FALSE, transform = FALSE)
Selected_GS <- GatingSet(Selected_CS)
removestrings=c("DR_", ".fcs")
SCs <- map(.x=Selected_GS[1], .f=Luciernaga_SingleColors,
sample.name="TUBENAME", removestrings=removestrings, subset="root",
PanelCuts=ThePanelCuts, stats="median", Verbose=TRUE, SignatureView=TRUE,
returntype = "plots")
#> After removestrings cleanup the name is CCR4 BUV615
#> The Fluorophore is BUV615 and the ligand is CCR4