我想使用ggplot2来说明两个相似的密度分布之间的差异。这是我拥有的数据类型的一个玩具示例:
library(ggplot2)
# Make toy data
n_sp <- 100000
n_dup <- 50000
D <- data.frame(
event=c(rep("sp", n_sp), rep("dup", n_dup) ),
q=c(rnorm(n_sp, mean=2.0), rnorm(n_dup, mean=2.1))
)
# Standard density plot
ggplot( D, aes( x=q, y=..density.., col=event ) ) +
geom_freqpoly()
Run Code Online (Sandbox Code Playgroud)
与其像上面那样分别绘制每个类别(dup
和sp
)的密度,不如我绘制一条线来显示这些分布之间的差异?
在上面的玩具示例中,如果我从dup
密度分布中减去了密度分布sp
,则结果线将在图的左侧大于零(因为存在大量较小的sp
值),而在右侧小于0(因为存在该值)是大量较大的dup
值)。并不是说类型dup
和的观察值可能不同sp
。
更笼统地说-显示相似密度分布之间差异的最佳方法是什么?
我正在编写一个名为 S4 的类,Expression
并希望包含一个 S4 对象DESeq2 = "DESeqDataSet"
作为插槽:
setClass(
Class = "Expression",
representation = representation (
species = "character",
edgeR = "DGEList",
DESeq2 = "DESeqDataSet",
lengths = "matrix",
individuals = "vector",
treatments = "vector",
id = "vector",
samples = "vector",
sample_prep = "vector",
genome_type = "vector",
molecule_type = "vector",
blast_hit = "vector",
rRNA = "vector",
protein = "vector"
))
Run Code Online (Sandbox Code Playgroud)
但是,当我检查包裹时,我收到以下警告:
Found the following significant warnings:
Warning: undefined slot classes in definition of "Expression": DESeq2(class "DESeqDataSet")
Run Code Online (Sandbox Code Playgroud)
该类工作正常(即,现在有错误),但我想修复我们代码中的所有警告。
带有 …