Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/entity-framework/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 在ggcyto绘图上设置x限制不';我好像没做那件事_R_Ggplot2_Bioconductor - Fatal编程技术网

R 在ggcyto绘图上设置x限制不';我好像没做那件事

R 在ggcyto绘图上设置x限制不';我好像没做那件事,r,ggplot2,bioconductor,R,Ggplot2,Bioconductor,我试图设置ggcyto(ggplot2)绘图的x限制,但它似乎不起作用。我设置的x极限一直压到右边,有很多空白。不知道还有什么可以尝试的。我试着设置biexp比例,但看起来都一样 library(ggcyto) library(ggplot2) library(flowCore) fs <- read.flowSet(fcs_files, path=(dir_path)) ggcyto(fs[[2]], aes(x = "FSC-A",

我试图设置ggcyto(ggplot2)绘图的x限制,但它似乎不起作用。我设置的x极限一直压到右边,有很多空白。不知道还有什么可以尝试的。我试着设置biexp比例,但看起来都一样

library(ggcyto)
library(ggplot2)
library(flowCore)

fs <- read.flowSet(fcs_files, path=(dir_path))


ggcyto(fs[[2]],
              aes(x = "FSC-A", 
              y = "SSC-A")  
              ) + 
  geom_hex(bins = 26) +
  xlab("") +
  ylab("") +
  theme(
    strip.text = element_text(size = 5),
  ) +
  scale_x_continuous(breaks = c(0, 18000), labels = function(x) formatC(x, format="e", digits =1), limits=c(0, 20000))) #+
  #scale_x_flowjo_biexp(maxValue = 20000, widthBasis = -10)  
库(ggcyto)
图书馆(GG2)
图书馆(flowCore)

fs没有你的数据,所以不能复制奇怪的轴。我会检查你的数据是否有负值。另外,
ggcyto
包装对您的限制也有一些限制

使用下面的示例数据,我将第一列“FSC”上的2个值设置为-999,得到了一个类似的错误:

library(ggcyto)
data(GvHD)
da = GvHD[[1]]
exprs(da)[1:2,1] = -999 
    
ggcyto(da, aes(x = `FSC-H`, y =  `SSC-H`)) +
geom_hex(bins = 50) +
scale_x_continuous(breaks =c(0,800),limits = c(0,2000))

错误是:

警告消息:已删除包含非有限值的2行 (stat_binhex)

如果我删除带有负值的条目,并使用
ggplot2
而不是
ggcyto
,则它可以工作

da = da[rowMeans(exprs(da[,1:2])>0) == 1,]

ggplot(da,aes(x = `FSC-H`, y =  `SSC-H`)) + 
geom_hex(bins=50) + 
scale_x_continuous(breaks =c(0,800),limits=c(0,1200))+
scale_fill_distiller(palette = "Spectral")

在您的示例中,您可以尝试以下操作:

da = fs[[2]]
da = da[rowMeans(exprs(da[,c("FSC-A","SSC-A")])>0) == 1,]

ggplot(da,aes(x = `FSC-A`,y = `SSC-A`)) + 
geom_hex(bins = 26) +
scale_x_continuous(breaks = c(0, 18000),limits=c(0, 20000))) 

你好@StupidWolf,谢谢你的建议!成功了!我还有一个问题。调色板默认为蓝色。我想保留
ggcyto
使用的原始调色板。我该怎么设置呢?像这样的<代码>缩放填充梯度n(颜色=???)
使用
缩放填充蒸馏器(调色板=“光谱”)