Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Font in alignments is pixelated #37

Open
ramiromagno opened this issue May 13, 2022 · 3 comments
Open

Font in alignments is pixelated #37

ramiromagno opened this issue May 13, 2022 · 3 comments

Comments

@ramiromagno
Copy link

It seems that the letters of the residues in the alignment are rendered with bitmap fonts...? They look very pixelated in my plots.

Do you got any idea on how I could fix this on my side? Thanks!

library(ggmsa)
#> Registered S3 methods overwritten by 'ggalt':
#>   method                  from   
#>   grid.draw.absoluteGrob  ggplot2
#>   grobHeight.absoluteGrob ggplot2
#>   grobWidth.absoluteGrob  ggplot2
#>   grobX.absoluteGrob      ggplot2
#>   grobY.absoluteGrob      ggplot2
#> Registered S3 method overwritten by 'ggtree':
#>   method      from 
#>   identify.gg ggfun
#> ggmsa v1.3.2  Document: http://yulab-smu.top/ggmsa/
#> 
#> If you use ggmsa in published research, please cite:
#> L Zhou, T Feng, S Xu, F Gao, TT Lam, Q Wang, T Wu, H Huang, L Zhan, L Li, Y Guan, Z Dai*, G Yu* ggmsa: a visual exploration tool for multiple sequence alignment and associated data. Briefings in Bioinformatics. DOI:10.1093/bib/bbac222

protein_sequences <- system.file("extdata", "sample.fasta", package = "ggmsa")
ggmsa(protein_sequences, 300, 350, char_width = 0.5, seq_name = TRUE) + geom_msaBar()
#> Coordinate system already present. Adding new coordinate system, which will replace the existing one.

  
sessionInfo()
#> R version 4.1.2 (2021-11-01)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Arch Linux
#> 
#> Matrix products: default
#> BLAS:   /usr/lib/libopenblasp-r0.3.18.so
#> LAPACK: /usr/lib/liblapack.so.3.10.0
#> 
#> locale:
#>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
#>  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
#>  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
#>  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
#>  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
#> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] ggmsa_1.3.2
#> 
#> loaded via a namespace (and not attached):
#>  [1] maps_3.4.0             tidyr_1.1.4            jsonlite_1.7.2        
#>  [4] assertthat_0.2.1       highr_0.9              stats4_4.1.2          
#>  [7] yulab.utils_0.0.4      GenomeInfoDbData_1.2.6 yaml_2.2.1            
#> [10] Rttf2pt1_1.3.10        pillar_1.6.4           lattice_0.20-45       
#> [13] glue_1.6.0             extrafontdb_1.0        digest_0.6.28         
#> [16] RColorBrewer_1.1-3     XVector_0.32.0         polyclip_1.10-0       
#> [19] colorspace_2.0-2       ggfun_0.0.6            htmltools_0.5.2       
#> [22] pkgconfig_2.0.3        zlibbioc_1.38.0        purrr_0.3.4           
#> [25] patchwork_1.1.1        tidytree_0.3.9         scales_1.1.1          
#> [28] ggplotify_0.1.0        tweenr_1.0.2           ggforce_0.3.3         
#> [31] tibble_3.1.6           generics_0.1.1         farver_2.1.0          
#> [34] IRanges_2.26.0         ggplot2_3.3.5          ellipsis_0.3.2        
#> [37] withr_2.4.2            seqmagick_0.1.5        BiocGenerics_0.40.0   
#> [40] lazyeval_0.2.2         cli_3.3.0              magrittr_2.0.1        
#> [43] crayon_1.4.2           evaluate_0.14          ash_1.0-15            
#> [46] fs_1.5.0               fansi_0.5.0            nlme_3.1-153          
#> [49] MASS_7.3-54            tools_4.1.2            lifecycle_1.0.1       
#> [52] stringr_1.4.0          aplot_0.1.4            S4Vectors_0.30.2      
#> [55] ggtree_3.0.4           munsell_0.5.0          reprex_2.0.1          
#> [58] Biostrings_2.60.2      compiler_4.1.2         ggalt_0.4.0           
#> [61] GenomeInfoDb_1.28.4    gridGraphics_0.5-1     rlang_1.0.2           
#> [64] grid_4.1.2             RCurl_1.98-1.5         rstudioapi_0.13       
#> [67] labeling_0.4.2         bitops_1.0-7           rmarkdown_2.11        
#> [70] proj4_1.0-11           gtable_0.3.0           DBI_1.1.1             
#> [73] R6_2.5.1               knitr_1.36             dplyr_1.0.7           
#> [76] fastmap_1.1.0          extrafont_0.18         utf8_1.2.2            
#> [79] treeio_1.16.2          KernSmooth_2.23-20     ape_5.6-2             
#> [82] stringi_1.7.6          parallel_4.1.2         Rcpp_1.0.7            
#> [85] vctrs_0.4.1            R4RNA_1.20.0           tidyselect_1.1.1      
#> [88] xfun_0.28

Created on 2022-05-13 by the reprex package (v2.0.1)

@nyzhoulang
Copy link
Collaborator

library(ggplot2)
protein_sequences <- system.file("extdata", "sample.fasta", package = "ggmsa")
p <- ggmsa(protein_sequences, 300, 350, char_width = 0.5, seq_name = TRUE) + geom_msaBar()
ggsave("p.png",p, height = 2,width = 8)

You need to set the appropriate aspect ratio of the graphics.
p

@ramiromagno
Copy link
Author

Ah okay, thank you.

But couldn't you make that font not rasterized?

@nyzhoulang
Copy link
Collaborator

But couldn't you make that font not rasterized?

The ggmsa() returns a ggplot object for users.
The fonts in MSA are actually polygons, which can handle various graphics scaling.
Rasterized Fonts are not very suitable in this case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants