Label size in plotLoadings


I use PLSDA with metabolites that have a very long name.
In the loadings plot, these names are cut and I would like to find a solution to display them in full.
I tried to adjust the parameter but it doesn’t resolve my problem.

With = 0.5 :

In red, you can see where the name of the metabolite is cut.
Can you help me ?

Thanks a lot

Hi @hschrieke,

Thanks for using mixOmics.

If the feature names are too long, the plots can become too narrow. For example, if untrimmed, the following plot:

    Y = nutrimouse$diet
    gene = nutrimouse$gene
    lipid = nutrimouse$lipid
    ## extend feature names
    suff <- "-a-long-suffix-from-abolutely-nowhere-which-is-gonna-be-longer-than-margins"
    colnames(gene) <- paste0(colnames(gene), suff)
    colnames(lipid) <- paste0(colnames(lipid), suff)
    data = list(gene = gene, lipid = lipid)
    design = matrix(c(0,1,1,1,0,1,1,1,0), ncol = 3, nrow = 3, byrow = TRUE)
    nutrimouse.sgccda = block.splsda(X = data,
                                     Y = Y,
                                     design = design,
                                     keepX = list(gene = c(10,10), lipid = c(15,15)),
                                     ncomp = 2,
                                     scheme = "centroid")
    plotLoadings(nutrimouse.sgccda, contrib = "min")


Even with one long feature name would run into margin errors or could look like the following (even if no errors occur):

That is why we decided to limit the length of feature names with a message that informs about the trimming. You can still access the full feature names by saving the output from plotLoadings.

pl_res <- plotLoadings(nutrimouse.sgccda, contrib = "min")

I just added a feature to the development version (which you can install using instruction in that allows you to adjust the trim length using a hidden argument. See example below:

    plotLoadings(nutrimouse.sgccda, contrib = "min", 
                 =  50) ## custom trim length

You may increase to any large number you wish that produces a reasonable plot without a margin error.

Please let me know if you run into any issues.

Best wishes,