if (!require("BiocManager"))
install.packages("BiocManager")
BiocManager::install("ggmsa")
ggmsa is a package designed to plot multiple sequence alignments.
This package implements functions to visualize publication-quality multiple sequence alignments (protein/DNA/RNA) in R extremely simple and powerful. It uses module design to annotate sequence alignments and allows to accept other data sets for diagrams combination.
In this tutorial, we’ll work through the basics of using ggmsa.
library(ggmsa)
We’ll start by importing some example data to use throughout this
tutorial. Expect FASTA files, some of the objects in R can also
as input. available_msa()
can be used to list MSA objects
currently available.
available_msa()
#> 1.files currently available:
#> .fasta
#> 2.XStringSet objects from 'Biostrings' package:
#> DNAStringSet RNAStringSet AAStringSet BStringSet DNAMultipleAlignment RNAMultipleAlignment AAMultipleAlignment
#> 3.bin objects:
#> DNAbin AAbin
protein_sequences <- system.file("extdata", "sample.fasta",
package = "ggmsa")
miRNA_sequences <- system.file("extdata", "seedSample.fa",
package = "ggmsa")
nt_sequences <- system.file("extdata", "LeaderRepeat_All.fa",
package = "ggmsa")
The most simple code to use ggmsa:
ggmsa(protein_sequences, 300, 350, color = "Clustal",
font = "DroidSansMono", char_width = 0.5, seq_name = TRUE )
ggmsa predefines several color schemes for rendering MSA
are shipped in the package. In the same ways, using
available_msa()
to list color schemes currently available.
Note that amino acids (protein) and nucleotides (DNA/RNA) have
different names.
available_colors()
#> 1.color schemes for nucleotide sequences currently available:
#> Chemistry_NT Shapely_NT Taylor_NT Zappo_NT
#> 2.color schemes for AA sequences currently available:
#> ClustalChemistry_AA Shapely_AA Zappo_AA Taylor_AA LETTER CN6 Hydrophobicity
Several predefined fonts are shipped ggmsa.
Users can use available_fonts()
to list the font currently available.
available_fonts()
#> font families currently available:
#> helvetical mono TimesNewRoman DroidSansMono
ggmsa supports annotations for MSA. Similar to the ggplot2,
it implements annotations by geom
and users can perform
annotation with +
, like this: ggmsa() + geom_*()
.
Automatically generated annotations that containing colored
labels and symbols are overlaid on MSAs to indicate
potentially conserved or divergent regions.
For example, visualizing multiple sequence alignment with sequence logo and bar chart:
ggmsa(protein_sequences, 221, 280, seq_name = TRUE, char_width = 0.5) +
geom_seqlogo(color = "Chemistry_AA") + geom_msaBar()
This table shows the annnotation layers supported by ggmsa as following:
Annotation modules | Type | Description |
---|---|---|
geom_seqlogo() | geometric layer | automatically generated sequence logos for a MSA |
geom_GC() | annotation module | shows GC content with bubble chart |
geom_seed() | annotation module | highlights seed region on miRNA sequences |
geom_msaBar() | annotation module | shows sequences conservation by a bar chart |
geom_helix() | annotation module | depicts RNA secondary structure as arc diagrams(need extra data) |
Check out the guides for learning everything there is to know about all the different features:
#> R version 4.1.1 (2021-08-10)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Ubuntu 20.04.3 LTS
#>
#> Matrix products: default
#> BLAS: /home/biocbuild/bbs-3.14-bioc/R/lib/libRblas.so
#> LAPACK: /home/biocbuild/bbs-3.14-bioc/R/lib/libRlapack.so
#>
#> locale:
#> [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
#> [3] LC_TIME=en_GB LC_COLLATE=C
#> [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] kableExtra_1.3.4 ggplot2_3.3.5 ggmsa_1.0.0 BiocStyle_2.22.0
#>
#> loaded via a namespace (and not attached):
#> [1] httr_1.4.2 sass_0.4.0 maps_3.4.0
#> [4] tidyr_1.1.4 viridisLite_0.4.0 jsonlite_1.7.2
#> [7] bslib_0.3.1 assertthat_0.2.1 BiocManager_1.30.16
#> [10] highr_0.9 stats4_4.1.1 yulab.utils_0.0.4
#> [13] GenomeInfoDbData_1.2.7 yaml_2.2.1 Rttf2pt1_1.3.9
#> [16] pillar_1.6.4 glue_1.4.2 extrafontdb_1.0
#> [19] digest_0.6.28 RColorBrewer_1.1-2 XVector_0.34.0
#> [22] polyclip_1.10-0 rvest_1.0.2 colorspace_2.0-2
#> [25] ggfun_0.0.4 htmltools_0.5.2 pkgconfig_2.0.3
#> [28] magick_2.7.3 bookdown_0.24 zlibbioc_1.40.0
#> [31] purrr_0.3.4 webshot_0.5.2 patchwork_1.1.1
#> [34] scales_1.1.1 svglite_2.0.0 ggplotify_0.1.0
#> [37] tweenr_1.0.2 ggforce_0.3.3 tibble_3.1.5
#> [40] generics_0.1.1 farver_2.1.0 IRanges_2.28.0
#> [43] ellipsis_0.3.2 withr_2.4.2 seqmagick_0.1.5
#> [46] BiocGenerics_0.40.0 magrittr_2.0.1 crayon_1.4.1
#> [49] evaluate_0.14 ash_1.0-15 fansi_0.5.0
#> [52] MASS_7.3-54 xml2_1.3.2 tools_4.1.1
#> [55] lifecycle_1.0.1 stringr_1.4.0 aplot_0.1.1
#> [58] S4Vectors_0.32.0 munsell_0.5.0 Biostrings_2.62.0
#> [61] compiler_4.1.1 ggalt_0.4.0 jquerylib_0.1.4
#> [64] GenomeInfoDb_1.30.0 systemfonts_1.0.3 gridGraphics_0.5-1
#> [67] rlang_0.4.12 grid_4.1.1 RCurl_1.98-1.5
#> [70] rstudioapi_0.13 bitops_1.0-7 labeling_0.4.2
#> [73] rmarkdown_2.11 proj4_1.0-10.1 gtable_0.3.0
#> [76] DBI_1.1.1 R6_2.5.1 knitr_1.36
#> [79] dplyr_1.0.7 fastmap_1.1.0 extrafont_0.17
#> [82] utf8_1.2.2 KernSmooth_2.23-20 stringi_1.7.5
#> [85] Rcpp_1.0.7 vctrs_0.3.8 R4RNA_1.22.0
#> [88] tidyselect_1.1.1 xfun_0.27