rprops / Phenoflow_package

R package offering functionality for the advanced analysis of microbial flow cytometry data
GNU General Public License v2.0
9 stars 5 forks source link

functionality of FCS_pool and assigning a vector to stub #71

Closed carolina671 closed 2 years ago

carolina671 commented 2 years ago

Hi, I wanted to ask about the functionality of FCS_pool as I am looking for a way to pool or concatenate specific frames of a flowSet object. I have replicates for a single sample and would like to combine the files by row (cells) as they have the same columns (channels). I tried FCS_pool function but i just end up with a flowframe with the same amount of replicates, is this what the function does? or am I using it wrong?

print(sample 1) [1] "New AS Plate 21_AS Plate_Sample 1_100.fcs" "New AS Plate 21_AS Plate_Sample 1_25.fcs" [3] "New AS Plate 21_AS Plate_Sample 1_250.fcs" "New AS Plate 21_AS Plate_Sample 1_50.fcs" [5] "New AS Plate 21_AS Plate_Sample 1_500.fcs"

length(flowData) [1] 90

flowdata1= FCS_pool(flowData, stub= print(sample 1)) [1] "New AS Plate 21_AS Plate_Sample 1_100.fcs" "New AS Plate 21_AS Plate_Sample 1_25.fcs" [3] "New AS Plate 21_AS Plate_Sample 1_250.fcs" "New AS Plate 21_AS Plate_Sample 1_50.fcs" [5] "New AS Plate 21_AS Plate_Sample 1_500.fcs"

length(flowdata1) [1] 5

Also i tried to create a loop to produce multiple flowdata frames from the corresponding sample( > flowdata1= FCS_pool(flowData, stub= print(sample 1)), > flowdata2= FCS_pool(flowData, stub= print(sample 2)).... and so on )but since the stub pattern is a character vector I have not figure out how to change the number of the i vector. Maybe any ideas on how to solve this issue?

for(i in 1:18) {

  • assign(paste0("flowdata", i), FCS_pool(flowData, stub= print(sample i)))} Error in print(sample i) : object 'sample i' not found

Thanks,

rprops commented 2 years ago

Hi @carolina671,

Stub should be a character vector of the patterns on which you want to pool.

For example: flowdata1 <- FCS_pool(flowData, stub= c("Sample 1", "Sample 2", "Sample 3))

Should pool those samples. The space may be an issue, but can you quickly check if this works?

carolina671 commented 2 years ago

Thanks, I understand the FCS_POOL function now but it was not exactly was I was looking for as I wanted to merge all the flowframes. Please see below an example of what I wanted in case someone needs it, I found the solution in another site.

example github

library(flowCore)

> data("GvHD")

> fr1 = GvHD[[1]]

> fr2 = GvHD[[2]]

> nrow(fr1)

[1] 3420

> nrow(fr2)

[1] 3405

> fs = flowSet(list(fr1, fr2))

> fr = as(fs, "flowFrame")

> nrow(fr)

[1] 6825

> fn = tempfile()

> write.FCS(fr, fn)