Skip to content

prep_fcd(): adjust max_cell for each file #46

@Muffin2001

Description

@Muffin2001

Problem

From a set of .fcs files, I need to import a different number of events from each file. prep_fcd() only allows for one max_cell parameter for the whole process. Technically, one could separately generate .fcs files with a specific number of cells for each file e.g. manually from FlowJO, but that's annoying and not open source. Separate prep_fcd() for separate files with subsequent merge_condor() might look like it works, but separate imports mean separate and therefore different transformations, as (according to my understanting) e.g. autologi transformation fits its parameters to the input data.

New prep_fcd_man() function

So I edited the code from cyCONDOR/R/data_load_and_transform.R to make my own prep_fcd_man() function using a vector max_cell_vec instead of max_cell. It's just very few changes in the code, but works very well for me.

For practicability and cleanliness reasons I can recommend this: I keep the code in a separate R script file that I "import" via source(file_path/file_name.R) - alongside other shenanigans, color palettes, and other custom functions.

I would also appreaciate it if it became a feature of the anno table interpretation, so that I could specify in the anno table how many cells to use from which sample, and maybe even a warning message if the desired number of cells is not there.

Source Code

A minimally edited working copy of the edited cyCONDOR/R/data_load_and_transform.R code is attached as .txt file because I don't know how to make pull requests (lol), so you just copy-paste it into an R script, save it and source it from there.
I think I marked all lines of code where I changed it (~10 lines I think), and renamed all changed functions to not impair existing functions. I had to import flowCore for the "read.FCS()" function.

New Input

Here is how the new input looks like in my case:

source(file_path/prep_fcd_man.R)
max_cell_vec_test <- c(50, 40, 30, rep(20, 60), 1, 70000, 20251031)     # here, rep(20, 60) generates 60 vector entries of 20

condor  <- prep_fcd_man(data_path = ("file_path"),
                   max_cell_vec = max_cell_vec_test,           # this is the new input
                   useCSV = FALSE, 
                   anno_table = "anno_table.csv",
                   filename_col = "filename",
                   separator_anno = ";",
                   transformation = "auto_logi",
                   seed = 91)

I would also like to give a shoutout to all the trees that I see through my window

They are loosing their leaves
because it is autumn.

prep_fcd_man.txt

Metadata

Metadata

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions