Home > Enterprise >  Area Under Disease Progress Curve (AUDPC)
Area Under Disease Progress Curve (AUDPC)

Time:07-28

I am trying to apply the function "audpc" from the package "agricolae" to my data base to calculate the area under disease progress curve (audpc). Information about the function and the package:

https://www.rdocumentation.org/packages/agricolae/versions/1.3-5/topics/audpc

I understand how the function works, but my problem relates how this function should be applied to my data. I have a data frame with different field trials (ID). For each ID, there are disease assessments for diferent diseases. These assessments were made at different time points in order to assess the disease intensity (proportion of plants that were diseased out of the total number of plants in that given field trial). My data base looks like this:

ID Week rust mildew scald
1 35 1 20 32
1 36 5 29 39
1 37 12 45 58
1 38 23 80 96
2 17 0 2 5
2 18 0 4 9
2 19 2 8 15
2 20 6 15 30
2 21 13 30 69

Each ID (field trial) has different number of entries (different number of weeks where the disease assessment were made) and obviously different values of disease intensity for each disease. What I would like to obtain is the audpc value for each ID and disease (rust, mildew, scald). Is it possible to do it using the audpc funtion in the package agricolae, or a user-defined function has to be created?

Thank you in advance

CodePudding user response:

Using the dplyr package, you can group_by ID, and apply the audpc function across each disease column:

library(agricolae)
library(dplyr)

df %>%
  group_by(ID) %>%
  summarise(across(rust:scald, ~ audpc(.x, Week)))
#> # A tibble: 2 x 4
#>      ID  rust mildew scald
#>   <int> <dbl>  <dbl> <dbl>
#> 1     1  29      124   161
#> 2     2  14.5     43    91

Data from question in reproducible format

df <- structure(list(ID = c(1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L), Week = c(35L, 
36L, 37L, 38L, 17L, 18L, 19L, 20L, 21L), rust = c(1L, 5L, 12L, 
23L, 0L, 0L, 2L, 6L, 13L), mildew = c(20L, 29L, 45L, 80L, 2L, 
4L, 8L, 15L, 30L), scald = c(32L, 39L, 58L, 96L, 5L, 9L, 15L, 
30L, 69L)), class = "data.frame", row.names = c(NA, -9L))

df
#>   ID Week rust mildew scald
#> 1  1   35    1     20    32
#> 2  1   36    5     29    39
#> 3  1   37   12     45    58
#> 4  1   38   23     80    96
#> 5  2   17    0      2     5
#> 6  2   18    0      4     9
#> 7  2   19    2      8    15
#> 8  2   20    6     15    30
#> 9  2   21   13     30    69

Created on 2022-07-26 by the reprex package (v2.0.1)

  • Related