makeSingleCross: Cross two individuals together

View source: R/myCross.R

makeSingleCrossR Documentation

Cross two individuals together

Description

Cross two individuals together

Usage

makeSingleCross(ind1, ind2, names, n = 1, verbose = TRUE)

Arguments

ind1

parent 1

ind2

parent 2

names

names of the descendants

n

number of descendants

verbose

print informations

Value

list of new individuals

Examples

### create simulation information
mySimInfo <- simInfo$new(simName = "Simulation Example",
                         simGeno = TRUE,
                         simPheno = TRUE,
                         nSimGeno = 1,
                         nSimPheno = 3,
                         nCoreMax = 4,
                         nCorePerGeno = 1,
                         nCorePerPheno = 3,
                         saveDataFileName = NULL)

### create specie information
mySpec <- specie$new(nChr = 3,
                     lChr = c(100, 150, 200),
                     specName = "Example 1",
                     ploidy = 2,
                     mutRate = 10^-8,
                     recombRate = 10^-6,
                     chrNames = c("C1", "C2", "C3"),
                     nLoci = c(3, 4, 5),
                     recombRateOneVal = FALSE,
                     effPopSize = 3,
                     simInfo = mySimInfo,
                     verbose = TRUE)

### create lociInfo object
myLoci <- lociInfo$new(genoMap = NULL, specie = mySpec)

### simulate haplotype
rawHaplo1 <- matrix(sample(c(0, 1), (3 + 4 + 5) * 2, replace = TRUE),
                    nrow = 2)
colnames(rawHaplo1) <- paste0("Locus_", 1:(3 + 4 + 5))

myHaplo1 <- myBreedSimulatR::haplotype$new(lociInfo = myLoci,
                                           haplo = rawHaplo1)

rawHaplo2 <- matrix(sample(c(0, 1), (3 + 4 + 5) * 2, replace = TRUE),
                    nrow = 2)
colnames(rawHaplo2) <- paste0("Locus_", 1:(3 + 4 + 5))

myHaplo2 <- myBreedSimulatR::haplotype$new(lociInfo = myLoci,
                                           haplo = rawHaplo2)

### create individuals:
myInd1 <-  individual$new(name = "Ind 1",
                          specie = mySpec,
                          parent1 = "OkaaSan1",
                          parent2 = "OtouSan1",
                          haplo = myHaplo1,
                          verbose = TRUE)

myInd2 <-  individual$new(name = "Ind 2",
                          specie = mySpec,
                          parent1 = "OkaaSan2",
                          parent2 = "OtouSan2",
                          haplo = myHaplo2,
                          verbose = TRUE)
offspring <- makeSingleCross(myInd1, myInd2, names = "off 1")
offspring

KosukeHamazaki/myBreedSimulatR documentation built on Aug. 31, 2024, 3:55 p.m.