Error when using plotIndiv.sgcca

Create issue
Issue #139 resolved
Lluís Revilla created an issue

I am trying to use plotIndiv on a result obtained from RGCCA::sgcca, however I am getting an error. I tracked the issue and it seems to come from the line 143 of the plotIndiv.sgcca.R file where object$X is called. In my object I don't have an X element, instead I have element Y. Changing this to object$Y would correct this issue.

Comments (5)

  1. Kim-Anh Le Cao repo owner

    Hi Lluis, I believe you are trying to use different packages. plotIndiv is part of mixOmics only, not RGCCA. You could try use mixOmics::wrapper.sgcca and plotIndiv (which is part of mixOmics):

    > ?wrapper.sgcca
    > data(nutrimouse)
    > # need to unmap the Y factor diet if you pretend this is not a classification pb.
    > # see also the function block.splsda for discriminant analysis  where you dont
    > # need to unmap Y.
    > Y = unmap(nutrimouse$diet)
    > data = list(gene = nutrimouse$gene, lipid = nutrimouse$lipid, Y = Y)
    > # with this design, gene expression and lipids are connected to the diet factor
    > # design = matrix(c(0,0,1,
    > #                   0,0,1,
    > #                   1,1,0), ncol = 3, nrow = 3, byrow = TRUE)
    > 
    > # with this design, gene expression and lipids are connected to the diet factor
    > # and gene expression and lipids are also connected
    > design = matrix(c(0,1,1,
    +                   1,0,1,
    +                   1,1,0), ncol = 3, nrow = 3, byrow = TRUE)
    > 
    > #note: the penalty parameters will need to be tuned
    > wrap.result.sgcca = wrapper.sgcca(X = data, design = design, penalty = c(.3,.5, 1),
    +                                   ncomp = 2,
    +                                   scheme = "centroid")
    > plotIndiv(wrap.result.sgcca)
    
  2. Lluís Revilla reporter

    Precisely I thought that plotIndiv having a method for class sgcca would work with the output of sgcca of the RGCCA package. Sincerely having a "wrapper.sgcca" that outputs something of a different definition of the original object that it is mimicking is confusing.

  3. Kim-Anh Le Cao repo owner

    The wrapper.sgcca is a wrapper of sgcca. The results would be the same as RGCCA:sgcca if you used the same input parameters, but RGCCA does not provide any visualisation, so we had to tweak the function,

  4. Lluís Revilla reporter

    No, the code of wrapper.sgcca doesn't call RGCCA (so it isn't a wrapper although does the same as far as I know) and the output is different from that of the RGCCA function. With your example and using RGCCA::sgcca:

    > names(wrap.result.sgcca)
     [1] "call"               "X"                  "variates"          
     [4] "loadings"           "loadings.star"      "design"            
     [7] "penalty"            "scheme"             "ncomp"             
    [10] "crit"               "AVE"                "names"             
    [13] "init"               "tol"                "iter"              
    [16] "max.iter"           "nzv"                "scale"             
    [19] "design"             "scheme"             "explained_variance"
    
    > result.sgcca = sgcca(data, C = design, c1 = c(.3,.5, 1), ncomp = c(2, 2, 2), scheme = "centroid")
    > names(result.sgcca)
    [1] "Y"      "a"      "astar"  "C"      "c1"     "scheme" "ncomp"  "crit"  
    [9] "AVE"
    

    As you can see one outputs Y and the other X, which makes the function of plotIndiv to fail as reported.

  5. Log in to comment