DoseResponse / drc

Fitting dose-response models in R
https://doseresponse.github.io/drc/
21 stars 16 forks source link

bug fix for issue #10 #11

Closed bjreisman closed 3 years ago

bjreisman commented 4 years ago

I've made two additions to the plot.drc function to fix the issues raised in #10.

The first fix is in the normalization block where previously the points would be reordered in alphabetical order by curveid; causing the curves to deviate from the plotted points. To prevent this behavior, each response is named by the order it appeared in the input data, normalized, then reordered by name to ensure it matches the original order.

The second fix is in the type = 'bars' code block. If normal == TRUE, the error bars are normalized using the same normalization code as before. Note that this may result in error bars that dip below 0 or above 1.

See code below for examples:

library(drc)
library(dplyr)
mydata <- read.csv("repex.csv")

silly.order <- data.frame(col = c(1:12), 
                          col.silly = c(1,4,7,10,
                                        2,5,8,11,
                                        3,6,9,12))

mydata <- mydata %>%
  left_join(silly.order) %>%
  arrange(col.silly)

drc.model <-  drm(abs ~ conc, drug, data = mydata, fct = LL.4())

plot(drc.model, 
     type = "all",
     normal = F, 
     col = T, 
     broken = T, 
)

image

plot(drc.model, 
     type = "all",
     normal = T, 
     col = T, 
     broken = T, 
)

image


plot(drc.model, 
     type = "bars",
     normal = T, 
     col = T, 
     broken = T, 
)

image

codecov-io commented 4 years ago

Codecov Report

Merging #11 into master will decrease coverage by 0.02%. The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #11      +/-   ##
==========================================
- Coverage   12.11%   12.09%   -0.03%     
==========================================
  Files         115      115              
  Lines        5968     5980      +12     
==========================================
  Hits          723      723              
- Misses       5245     5257      +12     
Impacted Files Coverage Δ
R/plot.drc.R 48.01% <0.00%> (-2.18%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 9de9a46...27fc7e4. Read the comment docs.