有没有办法从连续变量绘制频率直方图?

时间:2022-11-13 23:47:10

I have DNA segment lengths (relative to chromosome arm, 251296 entries), as such:

我有DNA片段长度(相对于染色体臂,251296个条目),因此:

0.24592963
0.08555043
0.02128725
...

The range goes from 0 to 2, and I would like to make a continuous relative frequency plot. I know that I could bin the values and use a histogram, but I would like to show continuity. Is there a simple strategy? If not, I'll use binning. Thank you!

范围从0到2,我想制作一个连续的相对频率图。我知道我可以对值进行分类并使用直方图,但我希望显示连续性。有一个简单的策略吗?如果没有,我将使用binning。谢谢!

EDIT:

I have created a binning vector with 40 equally spaced values between 0 and 2 (both included). For simplicity's sake, is there a way to round each of the 251296 entries to the closest value within the binning vector? Thank you!

我创建了一个binning向量,其中40个等间距值介于0和2之间(均包含在内)。为简单起见,有没有办法将每个251296个条目舍入到分箱向量中最接近的值?谢谢!

1 个解决方案

#1


Given that most of your values are not duplicated and thus don't have an easy way to derive a value for plotting on the y-axis, I'd probably go for a density plot. This will highlight dense segment lengths i.e. where you have lots of segment lengths occurring near each other.

鉴于您的大多数值都没有重复,因此没有一种简单的方法来获得在y轴上绘制的值,我可能会选择密度图。这将突出显示密集的段长度,即您有许多段长度彼此接近的位置。

d <- c(0.24592963, 0.08555043, 0.02128725)
plot(density(d), xlab="DNA Segment Length", xlim=c(0,2))

有没有办法从连续变量绘制频率直方图?

#1


Given that most of your values are not duplicated and thus don't have an easy way to derive a value for plotting on the y-axis, I'd probably go for a density plot. This will highlight dense segment lengths i.e. where you have lots of segment lengths occurring near each other.

鉴于您的大多数值都没有重复,因此没有一种简单的方法来获得在y轴上绘制的值,我可能会选择密度图。这将突出显示密集的段长度,即您有许多段长度彼此接近的位置。

d <- c(0.24592963, 0.08555043, 0.02128725)
plot(density(d), xlab="DNA Segment Length", xlim=c(0,2))

有没有办法从连续变量绘制频率直方图?