Error saving pdf: Error in grDevices::pdf(file = filename, ..., version = version) : invalid font type

created at 06-03-2022 views: 12

error message

Error in grDevices::pdf(file = filename, ..., version = version) :
invalid font type
In addition: Warning messages:
1: In grDevices::pdf(file = filename, ..., version = version) :
font family 'Helvetica' not found in PostScript font database
2: In grDevices::pdf(file = filename, ..., version = version) :
font family 'Helvetica' not found in PostScript font database

code

An error was reported when WGCNA performed the GO enrichment mapping of the module

### Omitted before
  load(file = 'step1_input.Rdata')
  load(file = "step2_beta_value.Rdata")
  load(file = "step3_genes_modules.Rdata")
  load(file = "step4_design.Rdata")

  table(moduleColors)
  group_g <- data.frame(gene=colnames(datExpr),
                        group=moduleColors)
  write.csv(group_g,file = "gene_moduleColors.csv",row.names = F, quote = F) ## Export all genes of the corresponding module

  # Select the mouse genome for annotation and ID conversion, if it is human, there is another R package
  library(clusterProfiler)
  library(org.Mm.eg.db)
  library(org.Hs.eg.db)
  tmp <- bitr(group_g$gene,fromType = genetype, # "SYMBOL" "ENSEMBL"
              toType = "ENTREZID",
              OrgDb = OrgDb )
  de_gene_cluster <- merge(tmp,group_g, by.x=genetype, by.y="gene")
  table(de_gene_cluster$group)

  ###run go analysis
  formula_res <- compareCluster(
    ENTREZID~group,
    data = de_gene_cluster,
    fun = "enrichGO",
    OrgDb = OrgDb,
    ont = "BP", #One of "BP", "MF", and "CC" or "ALL"
    pAdjustMethod = "BH",
    pvalueCutoff = 0.05,
    qvalueCutoff = 0.25
  )

  lineage1_ego <- simplify(
    formula_res,
    cutoff=0.5,
    by="p.adjust",
    select_fun=min
  )
  save(group_g,formula_res,lineage1_ego,file="step5_GOananlysis.Rdata")
  #plot
  dotp <- dotplot(lineage1_ego,
                  showCategory=10,
                  label_format=90)
  ggsave(dotp,filename= "step5_modul_GO_term.pdf", width = 1.2*ncol(MEs), height = 2*ncol(MEs))

solution

Add device = cairo_pdf, the picture can be saved, but there is still a warning, if it still reports an error, then go to study how to install the font

created at:06-03-2022
edited at: 06-03-2022: