Generates cosine comparison from a data.frame of fluorescent signatures
Source:R/Luciernaga_Cosine.R
Luciernaga_Cosine.Rd
Generates cosine comparison from a data.frame of fluorescent signatures
Usage
Luciernaga_Cosine(
data,
returntype = "plot",
rearrange = TRUE,
colorlow = "lightblue",
colorhigh = "red",
limitlow = 0.4,
limithigh = 1,
legend = TRUE
)
Arguments
- data
A data.frame with a single name column and rest numeric columns
- returntype
Default returns "plot", alternatively "data" for underlying data
- rearrange
Whether to rearrange the plot to group similar signatures
- colorlow
Default "lightblue"
- colorhigh
Default "orange"
- limitlow
Default 0.4
- limithigh
Default 1
- legend
Default TRUE
Examples
library(flowCore)
library(flowWorkspace)
library(openCyto)
library(data.table)
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:data.table':
#>
#> between, first, last
#> The following object is masked from 'package:flowCore':
#>
#> filter
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
File_Location <- system.file("extdata", package = "Luciernaga")
FCS_Files <- list.files(path = File_Location, pattern = ".fcs",
full.names = TRUE)
UnstainedFCSFiles <- FCS_Files[grep("Unstained", FCS_Files)]
UnstainedCells <- UnstainedFCSFiles[-grep("Beads", UnstainedFCSFiles)]
MyCytoSet <- load_cytoset_from_fcs(UnstainedCells[1],
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
#> done!
#> done.
#> finished.
removestrings <- c("DR_", "Cells", ".fcs", "-", " ")
StorageLocation <- file.path("C:", "Users", "JohnDoe", "Desktop")
PopulationInterest <- gs_pop_get_data(MyGatingSet[1], subset="lymphocytes")
TheDataValues <- exprs(PopulationInterest[[1]])
TheDataValues <- data.frame(TheDataValues, check.names=FALSE)
Signature <- AveragedSignature(TheDataValues, stats="median")
TheData1 <- Signature[,-grep("Time|FS|SC|SS|Original|W$|H$", names(Signature))]
TheData1 <- TheData1 %>% mutate(Sample="lymphocytes") %>%
relocate(Sample, .before=1)
PopulationInterest <- gs_pop_get_data(MyGatingSet[1], subset="nonDebris")
TheDataValues <- exprs(PopulationInterest[[1]])
TheDataValues <- data.frame(TheDataValues, check.names=FALSE)
Signature <- AveragedSignature(TheDataValues, stats="median")
TheData2 <- Signature[,-grep("Time|FS|SC|SS|Original|W$|H$", names(Signature))]
TheData2 <- TheData2 %>% mutate(Sample="nonDebris") %>%
relocate(Sample, .before=1)
FinalData <- rbind(TheData1, TheData2)
Plot <- Luciernaga_Cosine(data=FinalData, returntype="plot")