Learn R Programming

haplotypes (version 1.1.3.1)

grouping-methods: Groups haplotypes according to the grouping variable (populations, species, etc.)

Description

Function for creating a matrix with haplotypes as rows, grouping factor (populations, species, etc.) as columns and abundance as entries.

Usage

# S4 method for Haplotype
grouping(x,factors)

Value

a list with two components:

hapmat:

a matrix with haplotypes as rows, levels of the grouping factor (populations, species, etc.) as columns and abundance as entries.

hapvec:

a vector giving the haplotype identities of individuals.

Arguments

x

an object of class Haplotype.

factors

a vector or factor giving the grouping variable (populations, species, etc.), with one element per individual.

Methods

signature(x = "Haplotype")

Author

Caner Aktas, caktas.aca@gmail.com

See Also

haplotype

Examples

Run this code
data("dna.obj")
x<-dna.obj[1:6,,as.matrix=FALSE]
# inferring haplotypes from DNA sequences
h<-haplotype(x) 

## Grouping haplotypes.
# character vector 'populations' is a grouping factor.
populations<-c("pop1","pop1","pop2","pop3","pop3","pop3") 

# length of the argument 'factor' is equal to the number of sequences
g<-grouping(h,factors=populations) 
g

Run the code above in your browser using DataLab