You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何从R包ropls导出高分辨率Summary图用于学术发表?

How to Save High-Resolution ropls Summary Plots for Academic Publication

Got it, let's get your ropls plots saved in publication-ready TIFF and PDF formats with high resolution. The default plot() call in ropls displays the plot in R's default graphics window, but to capture it in a file, you'll need to use R's built-in graphics device functions. Here's a step-by-step solution tailored to your code:

Step 1: Full Reproducible Code with Saving Logic

Replace your existing plot code with this—it will generate the OPLS-DA model and save the summary plot in both required formats:

# Install and load ropls (if not already installed)
if (!requireNamespace("ropls", quietly = TRUE)) {
  source("http://bioconductor.org/biocLite.R")
  biocLite("ropls")
}
library(ropls)

# Load sample data and create OPLS-DA model
data(sacurine)
# Using `with()` instead of `attach()` to avoid cluttering your global environment
sacurine.oplsda <- with(sacurine, opls(dataMatrix, sampleMetadata[, "gender"], predI = 1, orthoI = NA))

# Save as high-resolution PDF
# Adjust width/height (in inches) to fit your publication's requirements
pdf("sacurine_oplsda_summary.pdf", width = 8, height = 6)
plot(sacurine.oplsda)
dev.off() # Critical: closes the PDF device to finalize the file

# Save as 300 DPI TIFF (standard for academic publications)
tiff("sacurine_oplsda_summary.tif", width = 8, height = 6, units = "in", res = 300)
plot(sacurine.oplsda)
dev.off()

Key Details to Note:

  • Resolution: The res = 300 argument in tiff() sets the resolution to 300 DPI, which is the industry standard for peer-reviewed journals.
  • Dimensions: Adjust width and height (in inches) to match the figure size guidelines of your target publication—most journals specify preferred dimensions for figures.
  • Device Closure: Always call dev.off() after plotting to close the graphics device. If you skip this, the output file will be corrupted and unreadable.
  • Avoid attach(): Using with() instead of attach() keeps your global environment clean and prevents naming conflicts with other variables in your workspace.

Bonus: Tweaking Plot Elements (If Needed)

If you need to customize the plot (e.g., font size, colors, titles), you can add global graphics parameters before plotting, or use arguments specific to ropls::plot():

# Example: Adjust font sizes and use Arial font (common in publications)
par(cex.lab = 1.2, cex.axis = 1.1, family = "Arial")

# Open device and plot with custom title
pdf("sacurine_oplsda_summary_custom.pdf", width = 8, height = 6)
plot(sacurine.oplsda, main = "OPLS-DA Summary: Sacurine Dataset (Gender)")
dev.off()

内容的提问来源于stack exchange,提问作者Variety

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 06:14:27