addpop2string: addpop2string

Description Usage Arguments Value Author(s) See Also Examples

View source: R/addpop2string.R

Description

This function adds population information to a DNAStringSet or an AAStringSet and puts them into the metadata information.
__Note__: All unassigned sequences will be put into pop "unassigned"!
Do not use "unassigned" as a population name!
__Note__: Names in a population in the poplist must match sequence names!
__Note__: Duplicated assignments are allowed!

Usage

1
addpop2string(seq, poplist)

Arguments

seq

DNAStringSet or AAStringSet [mandatory]

poplist

named list of populations either as index or names per population (do not mix index and names in one population) [mandatory]

Value

An object of class DNAStringSet or AAStringSet

Author(s)

Kristian K Ullrich

See Also

addmask2string, addregion2string, addpos2string

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
data(iupac, package="distSTRING")
iupac.aa <- iupac |> cds2aa(shorten = TRUE)
## create poplist
poplist <- list(FRA = grep("Mmd.FRA", names(iupac)),
   GER = grep("Mmd.GER", names(iupac)),
   IRA = grep("Mmd.IRA", names(iupac)),
   AFG = grep("Mmm.AFG", names(iupac)))
iupac.aa <- iupac.aa |> addpop2string(poplist)
iupac.aa@metadata$pop.integer
iupac.aa@metadata$pop.names
## mxixing index and names
poplist <- list(FRA = names(iupac)[grep("Mmd.FRA", names(iupac))],
   GER = grep("Mmd.GER", names(iupac)),
   IRA = names(iupac)[grep("Mmd.IRA", names(iupac))],
   AFG = grep("Mmm.AFG", names(iupac)))
iupac.aa <- iupac.aa |> addpop2string(poplist)
iupac.aa@metadata$pop.integer
iupac.aa@metadata$pop.names
## leaving out some sequences which will be assigned as "unassigned"
poplist <- list(FRA = names(iupac)[grep("Mmd.FRA", names(iupac))],
   GER = grep("Mmd.GER", names(iupac)),
   IRA = names(iupac)[grep("Mmd.IRA", names(iupac))])
iupac.aa <- iupac.aa |> addpop2string(poplist)
iupac.aa@metadata$pop.integer
iupac.aa@metadata$pop.names

kullrich/distSTRING documentation built on Dec. 21, 2021, 8:42 a.m.