Error when plotting flow cytometry data
1
0
Entering edit mode
alex • 0
@222f89de
Last seen 4 weeks ago
Germany

Hi everyone, I just started to use R for flow cytometry analysis and its hard for me to get behind. I never asked any question online and hope that I managed to post here accordingly, but I have a problem that I can't fix.

I'm using read.flowSet to read my .fcs files from an experiment. After gating and transformation of the flowset, I try to plot my flowset as stacked density plots as described here: https://www.bioconductor.org/packages/devel/bioc/vignettes/ggcyto/inst/doc/ggcyto.flowSet.html

When I try to plot however with

ggcyto(T_Singlets_MyFlowSet, aes(x="BV421-A")) + geom_density_ridges(aes(y=name))

I get an error:

Error in max(data$y) - min(data$y) : 
  non-numeric argument to binary operator

Could this error occur because my "name" vector in the phenodata dataframe is off the class " 'AsIs' chr" and not "chr" ?? This is at least the most obvious difference for me between teh flowset from I get from reading my experiment files vs. the flowset I get from https://www.bioconductor.org/packages/devel/bioc/vignettes/ggcyto/inst/doc/ggcyto.flowSet.html

I would be super happy if someone could help me. I really don't know a lot about this kind of stuff

FlowCytometry flowCore ggcyto • 345 views
ADD COMMENT
0
Entering edit mode
SamGG ▴ 290
@samgg-6428
Last seen 12 days ago
France/Marseille/Inserm

Welcome!

The most obvious solution sounds to use a backtick ` instead of double quote ".

Check carefully the vignette I think this is the point.

Best.

ADD COMMENT
0
Entering edit mode

Thanks for the reply! I get the same error when using backticks instead of quotes.

ADD REPLY
1
Entering edit mode
ggplot(T_Singlets_MyFlowSet, aes(x = `BV421-A`, fill = name)) + geom_density(alpha = 0.2)

same error with previous code?

ADD REPLY
0
Entering edit mode

This works!

ADD REPLY
0
Entering edit mode
ggplot(T_Singlets_MyFlowSet, aes(x = `BV421-A`)) + geom_density_ridges(aes(y=name))

also works?

ADD REPLY
0
Entering edit mode

Nope. This again results in the error

Error in max(data$y) - min(data$y) : 
  non-numeric argument to binary operator
ADD REPLY
1
Entering edit mode

Test your hypothesis. Change the type of the name column.

pData(T_Singlets_MyFlowSet)[,"name"] = as.character(pData(T_Singlets_MyFlowSet)[,"name"])

If the display still fails, please run the following code and return the result.

sapply(pData(T_Singlets_MyFlowSet), class)
sapply(pData(T_Singlets_MyFlowSet), typeof)
ADD REPLY
0
Entering edit mode

It worked!!! I can also use

ggcyto(T_Singlets_MyFlowSet, aes(x="BV421-A")) + geom_density_ridges(aes(y=name)) + facet_null()

now to plot as I intented. I guess then, the problem was that "name" wasn't classified as character, but I didn't know how to fix it. Thank you so so much!! this was giving me so much headaches

ADD REPLY
0
Entering edit mode

Great! If the error occurs again, it would be useful to understand where it comes from.

Best.

ADD REPLY

Login before adding your answer.

Traffic: 530 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6