Open AlexBlais74 opened 1 month ago
I wanted to add that ggcyto
seems to color a similar 2D plot for the same data:
ggcyto(
fs.sony_full,
aes(x = "FSC-A", y = "SSC-A"),
subset = "root",
max_nrow_to_plot = 25000) +
geom_hex(bins = 4096) +
ggcyto_par_set(limits = list(x = c(0, 1E6), y = c(0, 0.3E6))) +
theme( panel.background = element_rect(fill = "white"),
panel.grid = element_line(color = "gray95"))
Do you get the same result when you remove xlim
and ylim
?
Hello, thanks for looking into this.
Without the axis limits I get this, with cyto_plot
(first plot) and with ggcyto
(second plot)
There are some events with very high values, hence the need to set some limits.
But I have found a way to generate a plot that has the aspect I would expect: instead of subsetting during plotting by setting xlim and ylim, I subsetted the flowset object itself.
# create FS
fs.sony_full <- flowCore::read.flowSet( files=name.sony,
path=dir.sony,
truncate_max_range = FALSE)
# For filtering, design a rectangular gate with the limits I want
rectGate <- rectangleGate( filterId="plot_limits",
"FSC-A"=c(0,1E6),
"SSC-A"=c(0,0.3E6))
# Subset the FS using that gate
fs.sony_full.result <- flowCore::filter(fs.sony_full, rectGate)
fs.sony_full.subset <- Subset(fs.sony_full, fs.sony_full.result)
# Plot
cyto_plot( fs.sony_full.subset,
parent = "root",
channels = c("FSC-A", "SSC-A"),
display = 1,
point_size = 2,
contour_lines = 10)
So I get the plot I wanted but the workaround is not suitable for me as I would like to retain all events, even the most extremes. I am not an expert, but is it possible that the plot colors are determined on the full dataset, without taking into account the values of xlim and ylim? I can understand why this may be preferred by some users. However, it would also be nice to have the option of setting the colors based on the events that will be retained after the plot limits are set.
I have a feeling that the options "point_col_scale" and "point_cols" might be useful, however I am not sure how to employ them to obtain the result I am after.
Thanks Alex
Note that my solution with flowCore::filter
and Subset
only works with a flowset or flowframe object. It does not work with a GatingSet object. I will have to do more reading to figure out how to implement the same with a GatingSet object.
Hello I am using cyto_plot to examine FSC vs SSC of a FCS file, loaded as a a flowSet object with
flowCore::read.flowSet
The scatter (2D) plot that I obtain has an appearance that seems correct except for the colors, which seem too patchy: there are well-defined blocks of color that I expect should be more gradual and certainly not rectangular as seen here. I have drawn contour lines to show event density and those have the expected appearance.The code for the plot:
Here is the distribution of values I am trying to plot:
I am getting the same behavior with a gatingSet object creating using
cyto_setup
. Any help would be greatly appreciated. Thanks Alex