This is a test version of Biostars. For the public version, visit https://www.biostars.org.
renaming flow frames in a flowSet using flowCore

I'm working with flow cytometry data and I'm reading a set of FCS files into a flowSet using flowCore. By default the individual frames for the FCS files are named with the file name of the FCS file which is long and cumbersome. I would like to rename the frames in the flowSet object without changing the filenames (or copying them and renaming the copies) Is there anyway to do this? I could not find an explanation on how to rename frames in the flowCore documentation. This is what I have tried:

fs <- read.flowSet(sample_files, emptyValue=F, identifier=str_extract(sample_files,'sample_\\d+\\.fcs$'))

However the frames are still identified by the full cumbersome file name instead of a shorter string. Is there a way to rename them during the call to read.flowSet or rename them after the flowSet object is created?

flow cytometry r flowcore

Have you taken a look at the pData() slot for fs? Otherwise, try running str(fs) to see how the internal objects are structured and arranged.

1 answer

I think the key could be changing the GUID of each flowFrame, however, the method sampleNames() should take care of it, after you load the flowSet:

sampleNames(fs) = str_extract(sample_files,'sample_\\d+\\.fcs$')

This worked! Thank you!

For future reference I did the following:

sampleNames(fs) <- str_extract(sample_files,'sample_\\d+\\.fcs$')
pData(fs)$name <- str_extract(sample_files,'sample_\\d+\\.fcs$')

This changes the flow frame reference in the flowset object and changing the name field in pData changes how ggcyto labels the plots. sampleNames is part of the flowWorkspace package.

Please mark as Accepted (the answer)

Log in to answer this question.