FAQ  •  Register  •  Login

merging a large number of files

Forum rules
Please be as geeky as possible. Reference, reference, reference.
Also, please note that this is a mixed bag of math-gurus and mathematically challenged, so choose your words wisely :-)
<<

nataliaCW

Participant

Posts: 5

Joined: Mon Jan 31, 2022 4:42 pm

Post Tue Feb 25, 2025 9:55 am

merging a large number of files

Hi all, could you recommend me packages in Python (or in R) for merging a large number of FCS files? The ones I have found are very old
<<

tomash

Contributor

Posts: 26

Joined: Sun Oct 19, 2014 10:15 pm

Post Tue Feb 25, 2025 11:10 am

Re: merging a large number of files

Hi Natalia,

Self promoting here, but you could try Spectre: https://github.com/ImmuneDynamics/Spectre.

You can read in data as FCS or CSV, make any adjustments you like (e.g. merging files by adding a “sample” keyword or some such) and then writing out the new FCS files.

Tom
<<

sgranjeaud

Master

Posts: 126

Joined: Wed Dec 21, 2016 9:22 pm

Location: Marseille, France

Post Wed Feb 26, 2025 7:36 am

Re: merging a large number of files

Hi,
If you like code... The following code doesn't manage compensation matrix, but your files probably don't have.
Best.

  Code:
# using R and flowCore
library(flowCore)
# from the help of read.flowSet
fcs.loc <- system.file("extdata",package="flowCore")
file.location <- paste(fcs.loc, dir(fcs.loc), sep="/")
fs <- read.flowSet(file.location[1:3])
# a flowSet is a list of flowFrames having all the same channels; here is the first one
fs[[1]]
flowFrame object '0877408774.B08'
with 10000 cells and 8 observables:
      name              desc     range  minRange  maxRange
$P1  FSC-H             FSC-H      1024   0.00000      1023
$P2  SSC-H             SSC-H      1024   0.00000      1023
$P3  FL1-H                NA      1024   1.00904     10000
$P4  FL2-H                NA      1024   1.00904     10000
$P5  FL3-H                NA      1024   1.00904     10000
$P6  FL1-A                NA      1024   0.00000      1023
$P7  FL4-H                NA      1024   1.00904     10000
$P8   Time Time (51.20 sec.)      1024   0.00000      1023
166 keywords are stored in the 'description' slot
# the concatenation code
> fm <- as(fs, "flowFrame")
# the result is a single flowFrame with an extra channel called Original containing integers identifying each flowFrame
> fm
flowFrame object 'anonymous'
with 30000 cells and 9 observables:
             name              desc     range  minRange  maxRange
$P1         FSC-H             FSC-H      1024   0.00000      1023
$P2         SSC-H             SSC-H      1024   0.00000      1023
$P3         FL1-H                NA      1024   1.00904     10000
$P4         FL2-H                NA      1024   1.00904     10000
$P5         FL3-H                NA      1024   1.00904     10000
$P6         FL1-A                NA      1024   0.00000      1023
$P7         FL4-H                NA      1024   1.00904     10000
$P8          Time Time (51.20 sec.)      1024   0.00000      1023
Original Original    Original Frame        NA   1.00000         3
2 keywords are stored in the 'description' slot
# it could be written on disk using write.FCS()

Return to CyTOF data analysis

Who is online

Users browsing this forum: No registered users and 87 guests