Question: Problem displaying stats in ggcyto after log-transformation (flow cytometry analysis in R)
0
gravatar for srinivasarao.rao
2.6 years ago by
srinivasarao.rao0 wrote:

I am using ggcyto package in R to plot flow cytometry data, and to display stats on the plot, I am using the geom_stats() function as shown here: https://www.bioconductor.org/packages/release/bioc/vignettes/ggcyto/inst/doc/ggcyto.GatingSet.html

But while the plot and gates look fine, geom_stats is not working and I get the following warning messages when I run ggcyto()...geom_stats()

Warning messages: 1: Removed 27 rows containing missing values (geom_hex). 2: Removed 2 rows containing missing values (geom_label). 3: Removed 2 rows containing missing values (geom_label). 4: Removed 2 rows containing missing values (geom_label). 5: Removed 2 rows containing missing values (geom_label).

This is the code, but it's not a working example as the data files (FCS files exported from BD FACSdiva) are not uploaded.

# libraries ----
library(flowCore)
library(ggplot2)
library(cowplot)
library(ggcyto)
library(openCyto)
library(flowWorkspace)

# load FCS files ----
files <- list.files(path = "Folder_001/Experiment_001/", pattern = "Specimen", full.names = TRUE)
expt1 <- read.flowSet(files = files, name.keyword = "$FIL", alter.names = TRUE)

# log-transform PI and Annexin V data ----
logTrans <- logTransform(transformationId="log10-transformation", logbase=10, r=1, d=1)
trans <- transformList(c("PI.A", "BV421.A"), logTrans)
expt1.trans <- transform(expt1, trans)

# clean up NA/NaN/Inf ----
for(n in 1:length(expt1.trans)){
  exprs(expt1.trans[[n]]) <- exprs(expt1.trans[[n]])[!rowSums(!is.finite(exprs(expt1.trans[[n]]))), ]
}

# Add gates (flowWorkspace) ----
gate <- rectangleGate(filterId="myRectGate", "FSC.A"=c(0, 255000), "SSC.A"=c(0, 75000))
qg <- quadGate(filterId="myQuadGate1", "PI.A"=log10(10000), "BV421.A"=log10(3000))
gated.gs <- GatingSet(expt1.trans)
addgated.gs, gate, parent = "root", name = "rect", recompute = TRUE)
addgated.gs, qg, parent = "rect", name = c("Early apoptotic", "Dead", "PI only", "Live"))
getNodesgated.gs)
recomputegated.gs)
gated.selected <- gated.gs[c(8, 6)]

# plot ----
p <- ggcyto(gated.selected, aes(x = PI.A, y = BV421.A)) +
  geom_hex(bins = 200) +
  geom_gate(gates) + 
  labs(x = "PI", y = "Annexin V") + 
  geom_stats()

Looking at the ggplot object created by ggcyto, it looks like the problem might be with the x and y columns in the labels data frames, which have NA's, but manually modifying these columns does not seem to have any effect.

> p.build$data[[7]]
   x  y label PANEL group colour  fill size angle hjust vjust alpha family fontface lineheight
1 NA NA 9.16%     1    -1  black white 3.88     0   0.5   0.5    NA               1        1.2
2 NA NA 8.88%     2    -1  black white 3.88     0   0.5   0.5    NA               1        1.2

Hope that is all the relevant information, but please let me know if I missed anything. Thanks.

ADD COMMENTlink modified 2.6 years ago by go2rsr30 • written 2.6 years ago by srinivasarao.rao0
3
gravatar for go2rsr
2.6 years ago by
go2rsr30
United Kingdom
go2rsr30 wrote:

The maintainer of ggcyto has solved this issue for me, just posting this for anyone else who ends up here from a Google search.

https://github.com/RGLab/ggcyto/issues/13

Briefly, there are negative values in my data which generate NaN and Inf/-Inf upon log transformation. Instead, if I do a logicle transformation (http://www.ncbi.nlm.nih.gov/pmc/articles/PMC1994577/), there are no missing values and geom_stats() works as expected.

trans <- estimateLogicle(expt1[[1]], c("PI.A", "BV421.A"))
expt1.trans <- transform(expt1, trans)
ADD COMMENTlink modified 2.6 years ago • written 2.6 years ago by go2rsr30
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 2.3.0
Traffic: 732 users visited in the last hour