cytoqc -- A standardization tool for openCyto

cytoqc checks and standardizes channels, markers, keywords, gates of the cytodata .

knitr::opts_chunk$set(warning = FALSE, message = FALSE)
library(knitr)

Installation

remotes::install_github("RGLab/cytoqc")

Get started

library(flowCore)
library(flowWorkspace)
library(cytoqc)
# prepare the test data
data("GvHD")
fs <- GvHD[8:28]#exclude samples that has different Time length
data_dir <- tempfile()
dir.create(data_dir)
write.flowSet(fs, data_dir)

Load the FCS

files <- list.files(data_dir, ".fcs", full.names = TRUE)
cqc_data <- cqc_load_fcs(files)
cqc_data
#simulate channel discrepancy

#case
cf <- cqc_data[[1]]
colnames(cf)[1] <- "fsc-h"

#missing
cqc_data[[1]] <- cf[,1:7]


#redundant
thisfile <- files[2]
fr <- read.FCS(thisfile)
new_col <- exprs(fr)[,8,drop=F]
colnames(new_col) <- "channelA"
fr <- fr_append_cols(fr, new_col)
write.FCS(fr, files[2])
cqc_data[[2]] <- load_cytoframe_from_fcs(thisfile, is_h5 = TRUE)

#typo
cf <- cqc_data[[2]]
colnames(cf)[2] <- "SSC1-H"

#both case and typo
cf <- cqc_data[[3]]
colnames(cf)[1:2] <- c("fsc-h", "SSC1-H")

#order
cf <- cqc_data[[4]]
cf_swap_colnames(cf, "FL1-H", "FL2-H")

The basic workflow can be summarised as four steps:

  1. check
  2. match
  3. fix

1. Check the consistency across samples

check_results <- cqc_check(cqc_data, type = "channel")
check_results

2. Match the reference

res <- cqc_match(check_results, ref = 3) 
res

3. Apply the fix

cqc_fix(res)

Update check report

check_results <- cqc_check(cqc_data, type = "channel")
check_results

Return the cleaned data

cqc_data <- cqc_get_data(check_results)
cqc_data

Coerce it inot cytoset

cytoset(cqc_data)

Or output to FCS

cqc_write_fcs(cqc_data, outdir)


RGLab/cytoqc documentation built on Jan. 25, 2023, 11:05 p.m.