使用 flowViz 的 flowSet 的多个门
Multiple gates for a flowSet using flowViz
我想在 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)
现在 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)
})
现在我想构建一个 filtersList
来为我的 flowSet
的每个 flowFrame
使用多个门。
# 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)
})
此时我收到上面发布的警告。那么,如何正确构造 filtersList
呢?
我解决了这个问题。你只需要从你的门列表中构建 filters
对象。
然后重复该对象,这样您就可以得到与 flowset
长度相同的 filters
列表,并将 list
元素命名为与 flowset
元素相同的名称。
但是你只能使用相同类型的门,所以你不能组合rectangleGate
和ellipsoidGate
对象。
# 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
上使用多个椭圆门并绘制结果。
我设法用每帧一个门绘制 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)
现在 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)
})
现在我想构建一个 filtersList
来为我的 flowSet
的每个 flowFrame
使用多个门。
# 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)
})
此时我收到上面发布的警告。那么,如何正确构造 filtersList
呢?
我解决了这个问题。你只需要从你的门列表中构建 filters
对象。
然后重复该对象,这样您就可以得到与 flowset
长度相同的 filters
列表,并将 list
元素命名为与 flowset
元素相同的名称。
但是你只能使用相同类型的门,所以你不能组合rectangleGate
和ellipsoidGate
对象。
# 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)
})