-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME.Rmd
More file actions
67 lines (53 loc) · 2.56 KB
/
Copy pathREADME.Rmd
File metadata and controls
67 lines (53 loc) · 2.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# DNAPlotR
[](https://travis-ci.org/sherrillmix/dnaplotr)
[](https://codecov.io/github/sherrillmix/dnaplotr?branch=master)
## Install
An R library to plot a visual representation of a vector of DNA sequences. To install directly from github, use the [<code>devtools</code>](https://github.com/hadley/devtools) library and run:
```{r, eval=FALSE}
devtools::install_github("sherrillmix/dnaplotr")
```
Then load the library as normal using:
```{r}
library(dnaplotr)
```
## Main functions
### plotDNA
<code>plotDNA(seqs)</code> takes a character vector of strings representing DNA sequences and plots them to the current device. By default, A, C, T and G are colored, - are colored gray and all other characters are white. For example:
```{r seqExample,tidy=TRUE,results='hide'}
seqs<-c('ACACA','ACACA','ACACT','ACA-A')
plotDNA(seqs)
```
### plotAA
<code>plotAA(seqs)</code> takes a character vector of strings representing amino acid sequences and plots them to the current device. By default, amino acids are colored according to a colorscheme modified from [JMol](http://jmol.sourceforge.net/jscolors/) that seeks to assign similar colors to amino acids with similar properties. In addition, - are colored gray, stop codons (annotated as X) are black and all other characters are white. For example:
```{r aaExample,tidy=TRUE,results='hide'}
fakeAA<-c('MALWTRLRPLLALLALWPPPPARAFVNQHLCGSHLVEALY',
'MALWTRLRPLLALLALWPLPPARAFVNQHLCGSHLVEALY',
'MALWTRLRPLLALLALWPPPPARAFVNX')
plotAA(fakeAA,groups=c('Ref','Sub','Stop'))
```
## Helper functions
### replaceOuterGaps
<code>replaceOuterGaps(seqs)</code> marks gaps at the ends of sequences differently than internal indels. For example:
```{r}
seqs<-c('--AA-A','--AA--','A-AA-A')
replaceOuterGaps(seqs)
```
### replaceAfterStop
<code>replaceAfterStop(seqs)</code> marks amino acids after a stop codon. For example:
```{r}
seqs<-c('AAARXAA','AAARX','ARARAXRRAXAAR')
replaceAfterStop(seqs)
```
## More complex example
A more complex example displaying 1000 sequences is:
```{r,tidy=TRUE,eval=FALSE}
fakeSeqs<-createFakeDNA(1000)
refSeq<-fakeSeqs[1]
fakeSeqs<-fakeSeqs[-1]
species<-sprintf('Species %s',sub(' [0-9]+$','',names(fakeSeqs)))
par(mar=c(3.5,4.4,.5,7))
plotDNA(fakeSeqs,groups=species,groupCexScale=TRUE)
```
To produce something like:

See [generatePlots.R](generatePlots.R) or [inst/doc/example.pdf](the vignette) for complete plotting details.