Learn R Programming

poppr (version 1.1.5)

clonecorrect: Remove potential bias caused by cloned genotypes in genind or genclone object.

Description

This function removes any duplicated multilocus genotypes from any specified population hierarchy.

Usage

clonecorrect(pop, hier = 1, dfname = "population_hierarchy",
  combine = FALSE, keep = 1)

Arguments

pop
a genind object
hier
a hierarchical formula or numeric vector. In a genclone object, this will define the columns of the data frame in the hierarchy slot to use. In a genind object, the data
dfname
a character string. Only for genind objects This is the name of the data frame or list containing the vectors of the population hierarchy within the other slot of the ge
combine
logical. When set to TRUE, the heirarchy will be combined to create a new population for the clone corrected genind or genclone object.
keep
integer. When combine is set to FALSE, you can use this flag to choose the levels of your population hierarchy. For example: if your clone correction hierarchy is set to "Pop", "Subpop", and "Year", and you wan

Value

  • a clone corrected genclone or genind object.

Details

This function will clone correct based on the hierarchical level provided. To clone correct indiscriminantly of hierarchical structure, set hier = NA. It is recommended to use this function with genclone objects as they have a specific slot for hierarchies. If you wish to use this function on a genind object, see below.

Examples

Run this code
# LOAD A. euteiches data set
data(Aeut)

# Redefine it as a genclone object
Aeut <- as.genclone(Aeut, hier = other(Aeut)$population_hierarchy[-1])

# Check the number of multilocus genotypes
mlg(Aeut)
Aeut$pop.names

# Clone correct at the population level.
Aeut.pop <- clonecorrect(Aeut, hier= ~Pop)
mlg(Aeut.pop)
Aeut.pop$pop.names

# Clone correct at the subpopulation level with respect to population and
# combine.
Aeut.subpop <- clonecorrect(Aeut, hier=~Pop/Subpop, combine=TRUE)
mlg(Aeut.subpop)
Aeut.subpop$pop.names

# Do the same, but set to the population level.
Aeut.subpop2 <- clonecorrect(Aeut, hier=~Pop/Subpop, keep=1)
mlg(Aeut.subpop2)
Aeut.subpop2$pop.names

# LOAD H3N2 dataset
data(H3N2)

# Extract only the individuals located in China
country <- clonecorrect(H3N2, hier= ~country, dfname="x")

# How many isolates did we have from China before clone correction?
length(which(other(H3N2)$x$country=="China")) # 155

# How many unique isolates from China after clone correction?
length(which(other(country)$x$country=="China")) # 79

# Something a little more complicated. (This could take a few minutes on
# slower computers)

# setting the hierarchy to be Country > Year > Month
c.y.m <- clonecorrect(H3N2, hier= ~year/month/country, dfname="x")

# How many isolates in the original data set?
length(other(H3N2)$x$country) # 1903

# How many after we clone corrected for country, year, and month?
length(other(c.y.m)$x$country) # 1190

Run the code above in your browser using DataLab