Question: FlowCore/FlowViz: How do I skip plotting of empty populations that would otherwise cause an error?
0
gravatar for shieldsy05
2.2 years ago by
shieldsy050
shieldsy050 wrote:

Hey,

I'm trying to process a whole heap of flow data files (obviously), and I've set up gating strategies. My problem is that due to the nature of my research, in some files, a gated population will be empty, and this causes errors when I try to create a density plot (plots that population for each file until it reaches an empty population, then stops). It's inefficient for me to identify and remove the files, and there are other populations of interest aside from the population that is empty.

How can I remove or skip empty populations, so that I don't have to go back each time and find/delete the FCS files?

Example code:

fn <-list.files(pattern=".fcs")
fs <- read.flowSet(fn,alter.names=TRUE)
qg1 <- quadrantGate(fs,stains=c("CD19","CD3"))
fsqg1 <- split(fs,qg1)
bc <- fsqg1$`CD19+CD3-`
dpl <- densityplot(IndividualID~`FITC.A`,bc)

Thanks!

ADD COMMENTlink modified 2.1 years ago by SamGG190 • written 2.2 years ago by shieldsy050
Answer: FlowCore/FlowViz: How do I skip plotting of empty populations that would otherwi
0
gravatar for Haiying.Kong
2.2 years ago by
Haiying.Kong110
Germany
Haiying.Kong110 wrote:

If an empty .fcs file does not have even a header, and the file size is 0, add to between the line 1 and the line 2:

idx = which( file.info(fn)$size > 0 )

fn = fn[idx]

 

 

ADD COMMENTlink modified 2.2 years ago • written 2.2 years ago by Haiying.Kong110
Answer: FlowCore/FlowViz: How do I skip plotting of empty populations that would otherwi
0
gravatar for SamGG
2.1 years ago by
SamGG190
France
SamGG190 wrote:

Hi,

bc is a flowFrame. When it is empty, nrow(bc) should return zero.

ADD COMMENTlink written 2.1 years ago by SamGG190

It's a start. Is there a way that I can make the densityplot function skip over the empty frames within a subset? bc is the flowset resulting from a gate applied to fs. This is the result I get if one of the frames is blank, see how all the plots are generated up until the problem plot, and the remainder aren't generated?

ADD REPLYlink written 2.1 years ago by shieldsy050

I was wrong, bc is a flowSet. Filtering upon the number of rows (aka events) should do the job.

ff.ok <- fsApply(bc, nrow) > 100  # for a better estimation
table(ff.ok)  # always report when filtering
dpl <- densityplot(IndividualID ~ `FITC.A`, bc[ff.ok])  # should be ok

 

ADD REPLYlink written 2.1 years ago by SamGG190

Brilliant! This works really well and reports errors! Thanks. I really appreciate it.

ADD REPLYlink written 2.1 years ago by shieldsy050
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 16.09
Traffic: 117 users visited in the last hour