code2snp {phyclust} | R Documentation |
Transfer nucleotide codes (A, G, C, T, -) and SNPs (1, 2, -). Transfer nucleotide ids (0, 1, 2, 3, 4) and SNP ids (0, 1, 2).
### S3 methods for a list, vector or matrix (default). code2snp(codeseq) snp2code(snpseq, half = TRUE) nid2sid(nidseq) sid2nid(sidseq, half = TRUE)
codeseq |
a character vector contains nucleotide codes, A, G, C, T, or -. |
snpseq |
a character vector contains SNPs, 1, 2, or -. |
half |
nucleotide codes will be half assigned, see the ‘Details’ for more information. |
nidseq |
a numerical vector contains nucleotide ids, 0, 1, 2, 3, or 4. |
sidseq |
a numerical vector contains SNP ids, 0, 1, or 2. |
These functions are based on the internal object .nucleotide
and
.snp
to transfer nucleotide codes and SNPs.
For code2snp
, A, G are transfered to 1, and C, T are transfered to 2.
For snp2code
, 1 is transfered half to A and G, and 2 is transfered
half to C and T if half = TRUE
. Otherwise, 1 is all transfered to A,
and 2 is all transfered to C.
code2nid
returns a character vector containing nucleotide ids, and
nid2code
returns a character vector containing nucleotide codes.
nid2sid
returns a numerical vector containing SNP ids, and
sid2nid
returns a numerical vector containing nucleotide ids.
Wei-Chen Chen wccsnow@gmail.com
Phylogenetic Clustering Website: http://snoweye.github.io/phyclust/
.nucleotide
,
.snp
,
code2nid
,
nid2code
,
snp2sid
,
sid2snp
.
## Not run: library(phyclust, quiet = TRUE) # For codes a.vector <- c("A", "C", "G", "-", "T") code2snp(a.vector) snp2code(code2snp(a.vector)) snp2code(code2snp(a.vector), half = FALSE) # For ids a.sid.vector <- c(0, 2, 1, 4, 3) nid2sid(a.sid.vector) sid2nid(nid2sid(a.sid.vector)) sid2nid(nid2sid(a.sid.vector), half = FALSE) # Test list a.list <- list(a, a) code2snp(a.list) snp2code(code2snp(a.list)) snp2code(code2snp(a.list), half = FALSE) # Test matrix a.matrix <- rbind(a, a) code2snp(a.matrix) snp2code(code2snp(a.matrix)) snp2code(code2snp(a.matrix), half = FALSE) ## End(Not run)