How to reduce filesize of pdf extracted from pheatmap
2
0
Entering edit mode
4.0 years ago

Hi!

I'm creating heatmaps using pheatmap, to show an overview and clustering of differentially expressed genes. In my experiment I have tons of DEGs (18000 genes across 132 samples), so the heatmap is.. well.. pretty huge!

The problem I'm running into is that the exported file is about 11MB; which makes it impossible to process afterwards in illustrator for publication.

I tried exporting using the filename= argument of pheatmap, and using the pdf() function.

Does anyone know a solution to reduce the filesize?

Thanks in advance, Peter

R RNA-Seq pheatmap heatmap filesize • 3.0k views
ADD COMMENT
0
Entering edit mode
pdf(settings)
yourPheatmapcommand
dev.off()

?

ADD REPLY
0
Entering edit mode

This also results in a too large file; changing width and height dont seem to affect the filesize.

ADD REPLY
1
Entering edit mode
4.0 years ago
ATpoint 86k

You could check section 2.8 of ComplexHeatmap which discusses this including rasterisation of the heatmap and saving in alternative file formats.

Just asking, but you have 18.000 DEGs, how has that come to pass? I usually have 18.000 genes that are being considered after filtering for lowly-expressed ones. You probably know what you're doing but could there be something wrong here? The easiest would be to simply reduce the number of DEGs, either by more stringent testing against a fold-change cutoff or lowering the FDR threshold. 18k is...a lot, not sure how you would ever make any hypothesis from such a result, basically everything is changing, is it?

ADD COMMENT
0
Entering edit mode

Thanks for the answer, I will try through ComplexHeatmap!

I know 18.000 genes is a really big number, it's about 30% of the genes in my organism (cabbage). Indeed basicly everything is changing.. The biological reason is that I have a very strong stressor (a herbivore that's eating the sequenced tissue) and multiple time points. Right now I used an FDR cutoff of <0.01 and LFC <1.5, in DeSEQ2 using apeglm for lfcShrinkage.

I'll investigate lowering the FDR and LFC cutoff even more to get a smaller set. Thanks for the suggestion.

ADD REPLY
1
Entering edit mode
4.0 years ago
thyleal ▴ 160

To my knowledge, your options are:

  1. Rasterize (e.g, PNG, TIFF) and use labels as vectors if you want at least text to be searchable;
  2. Decrease your number of shapes by increasing your threshold for selecting the genes being visualized (18000 is overkill to be honest, are you sure of these results?);
  3. Try different heatmap engines, some of them uses more complex shapes than others;
  4. Try different formats, perhaps you are able to open SVG or EPS (not sure, only helped once).
  5. Try using this tool on your SVG: https://github.com/svg/svgo

Good luck

ADD COMMENT

Login before adding your answer.

Traffic: 2451 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6