用R代码确定斜率 [英] Determining slopes with R code

查看:215
本文介绍了用R代码确定斜率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有很多熔化曲线,我想使用R代码确定最小(谷)和最大(峰)之间最陡峭部分的斜率(拐点中的斜率对应于熔点) 。我可以想象的解决方案是确定每个点的斜率然后找到最大正值,或者通过使用drc软件包拟合4参数的Weibull型曲线来确定拐点(基本上对应于50%的响应)点在最大值和最小值之间)。在后一种情况下,最棘手的部分是,对于每条曲线,这种拟合都必须限制在最小(谷)荧光响应和最大(峰值)荧光响应之间的温度范围内。每个曲线的温度范围都不同。

I have a number of melting curves, for which I want to determine the slope of the steepest part between the minimum (valley) and maximum (peak) using R code (the slope in the inflection point corresponds to the melting point). The solutions I can imagine are either to determine the slope in every point and then find the maximum positive value, or by fitting a 4-parameter Weibull-type curve using the drc package to determine the inflection point (basically corresponding to the 50% response point between minimum and maximum). In the latter case the tricky part is that this fitting has to be restricted for each curve to the temperature range between the minimum (valley) and maximum (peak) fluorescence response. These temperature ranges are different for each curve.

感谢任何反馈!

推荐答案

diff函数可以在等距值(直到一个恒定因子)上实现等效的数值微分,因此可以找到最大值(或最小值)来确定最陡峭上升(或下降)的位置:

The diff function accomplishes the equivalent of numerical differentiation on equally spaced values (up to a constant factor) so finding maximum (or minimum) values can be used to identify location of steepest ascent (or descent):

z <- exp(-seq(0,3, by=0.1)^2 )
plot(z)
plot(diff(z))
z[ which(abs(diff(z))==max(abs(diff(z))) )]
# [1] 0.6126264
# could have also tested for min() instead of max(abs())
plot(z)
abline( v = which(abs(diff(z))==max(abs(diff(z))) ) )
abline( h = z[which(abs(diff(z))==max(abs(diff(z))) ) ] )

x差为1时,斜率就是该点的差:

With an x-difference of 1, the slope is just the difference at that point:

diff(z) [ which(abs(diff(z))==max(abs(diff(z))) )  ]
[1] -0.08533397

...但是我怀疑这是否真的很有意思。我本以为获取指数(将是有抵消的熔点)将是利息值。

... but I question whether that is really of much interest. I would have thought that getting the index (which would be the melting point subject to an offset) would be the value of interest.

这篇关于用R代码确定斜率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆