Inroduction to the R package haplotypes

This tutorial is for beginners. It is for Mac OS X users but should work for other operating systems if you have already installed the Package haplotypes (then go to step-6).

1- Download R from:

http://cran.us.r-project.org/

2- After installation, click on R icon to open the R Console:

3- To install packages, on the taskbar under the “Packages & Data” item, choose “Package Installer”.

4- Choose Cran (sources) on the dropdown menu and click the “Get List” button. This returs a list of available source packages.

5- Type “haplotypes” into the ‘Package Search’ field and click the package name, check the “install dependencies” box, and then the “Install Selected” button to install the package.

6- Type or copy and paste the following command at the R console and hit enter.

library(haplotypes)

Examples

Read the FASTA file ‘example.fas’ in the package haplotypes. ‘read.fas()’ function returns an object of class ‘Dna’ (here it is ‘x’), which holds the DNA Sequence data.

f<-system.file("example.fas",package="haplotypes")
x<-read.fas(file=f)
x

Alternatively, you can load the DNA Sequence data set.

data("dna.obj")
x<-dna.obj
x

You can extract or replace parts of the DNA sequences.

x[1:3,1:10]

Compute an absolute pairwise character difference matrix from DNA sequences. ‘distance()’ function returns an object of class ‘dist’.

Code gaps using simple indel coding method.

d<- distance(x,indels="sic")
d

Treat gaps as a fifth state character.

d<- distance(x,indels="5th")
d

Treat gaps as a missing character.

d<- distance(x,indels="missing")
d

Infer haplotypes (unique DNA sequences) using the ‘Dna’ object. Code gaps using simple indel coding method for the distance calculations. ‘haplotype()’ function returns an object of class ‘Haplotypes’.

h<-haplotype(x,indels="s")
h

Conduct statistical parsimony analysis with %95 connection limit. Code gaps using simple indel coding method for distance calculations. ‘parsimnet()’ function returns an object of class ‘Parsimnet’.

p<-parsimnet(x,indels="s",prob=.95)
p

Plot statistical parsimony network with default parameters.

p<-parsimnet(x,indels="s",prob=.95)
plot(p)

You can interactively adjust vertex positions.

p<-parsimnet(x,indels="s",prob=.95)
plot(p,interactive=TRUE)

See also: http://cran.r-project.org/web/packages/haplotypes/haplotypes.pdf

Next: Tutorial 2 (Plot pie charts on a haplotype network)

Reklamlar

Bir Cevap Yazın

Aşağıya bilgilerinizi girin veya oturum açmak için bir simgeye tıklayın:

WordPress.com Logosu

WordPress.com hesabınızı kullanarak yorum yapıyorsunuz. Çıkış  Yap / Değiştir )

Twitter resmi

Twitter hesabınızı kullanarak yorum yapıyorsunuz. Çıkış  Yap / Değiştir )

Facebook fotoğrafı

Facebook hesabınızı kullanarak yorum yapıyorsunuz. Çıkış  Yap / Değiştir )

Google+ fotoğrafı

Google+ hesabınızı kullanarak yorum yapıyorsunuz. Çıkış  Yap / Değiştir )

Connecting to %s