plotVar 5.1.2

Create issue
Issue #46 resolved
Florian Rohart created an issue

SelectVar was changed to simplify the code and bring some consistency in the outputs. This is now impacting on plotVar.

Easy fix is to grab the correct output from selectVar, but:

Since the output are now the same between method (or at least more similar than before), can we reduce the code of plotVar between line 190-308?

Comments (10)

  1. Florian Rohart reporter

    Easy fix is the way to go for the patch, we'll look into simplifying the code after the next release

  2. Florian Rohart reporter

    There is no need to change selectVar because all spls objects are also pls objects. Class(object)=c("spls","pls").

    So selectVar(spls object) calls selectVar.pls

  3. Florian Rohart reporter
    > data(nutrimouse)
    > diet = unmap(nutrimouse$diet)
    > blocks = list(gene = nutrimouse$gene, lipid = nutrimouse$lipid, diet = diet)
    > design = matrix(c(0,1,1,1,0,1,1,1,0), ncol = 3, nrow = 3, byrow = TRUE)
    > nutri.sgcca <- wrapper.sgcca(blocks,design=design, ncomp = c(3, 3, 3))
    > plotVar(nutri.sgcca,comp=c(1,2), blocks = 1:3) #OK
    > plotVar(nutri.sgcca,comp=c(1,2), blocks = c(1,3)) # notOK

    It is a bug: from line 285 in plotVar.R

    if blocks=c(1,3), z in the following code is 1:2 and thus for z=2, the rownames of cord.X2 (block 3) are not in selectVar(object,block=2)

              cord.X = lapply(1 : length(cord.X), function(z){cord.X[[z]][row.names(cord.X[[z]]) %in% unique(unlist(lapply(, function(x) {selectVar(object, block = z, comp = x)[[1]]$name}))), ,drop = FALSE]})
  4. Log in to comment