Learn R Programming

poppr (version 1.1.5)

splitcombine: Split a or combine items within a data frame in genind objects (DEPRECATED).

Description

Often, one way a lot of file formats fail is that they do not allow multiple population hierarchies. This can be circumvented, however, by coding all of the hierarchies in one string in the input file with a common separator (eg. "_"). splitcombine will be able to recognise those separators and create a data frame of all the population structures for whatever sub-setting you might need.

Usage

splitcombine(pop, method = 1, dfname = "population_hierarchy", sep = "_",
  hier = 1, setpopulation = TRUE, fixed = TRUE)

Arguments

pop
a genind object.
method
an integer, 1 for splitting, 2 for combining.
dfname
the name of the data frame containing the population structure. for the splitting method, the combined population structure must be in the first column.
sep
The separator used for separating or combining the data. See note.
hier
a vector containing the population hierarchy you wish to split or combine.
setpopulation
logical. if TRUE, the population of the resulting genind object will be that of the highest population structure (split method) or the combined populations (combine method).
fixed
logical. An argument to be passed onto strsplit. If TRUE, sep must match exactly to the populations for the split method.

Value

  • a genind object with a modified data frame in the other slot.

Examples

Run this code
# Method 1: Splitting.
Aeut <- read.genalex(system.file("files/rootrot.csv", package="poppr"))

# We have 19 different "populations", but really, there is a hierarchy.
Aeut$pop.names

# Let's split them up. The default data frame from read.genalex is the same
# as the default for this function.
Aeut <- splitcombine(Aeut, hier=c("Pop", "Subpop"))

# Much better!
Aeut$pop.names

# Method 2: Combining.

data(H3N2)
# Create a new data set combining the population factors of year and country
H.comb <- splitcombine(H3N2, method=2, dfname="x", hier=c("year", "country"))

# Checking to make sure they were actually combined.
head(H.comb$other$x$year_country)
# Creating new data frame in the object to mess around with.
H.comb$other$year_country <- data.frame(H.comb$other$x$year_country)

# Splitting those factors into their original components and setting the
# population to year.
H.comb <- splitcombine(H.comb, method=1, dfname="year_country", hier=c("year", "country"))

Run the code above in your browser using DataLab