使用R中的drc包回归多个剂量 - 反应曲线

时间:2017-09-08 11:51:48

标签: r regression drc

我试图通过我的实验数据拟合回归(4或5 PL)。我有几种化合物抑制我感兴趣的酶。每个都有自己的0-100%酶活性范围。所有数据都在一个数据框中,并由一列指定我的化合物('毒素')进行dinstinguished。因此,我希望单独对每种毒素/化合物进行回归。我尝试了以下代码

drc <- drm(avg ~ conc, data = testdata, toxin, fct = LL.5())

,它给出了以下两个错误:

  

optim中的错误(startVec,opfct,hessian = TRUE,method = optMethod,   control = list(maxit = maxIt,:非有限的有限差分值   [24] drmOpt错误(opfct,opdfct1,startVecSc,optMethod,   约束,warnVal,:收敛失败

在阅读SO上的一些帖子后,通常不使用浓度的对数刻度('conc')来解决此错误。在我的情况下,数据没有进行日志转换,因此我真的不知道如何继续,因为我真的不明白错误消息告诉我的是什么。

我尝试使用相同的命令只包含一部分数据(只有一个毒素)并且有效。

以下是数据:

    testdata <- structure(list(toxin = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 
1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 
3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 
4L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 5L, 6L, 6L, 6L, 6L, 6L, 
6L, 6L, 6L, 6L, 6L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L, 9L), .Label = c("toxin1", 
"toxin2", "toxin3", "toxin4", "toxin5", "toxin6", "NC", "PC", 
"toxin7"), class = "factor"), conc = c(80, 230, 690, 2060, 
6170, 18520, 55560, 116700, 5e+05, 1500000, 10, 30, 100, 290, 
860, 2600, 7700, 23300, 70000, 210000, 0.25, 0.76, 2.29, 6.69, 
29.57, 61.73, 185.19, 555.56, 1666.67, 5000, 0.1, 0.3, 0.91, 
2.74, 8.23, 24.69, 74.07, 222.22, 666.67, 2000, 0.19, 0.39, 0.78, 
1.56, 3.125, 6.25, 12.5, 25, 50, 100, 0.05, 0.14, 0.41, 1.23, 
3.7, 11.11, 33.33, 100, 300, 900, 0.25, 0.76, 2.29, 6.69, 20.57, 
61.73, 185.19, 555.56, 1666.67, 5000), avg = c(93.7392909656605, 
109.438977761257, 102.50389863782, 97.8565582988098, 98.7749196390328, 
94.6820096545283, 88.3878644123183, 74.6531623906189, 59.8033994067719, 
33.1521812859023, 84.3458578131283, 80.8432075369312, 80.5041552022783, 
74.3806536115552, 65.867746238255, 46.7093609589345, 25.2625895634089, 
16.5991924099889, 9.8338847737454, 9.1267136985971, 96.7637675923354, 
100.217322048861, 106.911067427548, 105.869274152439, 104.26295691452, 
99.924974639669, 105.178112603458, 100.834869287621, 97.0640881891228, 
100.517438616909, 102.664029650058, 104.079019894009, 106.005108031173, 
101.539083701953, 98.0496674854621, 67.7840816081928, 39.3101865930841, 
38.410593148271, 8.98193991681226, 7.22314661576326, 84.0614720922454, 
82.7675961061481, 65.2085894181738, 37.3278677636159, 24.9075938602538, 
14.3617392491638, 10.7917687047216, 8.37929257644196, 8.42895771412019, 
12.9194757988616, 76.5674185459266, 65.8625860764468, 47.7169920989096, 
29.6780563387259, 7.69651805994566, 4.34554390880982, 4.33821927277971, 
0.39797595095055, 2.38671848257005, 5.89474149920234, 107.319075979956, 
110.227548845268, 116.828640966343, 107.913632096559, 110.071386130938, 
106.575197414688, 105.043139402911, 98.236919454246, 104.052659508375, 
84.6763301224036), sd = c(7.49544951952132, 14.9170973650272, 
1.03754566304896, 3.87773637652399, 9.17174603323541, 2.0257944547102, 
0.874956239047901, 3.35155947287539, 1.91936941393018, 2.02594096726786, 
1.60035835782164, 1.25579403370456, 3.52866856497447, 4.04640886982452, 
7.37920326517342, 6.40246869316039, 4.77482079353957, 4.68322190067079, 
1.74780492483205, 0.738821067897037, 5.42050977224004, 12.2951096302121, 
9.08089564089922, 7.46281702965045, 9.52060311645085, 6.66339041948764, 
9.04568668161887, 10.9590666295114, 6.25902541715453, 4.96928340386536, 
10.8885949633507, 15.9830841613276, 7.11298501037955, 8.54768106201583, 
12.7115587453605, 5.72457692384765, 4.62110397186864, 50.9817341717873, 
2.96030364454981, 2.83464116977327, 10.7124422767561, 10.3544552730142, 
9.05103847553877, 13.233995551835, 4.26528894064237, 2.18416799462023, 
1.17346307923401, 5.46453008680512, 3.09705214055433, 10.1345046611914, 
2.11845922287944, 3.11915150865922, 6.31893385595251, 14.1295842962481, 
1.33224797602539, 2.11901484197009, 5.05792906176149, 2.08503325893712, 
3.05243406958019, 8.68923158027763, 8.49552648053034, 7.45485150355005, 
8.70510335269844, 7.13998242209083, 6.32588028411456, 4.75860842345735, 
4.09767898578108, 7.04991004776136, 9.37260366463128, 7.20137530818876
)), .Names = c("toxin", "conc", "avg", "sd"), row.names = c(NA, 
-70L), class = c("grouped_df", "tbl_df", "tbl", "data.frame"), vars = list(
    toxin), drop = TRUE, indices = list(0:9, 10:19, 20:29, 30:39, 
    40:49, 50:59, 60:69), group_sizes = c(10L, 10L, 10L, 10L, 
10L, 10L, 10L), biggest_group_size = 10L, labels = structure(list(
    toxin = structure(c(1L, 2L, 3L, 4L, 5L, 6L, 9L), .Label = c("toxin1", 
    "toxin2", "toxin3", "toxin4", "toxin5", "toxin6", "NC", 
    "PC", "toxin7"), class = "factor")), row.names = c(NA, 
-7L), class = "data.frame", vars = list(toxin), drop = TRUE, .Names = "toxin"))

1 个答案:

答案 0 :(得分:1)

错误消息告诉您该函数无法找到至少一个数据子集的解决方案。在您的情况下,toxin3是违规数据集。如果我运行以下代码省略了toxin3,我得到一个收敛的结果和一个很好的情节显示结果。

drc <- drm(avg ~ conc, data = testdata, curveid=toxin, subset=toxin %in% c("toxin1","toxin2","toxin4","toxin5","toxin6","toxin7"), fct = LL.5())
plot(drc)

毒素3失败的原因是数据描述的扁平线可以适合任意数量的LL.5()参数。解决这些问题的一种方法是将每条曲线分别放在一个循环(或应用函数)中,并使用try / catch来处理任何会引起收敛错误的数据集。