QC for DC panel

library(flowCore)
library(flowWorkspace)
# library(cytoqc)
devtools::load_all()
path <- "~/remote/fh/fast/gottardo_r/mike_working/lyoplate_out/parsed"
centers <- c('BIIR','CIMR','Miami','NHLBI','Stanford','UCLA','Yale')

Load gs

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

Check marker

cqc_data <- cqc_gs_list(gslist)
check_res <- cqc_check(cqc_data, "marker")
check_res
group_id nGatingSet marker
1 1 CD11c PE-Cy7, CD123 PerCP-Cy55, CD14 V450, CD16 APC, CD56 PE, HLA-DR V500, Lineage APC-H7, Live Dead FITC
2 1 CD11c, CD123, CD14, CD16, CD3_CD19_CD20, CD56, HLADR, LIVE_GREEN
3 1 CD11C, CD123, CD14, CD16, CD3+19+20, CD56, HLA-DR, LIVE DEAD
4 1 CD11c, CD123, CD14, CD16, CD3+CD19+CD20+, CD56, HLA-DR, Live Green
5 1 CD11c, CD123, CD14, CD16, CD3+CD19+CD20, CD56, HLA DR, Live/Dead
6 1 CD11c, CD123, CD14, CD16, CD3+CD19+CD20, CD56, HLA-DR, Live Green
7 1 CD11c, CD123, CD14, CD16, CD3CD19CD20, CD56, HLA-DR, LIVE

Match reference

match_res <- cqc_match(check_res, ref = 7, max.dist = 0.6)
match_res

Manually update the match

match_res <- cqc_update_match(match_res, c("Lineage APC-H7" = "CD3CD19CD20"))
match_res

Apply the match

cqc_fix(match_res)
cqc_check(cqc_data, "marker")
group_id nGatingSet marker
1 7 CD11c, CD123, CD14, CD16, CD3CD19CD20, CD56, HLA-DR, LIVE

Check panel

res <- cqc_check(cqc_data, "panel")
format(res, anchor = "marker")

Standarize the panel

cf <- get_cytoframe_from_cs(cqc_data[[1]], 1)

pnl <- cf_get_panel(cf, skip_na = T)
pnl
## # A tibble: 8 x 2
##   channel         marker     
##   <I<chr>>        <I<chr>>   
## 1 <APC-A>         CD16       
## 2 <APC-H7-A>      CD3CD19CD20
## 3 <FITC-A>        LIVE       
## 4 <PerCP-Cy5-5-A> CD123      
## 5 <V450-A>        CD14       
## 6 <V500-A>        HLA-DR     
## 7 <PE-A>          CD56       
## 8 <PE-Cy7-A>      CD11c
cqc_set_panel(cqc_data, pnl, ref.col = "marker")
cqc_check(cqc_data, "panel")

check gates

res <- cqc_check(cqc_data, "gate")
res
group_id nGatingSet gate
3 5 11c- 123-, 11c- 123+, 11c+ 123-, 11c+ 123+, 14+ 16+, 16- 56-, 16- 56+, 16+ 56-, 16+ 56+, DR+, Lin- 14-, Lin- 14+, MNC, not dead, root, singlets
1 1 11c - 123+, 11c- 123-, 11c+ 123-, 11c+ 123+, 14+ 16+, 16- 56-, 16- 56+, 16+ 56-, 16+ 56+, DR+, Lin- 14-, Lin- 14+, MNC, not dead, root, singlets
2 1 11c- 123-, 11c- 123+, 11c+ 123-, 11c+ 123+, 14+ 16+, 16- 56-, 16- 56+, 16+ 56-, 16+ 56+, DR+, Lin- 14-, Lin- 14+, MNC, not dead, root
diff(res)
group_id nGatingSet gate
3 5 11c- 123+, singlets
1 1 11c - 123+, singlets
2 1 11c- 123+
match_res <- cqc_match(res, ref = 2)
match_res

Singlets are not important for analysis thus can be safely deleted (actually hidden)

cqc_fix(match_res)

Check channel again

res <- cqc_check(cqc_data, "channel")
res
group_id nGatingSet channel
1 4 <APC-A>, <APC-H7-A>, <FITC-A>, <PE-A>, <PE-Cy7-A>, <PerCP-Cy5-5-A>, <V450-A>, <V500-A>, FSC-A, FSC-H, FSC-W, SSC-A, SSC-H, SSC-W, Time
2 1 <APC-A>, <APC-H7-A>, <FITC-A>, <PE-A>, <PE-Cy7-A>, <PerCP-Cy5-5-A>, <V450-A>, <V500-A>, FSC-A, FSC-H, SSC-A, SSC-H, Time
3 1 <APC-A>, <APC-H7-A>, <FITC-A>, <PE-A>, <PE-Cy7-A>, <PerCP-Cy5-5-A>, <V450-A>, <V500-A>, FSC-A, FSC-W, SSC-A, SSC-W, Time
4 1 <APC-A>, <APC-H7-A>, <FITC-A>, <PE-A>, <PE-Cy7-A>, <PerCP-Cy5-5-A>, <V450-A>, <V500-A>, FSC-A, SSC-A, Time
match_res <- cqc_match(res, ref = 4)
match_res

W/H scatter are for singlets gate thus can be safely removed

cqc_fix(match_res)

Merge the standarized data

gs <- merge_list_to_gs(gslist)
gs
## A GatingSet with 7 samples