library(knitr)
knitr::opts_chunk$set(warning = FALSE, message = FALSE)
library(kableExtra)
library(flowCore)
library(flowWorkspace)
library(cytoqc)
path <- "~/remote/fh/fast/gottardo_r/mike_working/lyoplate_out/parsed"
centers <- c('BIIR','CIMR','Miami','NHLBI','Stanford','UCLA','Yale')

Load gs

panel <- "bcell"
gslist <- sapply(centers, function(center) {
  message("Center: ", center)
  gs <- load_gs(file.path(path, center, panel))
})

QC Check gates

cqc_data <- cqc_gs_list(gslist)

#group by gates
groups <- cqc_check(cqc_data, "gate")
groups
#vis the difference
plot_diff(groups)

# match reference
match_result <- cqc_match(groups, ref = 1, select = c(2))
match_result

cqc_fix(match_result)

cqc_check(cqc_data, "gate")

QC check for channel

groups <- cqc_check(cqc_data, "channel")
groups

Channels are very different across centers so move on to check marker

#summarise marker groups
groups <- cqc_check(cqc_data, "marker")
groups

Markers are more standardized and go ahead to further clean it

res <- cqc_match(groups, ref = 2) 
res

Apply the fix and update checks

cqc_fix(solution)
cqc_check(cqc_data, "marker")

Relax string matching to clean up the rest

res <- cqc_match(groups, ref = 2, select = c(1)) 
res

solution <- cqc_recommend(res, max.distance = 0.7)
solution
cqc_fix(solution)

groups <- cqc_check(cqc_data, "marker")
knit_print(summary(groups))

Use the marker as reference to standardize the channels across centers

panel <- cf_get_panel(gs_cyto_data(cqc_data[[1]])[[1]], skip_na = TRUE)
panel
cqc_set_panel(cqc_data, panel, ref.col = "marker")
groups <- cqc_check(cqc_data, "panel")
knit_print(summary(groups))

Refresh QC report

groups <- cqc_check(cqc_data, "channel")
su <- summary(groups)
knit_print(su)
knit_print(diff(su))

Remove H/W channels

res <- cqc_match(groups, ref = 4, select = c(1,2,3)) 
res

solution <- cqc_recommend(res, max.distance = 0.6)
solution
cqc_fix(solution)

Coerce it directly into single GatingSet (zero-copying)

gs <- merge_list_to_gs(cqc_data)
gs


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