This function will calculate the distribution of susceptibilities by sample

calculate_complexities(x, cutoff, control, sample, gene, perc_susc)

Arguments

x

a data.frame containing the data.

cutoff

value for percent susceptible cutoff. Numeric.

control

value used to denote the susceptible control in the gene column. Character.

sample

column providing the unique identification for each sample being tested. Character.

gene

column providing the gene(s) being tested. Character.

perc_susc

column providing the percent susceptible reactions. Character.

Value

calculate_complexities returns an object of class hagis.complexities.

An object of class hagis.complexities is a list containing the following components

grouped_complexities

a data.table::data.table() object of grouped complexities

individual_complexities

a data.table::data.table() object of individual complexities

Examples


# Using the built-in data set, P_sojae_survey
data(P_sojae_survey)

P_sojae_survey
#>      Isolate         Line         Rps Total HR (1) Lesion (2)
#>   1:       1     Williams susceptible    10      0          0
#>   2:       1       Harlon      Rps 1a    10      4          0
#>   3:       1 Harosoy 13xx      Rps 1b     8      0          0
#>   4:       1     L75-3735      Rps 1c    10     10          0
#>   5:       1    PI 103091      Rps 1d     9      2          0
#>  ---                                                         
#> 290:      21   PRX 145-48      Rps 3c     8      3          1
#> 291:      21     L85-2352       Rps 4    10      3          1
#> 292:      21     L85-3059       Rps 5    10      0          4
#> 293:      21 Harosoy 62XX       Rps 6     8      2          1
#> 294:      21      Harosoy       Rps 7    10      0          0
#>      Lesion to cotyledon (3) Dead (4) total.susc total.resis perc.susc
#>   1:                       0       10         10           0       100
#>   2:                       0        6          6           4        60
#>   3:                       0        8          8           0       100
#>   4:                       0        0          0          10         0
#>   5:                       1        6          7           2        78
#>  ---                                                                  
#> 290:                       0        4          5           3        63
#> 291:                       4        2          7           3        70
#> 292:                       0        6         10           0       100
#> 293:                       0        5          6           2        75
#> 294:                       0       10         10           0       100
#>      perc.resis
#>   1:          0
#>   2:         40
#>   3:          0
#>   4:        100
#>   5:         22
#>  ---           
#> 290:         38
#> 291:         30
#> 292:          0
#> 293:         25
#> 294:          0

# calculate susceptibilities with a 60 % cutoff value
complexities <- calculate_complexities(x = P_sojae_survey,
                                       cutoff = 60,
                                       control = "susceptible",
                                       sample = "Isolate",
                                       gene = "Rps",
                                       perc_susc = "perc.susc")
complexities
#> 
#> Grouped Complexities
#>     complexity frequency distribution
#>  1:          1         0            0
#>  2:          2         0            0
#>  3:          3         0            0
#>  4:          4         0            0
#>  5:          5         1            1
#>  6:          6         2            2
#>  7:          7         2            2
#>  8:          8         7            7
#>  9:          9         0            0
#> 10:         10         5            5
#> 11:         11         3            3
#> 12:         12         0            0
#> 13:         13         1            1
#> 
#> 
#> Individual Complexities
#>     sample N_samp
#>  1:      1     10
#>  2:      2     10
#>  3:      3     10
#>  4:      4      8
#>  5:      5      8
#>  6:      6      8
#>  7:      7      8
#>  8:      8      8
#>  9:      9      6
#> 10:     10      5
#> 11:     11      6
#> 12:     12      8
#> 13:     13      7
#> 14:     14      8
#> 15:     15     11
#> 16:     16      7
#> 17:     17     10
#> 18:     18     10
#> 19:     19     11
#> 20:     20     11
#> 21:     21     13
#>     sample N_samp
#> 

summary(complexities)
#> 
#> Mean of Complexities
#> 8.714286 
#> 
#> Standard Deviation of Complexities
#> 2.003568 
#> 
#> Standard Error of Complexities
#> 0.4372144