[R] How to save Results in svg format

David Carlson dc@r|@on @end|ng |rom t@mu@edu
Fri Dec 4 06:21:37 CET 2020

If you look at the examples on the manual pages for the upgma() and NJ()
functions you will see that the results are generally sent to the plot()
function. To save that graph as an .svg file you need to open a graphics
device using the svg() function, plot the data, and close the graphics
device. You probably need something like the following:




There are numerous arguments that set various details for the plot that you
should look at (?svg).

David L Carlson
Texas A&M University

On Thu, Dec 3, 2020 at 10:24 PM Anas Jamshed <anasjamshed1994 using gmail.com>

> #Loading the required libraries
> library(ape)
> library(phangorn)
> library(seqinr)
> #Importing the required file
> align_5 <- read.alignment("C:/Users/VAMSI/align 5.fasta", format = "fast")
> align_119 <- read.alignment("C:/Users/VAMSI/align 119.fasta", format =
> "fasta")
> Computing the distance matrix for both UPGMA and NJ algorithms
> implementation.
>  matrix_5x5 <- dist.alignment(align_5, matrix = "identity")
> summary(matrix_5x5)
> matrix_119x119 <- dist.alignment(align_119, matrix = "identity")
> summary(matrix_119x119)
> #Implementation of UPGMA algorithm for a small matrix (5x5) and entire
> matrix (119x119)
> UPGMA_5x5 <- upgma(matrix_5x5)
> UPGMA_119x119 <- upgma(matrix_119x119)
> summary(UPGMA_5x5)
> summary(UPGMA_119x119)
> #Implementation of NJ algorithm for a small matrix (5x5) and entire
> matrix (119x119)
> NJ_5x5 <- NJ(matrix_5x5)
> NJ_119x119 <- NJ(matrix_119x119)
> summary(NJ_5x5)
> summary(NJ_119x119)
> I have done this whole analysis but don't know how can I  the save my
> tree file in svg or some other image format . In the avove script , I
> am applying the phylogenetic algorithm on the distance matrix which I
> have created through fasta file
>         [[alternative HTML version deleted]]
> ______________________________________________
> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://urldefense.com/v3/__https://stat.ethz.ch/mailman/listinfo/r-help__;!!KwNVnqRv!T-8PRCLc041aD-rW1ehtb14tfQAVpWdpBddf_q6Raeho0RbG9wDodEK_QDpGMCc$
> PLEASE do read the posting guide
> https://urldefense.com/v3/__http://www.R-project.org/posting-guide.html__;!!KwNVnqRv!T-8PRCLc041aD-rW1ehtb14tfQAVpWdpBddf_q6Raeho0RbG9wDodEK_1H9sJRs$
> and provide commented, minimal, self-contained, reproducible code.

	[[alternative HTML version deleted]]

More information about the R-help mailing list