Learn R Programming

RScelestial (version 1.0.4)

as.mutation.matrix: Conversion of ten-state sequencing matrix to 0/1-mutation matrix.

Description

Conversion of ten-state sequencing matrix to 0/1-mutation matrix.

Usage

as.mutation.matrix(seq)

Value

A data frame with exactly the same size as the input seq matrix. The most abundant state in each loci (row) translated to 0, and the others are translated to 1. Missing values are translated to 3.

Arguments

seq

A dataframe representing the ten-state sequencing matrix. Elements of the matrix are the from "X/Y" for X and Y being nucleotides or "./." for missing value. Rows represent loci and columns represent samples.

Examples

Run this code
## A small 10-state matrix
seq = data.frame("C1" = c("C/C", "C/C"), "C2" = c("A/A", NA), "C3" = c("C/C", "A/A"))
## Convert it to mutation matrix
as.mutation.matrix(seq)
#   C1 C2 C3
# 1  0  1  0
# 2  1  3  0

Run the code above in your browser using DataLab