CytoExploreR
CytoExploreR copied to clipboard
xlim does not work in cyto_plot_save(layout = ...)
Describe the bug xlim does not work in cyto_plot_save(layout = ...). In cyto_plot_layout(), it works. Could you fix it?
To Reproduce
setwd(dirname(rstudioapi::getActiveDocumentContext()$path))
##clear all objects
graphics.off()
rm(list=ls())
# Load required packages
library(CytoExploreR)
library(CytoExploreRData)
##select files to analyze
filename <- list.files("./")
filename.subset <- filename[grep(".*.fcs", filename)]
##load files
gs <- cyto_setup("./",
select = filename.subset,
gatingTemplate = "Activation-gatingTemplate.csv")
gs <- cyto_transform(gs, type = "biex")
cyto_plot_save("cyto_plot_save.pdf",
multiple = T,
layout = c(2,1))
for(j in 1:2){
cyto_plot(
gs[[j]],
parent = "root",
channels = c("GFP-A", "SSC-A"),
xlim = c(10,1000000),
)
}
cyto_plot_save_reset()
cyto_plot_reset()
##screenshot "cyto_plot_save.png"
cyto_plot_layout(c(2,1))
for(j in 1:2){
cyto_plot(
gs[[j]],
parent = "root",
channels = c("GFP-A", "SSC-A"),
xlim = c(10,1000000),
)
}
##screenshot "cyto_plot_layout.png"
Expected behavior The range of x-axis is set as described in xlim.
Screenshots
cyto_plot_save
cyto_plot_layout
Desktop (please complete the following information): win11, Rstudio, R version 4.2.1, ‘CytoExploreR’ version 1.1.0
Additional context Thank you for your great app!
@tamaikeiichi, I would recommend using the method described on the website under "Custom Plot Layouts" section: https://dillonhammill.github.io/CytoExploreR/articles/CytoExploreR-Visualisations.html
This will be the approach used in the new version of CytoExploreR as well, and layout
will be removed from cyto_plot_save()
.
This is the recommended way to do this:
# 1. open device
cyto_plot_save()
# 2. set layout
cyto_plot_custom()
# 3. add plots
cyto_plot()
# 4. close device
cyto_plot_complete()
@DillonHammill , Thank you for your quick response.
I have tried as you mentioned, but it does not still work. Is there any other way?
cyto_plot_save("cyto_plot_custom.pdf")
cyto_plot_custom(layout = c(2,1))
for(j in 1:2){
cyto_plot(
gs[[j]],
parent = "root",
channels = c("GFP-A", "SSC-A"),
xlim = c(10,1000000),
)
}
cyto_plot_complete()

Can you remove the xlim
part altogether and send through the plots?
Just pointing out that custom layouts are not actually required in this case. You can call cyto_plot_save()
and then cyto_plot()
directly:
cyto_plot_save("test.pdf")
cyto_plot(
gs,
select = c(1,2),
parent = "root",
channels = c("GFP-A", "SSC-A"),
layout =c(1,2)
)
I think the issue is that your transformations are not defined over the limits you specify. Try setting xlim = c(10, 1e6)
.
@DillonHammill ,
Your code xlim = c(10, 1e6)
works and X-axis is set correctly. Thank you.
Another problem is that I want to use for()
like below because multiple overlay plots are needed. The outcome is no multiple layout in "cyto_plot.pdf".
Finally, 24 paired files need to be processed and a PDF file be created as multiple layouts, pages.
Could you tell me what's wrong?
cyto_plot_save("cyto_plot.pdf", multiple = T)
for(j in 1:2){
test <- cyto_extract(gs, parent = "root")[[j+2]]
cyto_plot(
gs[[c(j)]],
parent = "root",
overlay = test,
channels = c("GFP-A", "SSC-A"),
xlim = c(100,1e6),
point_col = c("blue",
"pink"),
layout = c(2,2)
)
}
cyto_plot_complete()
What does the plot look like? It should be on one page as you onky require 2 panels but your layout defines 4 panels.
@DillonHammill , Here is the PDF file. Only one panel (and one page) was created cyto_plot.pdf
Try running cyto_plot_reset()
and then save the plot again.
@DillonHammill , Is this code what you expected? No change is seen.
cyto_plot_reset()
cyto_plot_save("cyto_plot.pdf", multiple = T)
for(j in 1:2){
test <- cyto_extract(gs, parent = "root")[[j+2]]
cyto_plot(
gs[[c(j)]],
parent = "root",
overlay = test,
channels = c("GFP-A", "SSC-A"),
xlim = c(100,1e6),
point_col = c("blue",
"pink"),
layout = c(1,2)
)
}
cyto_plot_complete()