Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plotLoadings margin problem #45

Closed
aljabadi opened this issue Oct 25, 2019 · 0 comments
Closed

plotLoadings margin problem #45

aljabadi opened this issue Oct 25, 2019 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@aljabadi
Copy link
Collaborator

problem

Trying to do a plotLoading of a diablo object, where the feature names are too long we get an Error:

suppressMessages(library(mixOmics))

data(nutrimouse)
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 = "max")
#> Error in plot.new(): figure margins too large

cause

traceback shows:

traceback()
5: plot.new()
4: barplot.default(df$importance, horiz = TRUE, las = 1, col = df$color, 
       axisnames = TRUE, names.arg = colnames.X, cex.names = size.name, 
       cex.axis = 0.7, beside = TRUE, border = border, xlim = xlim[i, 
           ])
3: barplot(df$importance, horiz = TRUE, las = 1, col = df$color, 
       axisnames = TRUE, names.arg = colnames.X, cex.names = size.name, 
       cex.axis = 0.7, beside = TRUE, border = border, xlim = xlim[i, 
           ]) at plotLoadings.splsda.R#166
2: plotLoadings.sgccda(nutrimouse.sgccda, contrib = "max") at plotLoadings.R#28
1: plotLoadings(nutrimouse.sgccda, contrib = "max")

Even though internally we try to accommodate for length of variables in plot layout, but currently there's no limit in size of the variables which can be long in some datasets. The error is also not informative at its current form.

remedy

A possible solution is to trim long variable names only in plots with a message. As a least-impact remedy, we can simply change the colnames.X passed to barplot functions in various functions, but it should be done before the layout considers their length in the margin specifications.

@aljabadi aljabadi self-assigned this Oct 25, 2019
@aljabadi aljabadi added the bug Something isn't working label Oct 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant