devtools::load_all("~/rglab/workspace/flowWorkspace")
library(SingleCellExperiment)
backend_mode <<- "mem"
set_default_backend(backend_mode)
fcs_file <- list.files(dataDir, "Cyto", full.names = TRUE)[1]
cf <- load_cytoframe_from_fcs(fcs_file)[, 3:6]

Default with no row names

cf
## cytoframe object 'CytoTrol_CytoTrol_1.fcs'
## with 119531 cells and 4 observables:
##            name        desc     range  minRange  maxRange
## $P3       FSC-W          NA    262143         0    262143
## $P4       SSC-A          NA    262143         0    262143
## $P5      B710-A CD4 PcpCy55    262143      -111    262143
## $P6      R660-A    CD38 APC    262143      -111    262143
## 199 keywords are stored in the 'description' slot
## row names(0):
## cytoframe has been subsetted and can be realized through 'realize_view()'.
rownames(cf)
## NULL
head(exprs(cf))
##         FSC-W     SSC-A   B710-A   R660-A
## [1,] 69150.98  91113.96 22311.24 35576.07
## [2,] 65506.79  10115.28     5.04   447.93
## [3,] 81667.89 174620.03   371.28   851.62
## [4,] 81210.08 150625.44  1494.36  5672.20
## [5,] 69974.92  76954.91  2545.20  2272.83
## [6,] 70071.60  70116.48 23052.96  1758.54

add rownames

rn <- paste0("c", seq_len(nrow(cf)))
rownames(cf) <- rn
cf
## cytoframe object 'CytoTrol_CytoTrol_1.fcs'
## with 119531 cells and 4 observables:
##            name        desc     range  minRange  maxRange
## $P3       FSC-W          NA    262143         0    262143
## $P4       SSC-A          NA    262143         0    262143
## $P5      B710-A CD4 PcpCy55    262143      -111    262143
## $P6      R660-A    CD38 APC    262143      -111    262143
## 199 keywords are stored in the 'description' slot
## row names(119531): c1 c2 ... c119530 c119531
## cytoframe has been subsetted and can be realized through 'realize_view()'.
head(rownames(cf))
## [1] "c1" "c2" "c3" "c4" "c5" "c6"
head(exprs(cf))
##       FSC-W     SSC-A   B710-A   R660-A
## c1 69150.98  91113.96 22311.24 35576.07
## c2 65506.79  10115.28     5.04   447.93
## c3 81667.89 174620.03   371.28   851.62
## c4 81210.08 150625.44  1494.36  5672.20
## c5 69974.92  76954.91  2545.20  2272.83
## c6 70071.60  70116.48 23052.96  1758.54

subset

cf1 <- cf[2:4, ]
cf1
## cytoframe object 'CytoTrol_CytoTrol_1.fcs'
## with 3 cells and 4 observables:
##            name        desc     range  minRange  maxRange
## $P3       FSC-W          NA    262143         0    262143
## $P4       SSC-A          NA    262143         0    262143
## $P5      B710-A CD4 PcpCy55    262143      -111    262143
## $P6      R660-A    CD38 APC    262143      -111    262143
## 199 keywords are stored in the 'description' slot
## row names(3): c2 c3 c4
## cytoframe has been subsetted and can be realized through 'realize_view()'.

update subset also affect the original cf

rn1 <- rownames(cf1)
rn1 <- sub("c", "D", rn1)
rownames(cf1) <- rn1
head(exprs(cf1))
##       FSC-W     SSC-A  B710-A  R660-A
## D2 65506.79  10115.28    5.04  447.93
## D3 81667.89 174620.03  371.28  851.62
## D4 81210.08 150625.44 1494.36 5672.20
head(exprs(cf))
##       FSC-W     SSC-A   B710-A   R660-A
## c1 69150.98  91113.96 22311.24 35576.07
## D2 65506.79  10115.28     5.04   447.93
## D3 81667.89 174620.03   371.28   851.62
## D4 81210.08 150625.44  1494.36  5672.20
## c5 69974.92  76954.91  2545.20  2272.83
## c6 70071.60  70116.48 23052.96  1758.54

prohibit the rownames deletion from subset (since it will delete the entire rownames of original cf)

rownames(cf1) <- NULL
## Error in del_rownames(x@pointer): Cannot delete the rownames from a subsetted CytoFrameView!

delete rownames from original cf also affect the subset

rownames(cf) <- NULL
head(exprs(cf1))
##         FSC-W     SSC-A  B710-A  R660-A
## [1,] 65506.79  10115.28    5.04  447.93
## [2,] 81667.89 174620.03  371.28  851.62
## [3,] 81210.08 150625.44 1494.36 5672.20
head(exprs(cf))
##         FSC-W     SSC-A   B710-A   R660-A
## [1,] 69150.98  91113.96 22311.24 35576.07
## [2,] 65506.79  10115.28     5.04   447.93
## [3,] 81667.89 174620.03   371.28   851.62
## [4,] 81210.08 150625.44  1494.36  5672.20
## [5,] 69974.92  76954.91  2545.20  2272.83
## [6,] 70071.60  70116.48 23052.96  1758.54