Learn R Programming

sidier (version 1.0)

HapPerPop: Returns the number of haplotypes per population.

Description

Given a two column matrix, this function returns the number of haplotypes per population. The input matrix must contain one row per individual. The first column must contain the population name, while the second must contain the name of the haplotype. The desired matrix can be obtained using "FindHaplo".

Usage

HapPerPop(readfile = T, sep = " ", header = F, inputFile = NA, input = NA, saveFile = T, Wname = NA, Iname = NA)

Arguments

readfile
a logical; if TRUE (default) the input matrix is provided in a text file. If FALSE, the matrix is provided as an R object.
sep
the character separating columns in the input matrix (space, by default).
header
a logical value indicating whether the input matrix contains the names of the variables as its first line. (Default=FALSE).
inputFile
(if readfile=TRUE) the name of the file containing the input matrix.(if readfile=TRUE) the name of the file containing the input matrix.
input
a logical; if TRUE (default), the two ouput matrices computed are saved as two different text files.
saveFile
a logical; if TRUE (default), the two ouput matrices computed are saved as two different text files.
Wname
the name given to the output weighted matrix file.
Iname
the name given to the output interaction matrix file

Value

  • A list containing two matrices.
  • comp1The first matrix contains the weighted matrix, that is, the number of haplotypes (columns) found per population (rows).
  • comp2The second is the interaction matrix, containing information about the presence or absence of each haplotype (columns) per population (rows).

Details

Two output matrices are estimated, one giving the abundance of each haplotype per population (named weighted matrix) and the other representing presence/absence of each haplotype per population by 1/0 (named interaction matrix).

See Also

FindHaplo

Examples

Run this code
cat("Sequence.Name Haplotype.Name",
"Population1 H1",
"Population1 H2",
"Population1 H3",
"Population1 H2",
"Population2 H4",
"Population2 H5",
"Population2 H6",
"Population2 H4",
"Population3 H7",
"Population3 H7",
"Population3 H7",
"Population3 H7",
     file = "3_FindHaplo_Example2_modified.txt", sep = "")
     example2_2 <- read.table("3_FindHaplo_Example2_modified.txt",header=TRUE)
	 FH<-read.table("3_FindHaplo_Example2_modified.txt",header=TRUE)

# Reading the alignment from an object and saving the two computed distance matrices:
HapPerPop(readfile=FALSE,input=FH,header=TRUE,saveFile=FALSE)

# Reading the alignment directly from file, displaying only the weighted matrix:
HapPerPop(readfile=TRUE,inputFile="3_FindHaplo_Example2_modified.txt",header=TRUE,saveFile=FALSE)[[1]]

Run the code above in your browser using DataLab