Skip to contents

Transfer the .fcs files selected by LuciernagaTree to a new location

Usage

Luciernaga_Move(x, data, input, output)

Arguments

x

A vector containing fluorophore names found within data.

data

The data.frame output of LuciernagaTree listing files to be moved.

input

The path to the current storage location of the .fcs files.

output

The path to the desired future storage location of the selected files.

Value

No return, .fcs files are moved desired folder.

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)