Sequence difference plot

Here we use the data published in Potato Research(Chang et al. 2015) as an example.

fas <- list.files(system.file("examples","GVariation", package="seqcombo"),
                  pattern="fas", full.names=TRUE)
fas
## [1] "/private/tmp/RtmpdZP9KV/Rinstacc5203a567b/seqcombo/examples/GVariation/A.Mont.fas"  
## [2] "/private/tmp/RtmpdZP9KV/Rinstacc5203a567b/seqcombo/examples/GVariation/B.Oz.fas"    
## [3] "/private/tmp/RtmpdZP9KV/Rinstacc5203a567b/seqcombo/examples/GVariation/C.Wilga5.fas"

The input fasta file should contains two aligned sequences. User need to specify which sequence (1 or 2, 1 by default) as reference. The seqdiff function will parse the fasta file and calculate the nucleotide differences by comparing the non-reference one to reference.

x1 <- seqdiff(fas[1], reference=1)
x1
## sequence differences of Mont and CF_YL21 
## 1181 sites differ:
##   A   C   G   T 
## 286 315 301 279

We can visualize the differences by plot method:

plot(x1)

We can parse several files and visualize them simultaneously.

x <- lapply(fas, seqdiff)
plts <- lapply(x, plot)
plot_grid(plotlist=plts, ncol=1, labels=LETTERS[1:3])

Sequence similarity plot

fas <- system.file("examples/GVariation/sample_alignment.fa", package="seqcombo")
simplot(fas, 'CF_YL21')

Session info

Here is the output of sessionInfo() on the system on which this document was compiled:

## R version 4.1.1 (2021-08-10)
## Platform: x86_64-apple-darwin17.0 (64-bit)
## Running under: macOS Mojave 10.14.6
## 
## Matrix products: default
## BLAS:   /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRblas.0.dylib
## LAPACK: /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRlapack.dylib
## 
## locale:
## [1] C/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
## [1] ggplot2_3.3.5   emojifont_0.5.5 tibble_3.1.3    seqcombo_1.14.1
## 
## loaded via a namespace (and not attached):
##  [1] prettydoc_0.4.1        tidyselect_1.1.1       xfun_0.25             
##  [4] bslib_0.2.5.1          purrr_0.3.4            colorspace_2.0-2      
##  [7] vctrs_0.3.8            generics_0.1.0         htmltools_0.5.1.1     
## [10] stats4_4.1.1           yaml_2.2.1             utf8_1.2.2            
## [13] rlang_0.4.11           jquerylib_0.1.4        pillar_1.6.2          
## [16] withr_2.4.2            glue_1.4.2             DBI_1.1.1             
## [19] BiocGenerics_0.38.0    GenomeInfoDbData_1.2.6 lifecycle_1.0.0       
## [22] stringr_1.4.0          zlibbioc_1.38.0        Biostrings_2.60.2     
## [25] munsell_0.5.0          gtable_0.3.0           evaluate_0.14         
## [28] labeling_0.4.2         knitr_1.33             IRanges_2.26.0        
## [31] GenomeInfoDb_1.28.1    parallel_4.1.1         fansi_0.5.0           
## [34] highr_0.9              proto_1.0.0            scales_1.1.1          
## [37] showtext_0.9-4         S4Vectors_0.30.0       jsonlite_1.7.2        
## [40] XVector_0.32.0         sysfonts_0.8.5         farver_2.1.0          
## [43] digest_0.6.27          stringi_1.7.3          showtextdb_3.0        
## [46] dplyr_1.0.7            cowplot_1.1.1          grid_4.1.1            
## [49] tools_4.1.1            bitops_1.0-7           yulab.utils_0.0.2     
## [52] magrittr_2.0.1         sass_0.4.0             RCurl_1.98-1.4        
## [55] crayon_1.4.1           pkgconfig_2.0.3        ellipsis_0.3.2        
## [58] assertthat_0.2.1       rmarkdown_2.10         R6_2.5.1              
## [61] igraph_1.2.6           compiler_4.1.1

References

Chang, Fei, Fangluan Gao, Jianguo Shen, Wenchao Zou, Shuang Zhao, and Jiasui Zhan. 2015. “Complete Genome Analysis of a PVYN-Wi Recombinant Isolate from Solanum Tuberosum in China.” Potato Research 58 (4): 377–89. https://doi.org/10.1007/s11540-015-9307-3.