DillonHammill / CytoExploreR

Interactive Cytometry Data Analysis
60 stars 13 forks source link

Renaming of files #131

Open simonuoft opened 2 years ago

simonuoft commented 2 years ago

Hi, I would like to rename files but didn't find the proper way to do it.

I have a list of around 30 *.fcs files named sample1, sample2, sample3 etc... I created a gattingset containing all the files using the cyto_setup function. then I tried to apply this code :

samplelist<-c("non treated", "0,5um", "1um" all the way to 30)
cyto_names(data)<-samplelist

That works and change the names (if i type cyto_names(data) i see the names have been modified) However then when I try to plot or draw gate I got error such as : Error in .cpp_getNodes(x@pointer, sampleNames(x)[1], as.integer(orderInd), : NA not found! or Error : Subset out of bounds

Any inputs/idea about what I'm doing wrong ? Thanks in advance

DillonHammill commented 2 years ago

@simonuoft, you have replaced the names in the correct way. The problem is that after changing the names cyto_names() becomes out of sync with the uri of the cytoframes - I have addressed this problem in version 2.0.0 of CytoExploreR which is around the corner.

In the meantime, I would recommend writing the FCS files with the desired names and then read them back into CytoExploreR, then everything should be in sync again.

# Replace names
cyto_names(data) <- c("x.fcs", "y.fcs", "z.fcs")
# Write new FCS files
cyto_save(
    data, 
    parent = "root", 
    save_as = "Renamed-FCS-Files", 
    names = c("x.fcs", "y.fcs","z.fcs"),
    inverse = TRUE
)
# Reload new FCS files
data <- cyto_setup("Renamed-FCS-Files")

Tip: you can also save the entire GatingSet using cyto_save() just leave out the parent argument. This saved GatingSet retains all your analyses and can be reloaded using cyto_setup() as above.