I want to compile the mixOmics graphical outputs via ggpubr::ggarrange() - to do this, I need to convert the graphical outputs into ggplot objects first. I managed it well with plotInd() by choosing style = "ggplot2" and extracting the plot via sPLS2.plot.ggplot <- sPLS2.plot$graph.
However, this does not work with plotVar() as this function returns a data frame. Is there a way to save the variable plot as a ggplot object?
Thank you in advance.
Best,
Luise
Edit: I also face the same difficulties with the plotLoadings() function.
I apologise for my inconcrete question.
I want to save / convert the plot generated via plotVar() and plotLoadings() in a ggplot2-format, so I can then include this plot in my figure panel, generated via ggarrange().
Is there a neat way to convert /plot this plotVar object into a ggplot2 object, so I can include the figure below (generated solely by running plotVar()) in my ggarrange() panel?
Hi @l.bel ,
a nice workaround is to export the data from the mixomics object using$graph at the end of the prompt and use the data to create your own ggplot graph.
Here is an example form the pca data but it works with any object.
Let me know if this works for you
get the data
dat.pca.moxL_mrn ← plotIndiv(final.pca.moxL_mrn,
comp = c(1, 2), # Specify components to plot
ind.names = F, # Show row names of samples
group = san_moxL_mrn$pop_gen, # your grouping
title = ‘mRNA’, # doent actually matter
legend = TRUE,
legend.title = ‘Stage’)$graph # this is the $graph prompt that gives you the data