如何从大图中取样以knitr-PDF显示

时间:2016-10-04 07:22:31

标签: r plot rstudio pheatmap

我经常在RStudio中创建大图,我将其保存为PDF,但也希望部分显示在PDF编辑报告中。 有没有办法创建完整的对象然后剪切一块(理想情况下左上角)并在PDF报告中包含第二张图片?

例如,一个pheatmap代码,它生成一个包含56列和100行的图。我想只显示左上角10col和10行,但如果我对输入数据进行采样,由于对不同数据进行了聚类,我显然会得到另一个图。此外,我希望适用于任何情节类型的解决方案(不仅仅是pheatmap)。

drows <- "euclidean"
dcols <- "euclidean"
clustmet <- "complete"

col.pal <- c("lightgrey","blue")

main.title <- paste("Variant (freq>", minfreq, "%) in all samples", sep="") 

hm.parameters.maj <- list(hm.maj.data, 
                      color = col.pal,
                      fontsize = 10,
                      cellwidth = 14, 
                      cellheight = 14, 
                      scale = "none",
                      treeheight_row = 200,
                      kmeans_k = NA,
                      show_rownames = T, 
                      show_colnames = T,
                      main = main.title,
                      clustering_method = clustmet,
                      cluster_rows = TRUE, 
                      cluster_cols = FALSE,
                      clustering_distance_rows = drows, 
                      clustering_distance_cols = dcols,
                      legend=FALSE)

# To draw the heatmap on screen (comment-out if you run the script from terminal)
do.call("pheatmap", hm.parameters.maj)

# To draw to file (you may want to adapt the info(header(vcf))sizes)
outfile <- paste("major-variants_heatmap_(freq>", minfreq, ")_", drows, ".pdf", sep="")
do.call("pheatmap", c(hm.parameters.maj, filename=outfile, width=24, height=35))

提前致谢 斯蒂芬

0 个答案:

没有答案
相关问题