Hi, I am trying to plot a frame set using ggycto and autoplot but also to rearrange the frames in a specific order.
I first created a vector with the sample names and then created a matrix that will show the order of the frames in the plot. I use a vector becuase I need to for another loop I have in my script, and I truncate it to 49 for another reason unrelated to this question.
# Create a 96 well plate name spece in a vector
wholeplate <- vector()
rowsinplate <- c("A","B","C","D","E","F","G","H")
for (i in rowsinplate){
for (j in 1:12){
wholeplate <- c(wholeplate,paste(i, j, sep=""))
}
}
ndataset <- vector()
ndataset <- wholeplate[0:49]
#for a later use, make a matrix with 12 columns to store all sample names
layoutmtrx <- matrix(ndataset,ncol = 6, byrow=TRUE)
layoutmtrx
Plotting the frameset with autoplot works fine:
autoplot(fs, "RED.B.HLin", "FSC.HLin", bins=132) +
ggcyto_par_set(limits = "data")
But the frames are ordered as they were files names (A1, A10, A11, A12, A2 ...) So I try using ggcyto_arrange either with the matrix order or just changing the number of rows, but I get the same error:
ggcyto_arrange(autoplot(gs[[1]], "RED.B.HLin", "FSC.HLin", bins=132),layout_matrix = layoutmtrx)
ggcyto_arrange(autoplot(fs, "RED.B.HLin", "FSC.HLin", bins=132), nrow=2)
Error in as.ggplot(p) : object 'name' not found
Should I use another function to re-arrange the plots?
EDIT: while the frames are read in the right order, they are still plotted in the wrong order....
I didn't mange to solve it using
ggcyto_arrange
, but I found an alternative solution (EDIT: actually it doesn't work, the plots are in the wrong order):When loading all frames into the frameset I am now using
mixedsort
fromgtools
to rearrange the list of frames prior to reading it into one flowset.