2

RStudio で大きなプロットを作成して PDF に保存することがよくありますが、PDF ニット レポートにも部分的に表示したいと考えています。完全なオブジェクトを作成し、一部 (理想的には左上隅) を切り取り、その 2 番目の画像を PDF レポートに含める方法はありますか?

例として、56列と100行のプロットを生成するpheatmapコード。左上の 10 列と 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))

前もってありがとうステファン

4

0 に答える 0