rletter

Obtaining Significance letters (rcompanion) while performing Peto-Peto one factor test


I am trying to obtain the significance letters with the function cldList() (package rcompanion) after performing a Peto-Peto one factor test with the function cen1way()(package NADA2).

After obtaining the p values from the test, I am unable to call them correctly, as the output of cldList() is null.

I believe the p values output might not be in an appropriate object type to be called in cldList(), but I can't figure out how to get it in a usable form.

Here is the code I tried using a subset of my data.

Adding Data

set1 <- structure(list(ID = c("A", "A", "A", "A", "A", "A", 
                      "A", "A", "A", "A", "B", "B", "B", "B", "B", "B", "B", 
                      "B", "C", "C", "C", "D", "D", "D", "D", "D", "D", "D", 
                      "D", "D", "D", "E", "E", "E", "E", "E", "E", "E", "E", 
                      "E", "F", "F", "F", "F", "F", "F", "F", "F", "F", "F", 
                      "F", "F", "F", "G", "G", "G", "G", "G", "G", "G", "G", 
                      "G", "G", "G", "G", "G", "H", "H", "H", "H", "H", "H", 
                      "H", "H"), original = c(0.0034397051289882, 1.1895195198828e-05, 
                                                   2.80463220089782e-05, 5.40349098831069e-05, 2.80463220089782e-05, 
                                                   6.54592102975903e-05, 8.42044278641221e-05, 0.00110045642460291, 
                                                   5.83998369803433e-06, 6.62922790737467e-05, 5.97908405798548e-05, 
                                                   2.80463220089782e-05, 0.000485444017223116, 7.59323332783847e-05, 
                                                   9.34269632583946e-05, 2.80463220089782e-05, 0.000202856928583584, 
                                                   2.80463220089782e-05, 0.000628230889994026, 9.13108026060008e-05, 
                                                   0.000162375214276451, 0.00124474651246522, 6.05143500495826e-05, 
                                                   0.000765789119095523, 0.000705778973990029, 0.000439267485838453, 
                                                   0.000271485757636799, 0.000264355137702171, 0.000913605153098551, 
                                                   0.000841832877175541, 0.00150097653600645, 0.000440713522584867, 
                                                   0.000333725382308514, 0.000440771063101499, 0.000330888958820384, 
                                                   0.000335177057648398, 0.00027488295896592, 0.000518376675120886, 
                                                   0.000258107439200671, 0.000295378252143169, 1.33813016467029e-05, 
                                                   0.000170515172372076, 0.000160470677229974, 9.8859042573522e-05, 
                                                   4.77094034798514e-06, 0.000779128855726363, 2.80463220089782e-05, 
                                                   0.000407571008174826, 4.76025086993255e-05, 1.6605450183472e-05, 
                                                   0.000437149280986268, 5.37106562163918e-05, 4.82654666645295e-05, 
                                                   5.56927962541369e-05, 6.13875350181571e-05, 7.23571226639171e-05, 
                                                   0.000139020374377688, 0.000183535432147331, 2.80463220089782e-05, 
                                                   0.00027648488631673, 0.000168280725021817, 5.21403981691148e-05, 
                                                   2.80463220089782e-05, 2.80463220089782e-05, 2.80463220089782e-05, 
                                                   2.80463220089782e-05, 2.80463220089782e-05, 2.80463220089782e-05, 
                                                   3.53603278692284e-05, 0.000774068073825739, 8.72875026642225e-05, 
                                                   0.000231402667811853, 2.51299208991313e-05, 7.37528096121726e-05
                      ), LOD = c(0.0034397051289882, 5.68047780523916e-05, 5.68047780523916e-05, 
                                   5.68047780523916e-05, 5.68047780523916e-05, 6.54592102975903e-05, 
                                   8.42044278641221e-05, 0.00110045642460291, 5.68047780523916e-05, 
                                   6.62922790737467e-05, 5.97908405798548e-05, 5.68047780523916e-05, 
                                   0.000485444017223116, 7.59323332783847e-05, 9.34269632583946e-05, 
                                   5.68047780523916e-05, 0.000202856928583584, 5.68047780523916e-05, 
                                   0.000628230889994026, 9.13108026060008e-05, 0.000162375214276451, 
                                   0.00124474651246522, 6.05143500495826e-05, 0.000765789119095523, 
                                   0.000705778973990029, 0.000439267485838453, 0.000271485757636799, 
                                   0.000264355137702171, 0.000913605153098551, 0.000841832877175541, 
                                   0.00150097653600645, 0.000440713522584867, 0.000333725382308514, 
                                   0.000440771063101499, 0.000330888958820384, 0.000335177057648398, 
                                   0.00027488295896592, 0.000518376675120886, 0.000258107439200671, 
                                   0.000295378252143169, 5.68047780523916e-05, 0.000170515172372076, 
                                   0.000160470677229974, 9.8859042573522e-05, 5.68047780523916e-05, 
                                   0.000779128855726363, 5.68047780523916e-05, 0.000407571008174826, 
                                   5.68047780523916e-05, 5.68047780523916e-05, 0.000437149280986268, 
                                   5.68047780523916e-05, 5.68047780523916e-05, 5.68047780523916e-05, 
                                   6.13875350181571e-05, 7.23571226639171e-05, 0.000139020374377688, 
                                   0.000183535432147331, 5.68047780523916e-05, 0.00027648488631673, 
                                   0.000168280725021817, 5.68047780523916e-05, 5.68047780523916e-05, 
                                   5.68047780523916e-05, 5.68047780523916e-05, 5.68047780523916e-05, 
                                   5.68047780523916e-05, 5.68047780523916e-05, 5.68047780523916e-05, 
                                   0.000774068073825739, 8.72875026642225e-05, 0.000231402667811853, 
                                   5.68047780523916e-05, 7.37528096121726e-05), cen = c(0, 1, 
                                                                                          1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 
                                                                                          0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 
                                                                                          1, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 1, 
                                                                                          1, 1, 1, 1, 0, 0, 0, 1, 0)), class = c("tbl_df", "tbl", "data.frame"
                                                                                          ), row.names = c(NA, -74L))

Peto-Peto one-factor test

pval <- cen1way(set1$LOD, 
               set1$cen, set1$ID, mcomp.method = "BH", printstat = TRUE)

Obtaining the significance letters

CLD <- cldList(P.adj ~ Comparison, data=pval$res)
CLD

Solution

  • You have to dig through the structure of the output from cen1way() to get the part you want. And then I think you need to convert it to a complete square matrix to pass it to multcompView.

    cldList() doesn't handle p-values in that kind of matrix format.

    You can examine the structure of the output with e.g. str(Cen1), as defined below.

    library(NADA2)
    
    Cen1 <- cen1way(set1$LOD, 
                    set1$cen, set1$ID, mcomp.method = "BH", printstat = TRUE)
     
    Pval = Cen1$mcomp$p.value
    
    Pval
    
    library(rcompanion)
    
    PT = fullPTable(Pval)
    
    PT
    
    library(multcompView)
    
    multcompLetters(PT)
    
       ###    A    B    C    D    E    F    G    H 
       ### "ab"  "a" "ab"  "b"  "b"  "a"  "a"  "a"