我想在直方图上画出局部极小值的位置。我使用以下代码查看数据并找到局部最小值:
bins = cut(Seurat_obj$nCount_RNA,
breaks = seq(0, max(Seurat_obj$nCount_RNA) + dist, by = dist))
bin_counts_table = table(bins)
bin_counts = as.vector(bin_counts)
names(bin_counts) = names(bin_counts_table)
print(data.frame(bin_counts))
这给我提供了以下数据框架:
然后,我使用以下代码绘制直方图:
p = ggplot(Seurat_obj@meta.data, aes(x=nCount_RNA)) +
geom_histogram(binwidth=dist) +
geom_vline(aes(xintercept=1500), #hardcoded here but I have code to determine this
color="blue", linetype="dashed", size=1) +
scale_x_continuous(breaks=seq(0, max(Seurat_obj$nCount_RNA)+dist, by = 3*dist))
这给我提供了以下图:
cut和geom_histogram之间是否有什么不同,从而改变了垃圾箱的计算方式?为什么最小值是不同的?
发布于 2020-08-26 01:11:26
中断是不同的设置boundary=0修复了这个问题。请参阅@eipi10的评论。
https://stackoverflow.com/questions/63583170
复制相似问题