Skip to content

Instantly share code, notes, and snippets.

@soh-i
Last active September 19, 2022 17:19
Show Gist options
  • Save soh-i/daef293389e978edd412487e307c6c0d to your computer and use it in GitHub Desktop.
Save soh-i/daef293389e978edd412487e307c6c0d to your computer and use it in GitHub Desktop.
FACS plot with user-defined gate
library(CytoML)
library(flowWorkspace)
library(ggcyto)
xmlfile <- 'gate.xml' # Gating-ML xml file generated by Cytobank
fcsFiles <- list.files(pattern='.fcs', path='./FCS/', full.names=TRUE)
gs <- cytobank2GatingSet(xmlfile, fcsFiles)
fs <- getData(gs, "P1") # FCS file object filtered by P1 gate (live cell)
P2 <- getGate(gs, "P2") # P2 gate object (EGFP gate)
g <- ggcyto(fs, aes(y=`FSC-A`, x=`FITC-A`)) +
facet_wrap(~name) +
geom_hex(bins=128) +
geom_gate(P2) +
geom_stats(fill='transparent', digits=1.0, size=2, adjust=0.8) +
theme_bw() +
theme(
strip.background=element_rect(colour=NA, fill=NA),
panel.grid.major=element_blank(), aspect.ratio=1) +
labs(x='EGFP intensity', y='FSC-A') +
scale_y_continuous(limits=c(0, 200000))
@soh-i
Copy link
Author

soh-i commented Oct 29, 2018

screen shot 2018-10-29 at 23 56 30

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment