使用flowViz的flowSet的多个门

问题描述 投票:1回答:1

我想在flowSet上使用多个椭球门并绘制结果。

我设法用每帧一个门绘制flowSet,但我无法正确构造filtersList对象。我收到以下警告:

Warning messages: 1: 'filter' must either be a filtersList,filterResultList, a single filter object or a named list of filter objects. 2: 'filter' must either be a filtersList,filterResultList, a single filter object or a named list of filter objects.

set.seed(1)
library(flowViz)
# Graphical parameters
flowViz.par.set("gate", list(lwd = 8))
gp <- flowViz.par.get()

# First set of data
data1 <- matrix(c(rnorm(10000), rlnorm(10000)), ncol = 2)
colnames(data1) <- c("M1", "M2")
rownames(data1) <- 1:10000

# Second set of data
data2 <- matrix(c(rnorm(10000), rlnorm(10000)), ncol = 2)
colnames(data2) <- c("M1", "M2")
rownames(data2) <- 1:10000

# Constructing the flowFrames
frame1 <- new("flowFrame", exprs = data1)
frame2 <- new("flowFrame", exprs = data2)

# Gating 
covar1 <- matrix(c(1,0.001,0.001,5), ncol = 2)
colnames(covar1) <- c("M1", "M2")
rownames(covar1) <- c("M1", "M2")
covar2 <- covar1 

means1 <- c(M1 = 0, M2 = 2.5)
means2 <- c(M1 = 0, M2 = 10)

eg1 <- ellipsoidGate(.gate = covar1, mean = means1)
eg2 <- ellipsoidGate(.gate = covar2, mean = means2)

egs <- filters(list(gate1 = eg1, gate2 = eg2))

# Plotting only one flowFrame
xyplot(`M2`~`M1`, frame1, xlab = "M2", ylab = "M1", xlim = c(-4,4), 
ylim = c(0,30), smooth = FALSE, filter = egs)

Plotting only one flowFrame

现在flowSet也一样。

# Constructing the flowSet
frames <- list(frame1, frame2)
fs <- flowSet(frames)

# Plotting the flowSet
xyplot(`M2`~`M1`|name, fs, xlab = "M2", ylab = "M1", xlim = c(-4,4), 
ylim = c(0,30), 
       panel = function(x,y,...){
         panel.xyplot.flowset(x = x, frames = fs, channel.x.name = "M1",
                              channel.y.name = "M2",gp = gp, 
                              smooth = FALSE,  filter = eg1)
   })

Plotting a flowSet with one filter

现在我想构建一个filtersList,为我的flowFrame的每个flowSet使用多个门。

# Constructing the filtersList
myFilters <- filtersList(list(plot1 = egs, plot2 = egs))

xyplot(`M2`~`M1`|name, fs, xlab = "M2", ylab = "M1", xlim = c(-4,4), 
ylim = c(0,30), 
       panel = function(x,y,...){
         panel.xyplot.flowset(x = x, frames = fs, channel.x.name = "M1",
 channel.y.name = "M2", gp = gp, smooth = FALSE,  filter = myFilters)
       })

Plotting a flowSet

此时我收到上面发布的警告。那么,我如何正确构建filtersList

r bioinformatics bioconductor
1个回答
1
投票

我解决了这个问题。你只需要从你的大门列表中构建filters对象。

然后重复这个对象,这样你得到的filters列表与flowset的长度相同,并将list元素命名为与flowset元素相同。

但是你只能使用相同类型的门,所以你不能组合rectangleGateellipsoidGate对象。

# Constructing the filtersList  
myFilters <- filters(list(eg1,eg2))  
myFilters <- rep(list(myFilters),2)  
names(myFilters) <- sampleNames(fs)  

xyplot(`M2`~`M1`|name, fs, xlab = "M2", ylab = "M1", xlim = c(-4,4),  
      ylim = c(0,30),  
      panel = function(x,y,...){  
        panel.xyplot.flowset(x = x, frames = fs, channel.x.name = "M1",  
                             channel.y.name = "M2", gp = gp, smooth = FALSE,  
                             filter = myFilters)  
      })

flowSet with 2 different gates per panel

© www.soinside.com 2019 - 2024. All rights reserved.