Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This issue ended up being more multifaceted than originally thought.
--- Prior issue: ---
While exploring the bug, a separate (but related) issue was noticed. On standard
(s)plsda
objects (ie. non-MINT), only some of thebackground.predict()
regions (or polygons) would display. Only thing that resolved this issue was manually adjusting thexlim
andylim
parameters (increasing their bounds). This occured only forstyle = ggplot2
. Theggplot2
package entirely removes polygons from the plot if a certain percentage of said polygon is outside the range of the axes (ie, if plot too zoomed in, polygon won't show). Previouslyinternal_graphicModule()
had used the bounds of the points as the defaultxlim
andylim
, resulting in this cutoff.Hence, to resolve this, if a background is supplied (and
xlim
/ylim
are not supplied) toplotIndiv()
, then the default value of the limit parameters is set to the average of the minimum/maximum values of the points and the polygons. This allows the plot to not be too 'zoomed out' as well as the polygons to be shown.--- Immediate Issue: ---
The error raised when trying to use
dist = "max.dist"
inbackground.predict()
on amint.splsda
object was caused by the absence of thecenter
andscale
attributes on themint.splsda$ind.mat
object. It had these for each study individually, but global values are needed forbackground.predict()
. Using the follow externally would result in incorrect values for these attributes:mint.res.object$ind.mat <- scale(mint.res.object$ind.mat)
Hence,
mean_centering_per_study()
was adjusted such that if thecenter
andscale
parameters wereTRUE
, irrespective of whether it is a MINT object or not, the globalcenter
andscale
attributes will be appended to theind.mat
object.--- Downstream issue: ---
The above fix resolved the error noted in Issue #24, however upon using the
plotIndiv()
function with a supplied background (on themint.splsda
object), no background would be shown. This was due to the absence of any code which handles background polygons within theif (style == "ggplot2-MINT")
block (starts on line 364 ofinternal_graphicModule()
).Hence, the code from the
if (style == "ggplot2")
which handles backgrounds was copied over into the MINT block. On top of this,plotIndiv.mint()
was slightly adjusted so thenames(background.object)
are converted into colours. This is how it is handled in the standard sPLSDA case so this process was homogenised for consistency's sake.