Parser fails due to the inconsistent channels across FCS files

library(CytoML)
ws <- open_flowjo_xml(wsfile)
gs <- flowjo_to_gatingset(ws, name = 4, path = fcsdir, subset = 1:2)
## Error in get_cytoset(x@pointer): Found channel inconsistency across samples. 'redundant' is missing from CytoTrol_CytoTrol_2.fcs_115728

Use cytoqc to clean up data

Load FCS

library(cytoqc)
rawfiles <- list.files(fcsdir, ".fcs", full.names = TRUE)
cqc_data <- cqc_load_fcs(rawfiles)

check

check_res <- cqc_check(cqc_data, type = "channel")
check_res
group_id nFCS channel
1 1 B710-A, FSC-A, FSC-H, FSC-W, G560-A, G780-A, R660-A, R780-A, redundant, SSC-A, Time, V450-A, V545-A
2 1 B710-A, FSC-A, FSC-H, FSC-W, G560-A, G780-A, R660-A, R780-A, SSC-A, Time, V450-A, V545-A

pick reference to match

match_res <- cqc_match(check_res, ref = 2)
match_res

fix the problem

cqc_fix(match_res)

check again to ensure data is standardized

cqc_check_channel(cqc_data)
group_id nFCS channel
1 2 B710-A, FSC-A, FSC-H, FSC-W, G560-A, G780-A, R660-A, R780-A, SSC-A, Time, V450-A, V545-A

coerce data to cytoset (zero-copy)

cs <- cytoset(cqc_data)

Now pass the standardized data (cytoset) to parser

gs <- flowjo_to_gatingset(ws, name = 4, cytoset = cs, subset = 1:2)
library(ggcyto)
autoplot(gs[[1]])

No extra copy of fcs or h5 files

#gatingset shares the data with cytoset
cf_get_h5_file_path(get_cytoframe_from_cs(gs_cyto_data(gs), 1))
## [1] "/tmp/RtmpNOtnAm/file694163693e8b.h5"
cf_get_h5_file_path(cs[[1, return = "cytoframe"]])
## [1] "/tmp/RtmpNOtnAm/file694163693e8b.h5"

Note that cs is also modified in-place during parsing