├── .gitignore ├── .travis.yml ├── CMakeLists.txt ├── DESCRIPTION ├── DESCRIPTION.in ├── NAMESPACE ├── R ├── Pillai.R ├── Rcpp_exceptions.R ├── addExtraMarkerFromRawCall.R ├── addExtraMarkers.R ├── additionOperators.R ├── as.mpInterval.R ├── assignFounderPattern.R ├── assignFounderPatternPrototype.R ├── backcrossPedigree.R ├── biparentalDominant.R ├── callFromMap.R ├── canSkipValidity.R ├── changeMarkerPosition.R ├── combineGenotypes.R ├── combineKeepRF.R ├── compressedProbabilities.R ├── computeAllEpistaticChiSquared.R ├── computeGenotypeProbabilities.R ├── createSNPTemplate.R ├── detailedPedigree-class.R ├── eightWayPedigreeImproperFunnels.R ├── eightWayPedigreeRandomFunnels.R ├── eightWayPedigreeSingleFunnel.R ├── estimateMap.R ├── estimateMapFromImputation.R ├── estimateRF.R ├── estimateRFSingleDesign.R ├── expand.R ├── expandedProbabilities.R ├── exportMapToPretzl.R ├── extraImputationPoints.R ├── f2Pedigree.R ├── finals.R ├── fixedNumberOfFounderAlleles.R ├── formGroups.R ├── founders.R ├── fourParentPedigreeRandomFunnels.R ├── fourParentPedigreeSingleFunnel.R ├── fullHetData.R ├── generateGridPositions.R ├── generateIntervalMidPoints.R ├── geneticData-class.R ├── getAllFunnels.R ├── getChromosomes.R ├── getIntercrossingAndSelfingGenerations.R ├── getPositions.R ├── hetData-class.R ├── hetData.R ├── identC.R ├── imputationGenerics.R ├── impute.R ├── imputeFounders.R ├── jitterMap.R ├── lg-class.R ├── lineNames.R ├── listCodingErrors.R ├── map-class.R ├── mapFunctions.R ├── markers.R ├── mpcross-class.R ├── mpcross.R ├── multiparentSNP.R ├── multiparentSNPPrototype.R ├── nFounders.R ├── nLines.R ├── nMarkers.R ├── num_threads.R ├── orderCross.R ├── pedigree-class.R ├── pedigree.R ├── pedigreeGraph-class.R ├── pedigreeGraph.R ├── pedigreeToGraph.R ├── plot.R ├── plotMosaic.R ├── plotProbabilities.R ├── print.R ├── probabilityData.R ├── purdyToPedigree.R ├── rawSymmetricMatrix.R ├── redact.R ├── removeHets.R ├── reorderPedigree.R ├── reverseChromosomes.R ├── rf-class.R ├── rilPedigree.R ├── roxygen.R ├── selfing.R ├── show.R ├── simulateMPCross.R ├── simulatePhenotypes.R ├── singleLocusProbabilities.R ├── sixteenParentPedigreeRandomFunnels.R ├── stripPedigree.R ├── subset.R ├── testDistortion.R ├── toMpMap.R ├── transposeProbabilities.R ├── twoParentPedigree.R └── validation.R ├── README.md ├── data ├── callFromMapExampleLocalisationStatistics.RData ├── eightParentSubsetMap.RData ├── simulatedFourParentData.RData └── wsnp_Ku_rep_c103074_89904851.RData ├── inst ├── generateDatasets │ └── generateExample1.R └── mathematica │ ├── .gitignore │ ├── finiteSelfingIntercrossing16Way.nb │ ├── finiteSelfingIntercrossing16Way.states │ ├── finiteSelfingIntercrossing4Way.nb │ ├── finiteSelfingIntercrossing4WaySingleFunnel.nb │ ├── finiteSelfingIntercrossing8Way.nb │ ├── finiteSelfingIntercrossing8WaySingleFunnel.nb │ ├── finiteSelfingIntercrossing8WaySinglePoint.nb │ └── finiteSelfingIntercrossingF2.nb ├── man ├── addExtraMarkerFromRawCall.Rd ├── addExtraMarkers.Rd ├── as.mpInterval.Rd ├── assignFounderPattern.Rd ├── backcrossPedigree.Rd ├── biparentalDominant.Rd ├── callFromMap.Rd ├── changeMarkerPosition.Rd ├── clusterOrderCross.Rd ├── combineKeepRF.Rd ├── combineMpcross.Rd ├── computeAllEpistaticChiSquared.Rd ├── computeGenotypeProbabilities.Rd ├── detailedPedigree-class.Rd ├── eightParentPedigreeImproperFunnels.Rd ├── eightParentPedigreeRandomFunnels.Rd ├── eightParentPedigreeSingleFunnel.Rd ├── eightParentSubsetMap.Rd ├── estimateMap.Rd ├── estimateMapFromImputation.Rd ├── estimateRF.Rd ├── estimateRFSingleDesign.Rd ├── existingLocalisationStatistics.Rd ├── expand.Rd ├── exportMapToPretzl.Rd ├── extraImputationPoints.Rd ├── f2Pedigree.Rd ├── finalNames.Rd ├── finals.Rd ├── fixedNumberOfFounderAlleles.Rd ├── flatImputationMapNames.Rd ├── formGroups.Rd ├── founderNames.Rd ├── founders.Rd ├── fourParentPedigreeRandomFunnels.Rd ├── fourParentPedigreeSingleFunnel.Rd ├── fromMpMap.Rd ├── generateGridPositions.Rd ├── generateIntervalMidPoints.Rd ├── geneticData-class.Rd ├── getAllFunnels.Rd ├── getAllFunnelsIncAIC.Rd ├── getChromosomes.Rd ├── getIntercrossingAndSelfingGenerations.Rd ├── getPositions.Rd ├── hetData.Rd ├── hetsForSNPMarkers.Rd ├── imputationData.Rd ├── imputationKey.Rd ├── imputationMap.Rd ├── impute.Rd ├── imputeFounders.Rd ├── infiniteSelfing.Rd ├── initialize.Rd ├── internalOperators.Rd ├── jitterMap.Rd ├── lineNamesGeneric.Rd ├── lineNamesMpcross.Rd ├── lineNamesPedigree.Rd ├── linesByNames.Rd ├── listCodingErrors.Rd ├── listCodingErrorsInfiniteSelfing.Rd ├── mapFunctions.Rd ├── markers.Rd ├── mpcross-class.Rd ├── mpcross.Rd ├── mpcrossMapped-class.Rd ├── mpcrossMapped.Rd ├── mpcrossRF-class.Rd ├── multiparentSNP.Rd ├── nFounders.Rd ├── nLines.Rd ├── nMarkers.Rd ├── normalPhenotype.Rd ├── openmp.Rd ├── orderCross.Rd ├── pedigree-class.Rd ├── pedigree.Rd ├── pedigreeGraph-class.Rd ├── pedigreeToGraph.Rd ├── plot-addExtraMarkersStatistics-ANY-method.Rd ├── plot-pedigreeGraph-ANY-method.Rd ├── plot.Rd ├── plotMosaic.Rd ├── plotProbabilities.Rd ├── probabilities-class.Rd ├── probabilityData.Rd ├── redact.Rd ├── removeHets.Rd ├── reverseChromosomes.Rd ├── rilPedigree.Rd ├── selfing.Rd ├── simulateMPCross.Rd ├── simulatedFourParentData.Rd ├── sixteenParentPedigreeRandomFunnels.Rd ├── stripPedigree.Rd ├── subset.Rd ├── testDistortion.Rd ├── toMpMap.Rd ├── transposeProbabilities.Rd ├── twoParentPedigree.Rd └── wsnp_Ku_rep_c103074_89904851.Rd ├── src ├── .gitignore ├── CMakeLists.txt ├── FindR.cmake ├── Makefile.in ├── Makevars ├── alleleDataErrors.cpp ├── alleleDataErrors.h ├── array2.h ├── arsa.cpp ├── arsa.h ├── arsaRaw.cpp ├── arsaRaw.h ├── arsaRawREntryPoint.cpp ├── arsaRawREntryPoint.h ├── assignFounderPattern.cpp ├── assignFounderPattern.h ├── checkHets.cpp ├── checkHets.h ├── checkImputedBounds.cpp ├── checkImputedBounds.h ├── combineGenotypes.cpp ├── combineGenotypes.h ├── combineRFDisjoint.cpp ├── combineRFDisjoint.h ├── compressedProbabilities.cpp ├── compressedProbabilities.h ├── compressedProbabilities_RInterface.cpp ├── compressedProbabilities_RInterface.h ├── computeAllEpistaticChiSquared.cpp ├── computeAllEpistaticChiSquared.h ├── computeGenotypeProbabilities.cpp ├── computeGenotypeProbabilities.h ├── constructLookupTable.h ├── convertGeneticData.cpp ├── convertGeneticData.h ├── crc32.cpp ├── crc32.h ├── dspMatrix.cpp ├── dspMatrix.h ├── eightParentPedigreeImproperFunnels.cpp ├── eightParentPedigreeImproperFunnels.h ├── eightParentPedigreeRandomFunnels.cpp ├── eightParentPedigreeRandomFunnels.h ├── eightParentPedigreeSingleFunnel.cpp ├── eightParentPedigreeSingleFunnel.h ├── estimateRF.cpp ├── estimateRF.h ├── estimateRFCheckFunnels.cpp ├── estimateRFCheckFunnels.h ├── estimateRFSingleDesign.cpp ├── estimateRFSingleDesign.h ├── estimateRFSingleDesignInternal.cpp ├── estimateRFSingleDesignInternal.h ├── estimateRFSpecificDesign.cpp ├── estimateRFSpecificDesign.h ├── expandedProbabilities_RInterface.cpp ├── expandedProbabilities_RInterface.h ├── forwardsBackwards.h ├── forwardsBackwardsFiniteSelfing.h ├── forwardsBackwardsFiniteSelfingApplyFunnel.h ├── forwardsBackwardsFiniteSelfingApplyIntercrossing.h ├── forwardsBackwardsInfiniteSelfing.h ├── forwardsBackwardsInfiniteSelfingApplyFunnel.h ├── forwardsBackwardsInfiniteSelfingApplyIntercrossing.h ├── fourParentPedigreeRandomFunnels.cpp ├── fourParentPedigreeRandomFunnels.h ├── fourParentPedigreeSingleFunnel.cpp ├── fourParentPedigreeSingleFunnel.h ├── funnelHaplotypeToMarker.h ├── funnelHaplotypeToMarkerFiniteSelfing.h ├── funnelHaplotypeToMarkerInfiniteSelfing.h ├── funnelsToUniqueValues.cpp ├── funnelsToUniqueValues.h ├── generateDesignMatrix.cpp ├── generateDesignMatrix.h ├── generateGenotypes.cpp ├── generateGenotypes.h ├── generateKeys.cpp ├── generateKeys.h ├── getAllFunnels.cpp ├── getAllFunnels.h ├── getAllFunnelsIncAIC.cpp ├── getAllFunnelsIncAIC.h ├── getFunnel.cpp ├── getFunnel.h ├── getMinAIGenerations.cpp ├── getMinAIGenerations.h ├── haldaneToRf.cpp ├── haldaneToRf.h ├── hclustMatrices.cpp ├── hclustMatrices.h ├── identC.cpp ├── identC.h ├── impossibleDataException.h ├── impute.cpp ├── impute.h ├── imputeFounders.cpp ├── imputeFounders.h ├── intercrossingAndSelfingGenerations.cpp ├── intercrossingAndSelfingGenerations.h ├── intercrossingHaplotypeToMarker.h ├── intercrossingHaplotypeToMarkerFiniteSelfing.h ├── intercrossingHaplotypeToMarkerInfiniteSelfing.h ├── joinMapWithExtra.cpp ├── joinMapWithExtra.h ├── mapFunctions.cpp ├── mapFunctions.h ├── markerPatternsToUniqueValues.cpp ├── markerPatternsToUniqueValues.h ├── matrices.h ├── matrix.h ├── matrixChunks.cpp ├── matrixChunks.h ├── mpMap2_openmp.cpp ├── mpMap2_openmp.h ├── multiparentSNP.cpp ├── multiparentSNP.h ├── order.cpp ├── order.h ├── orderFunnel.cpp ├── orderFunnel.h ├── parsePurdy.cpp ├── parsePurdy.h ├── preClusterStep.cpp ├── preClusterStep.h ├── probabilities.h ├── probabilities16.cpp ├── probabilities16.h ├── probabilities16IntermediateProbabilitiesMask.h ├── probabilities2.cpp ├── probabilities2.h ├── probabilities4.cpp ├── probabilities4.h ├── probabilities8.cpp ├── probabilities8.h ├── probabilitiesOther.h ├── rawSymmetricMatrix.cpp ├── rawSymmetricMatrix.h ├── recodeFoundersFinalsHets.cpp ├── recodeFoundersFinalsHets.h ├── recodeHetsAsNA.h ├── register.cpp ├── removeHets.cpp ├── removeHets.h ├── reorderPedigree.cpp ├── reorderPedigree.h ├── replaceHetsWithNA.cpp ├── singleLocusProbabilities_RInterface.cpp ├── singleLocusProbabilities_RInterface.h ├── sixteenParentPedigreeRandomFunnels.cpp ├── sixteenParentPedigreeRandomFunnels.h ├── sortPedigreeLineNames.cpp ├── sortPedigreeLineNames.h ├── stripPedigree.cpp ├── stripPedigree.h ├── testDistortion.cpp ├── testDistortion.h ├── transformForMPWGAIM.cpp ├── transformForMPWGAIM.h ├── transposeProbabilities.cpp ├── transposeProbabilities.h ├── unitTypes.h ├── viterbi.h ├── viterbiFiniteSelfing.h ├── viterbiFiniteSelfingApplyFunnel.h ├── viterbiFiniteSelfingApplyIntercrossing.h ├── viterbiInfiniteSelfing.h ├── viterbiInfiniteSelfingApplyFunnel.h ├── viterbiInfiniteSelfingApplyIntercrossing.h ├── warnings.cpp └── warnings.h ├── tests ├── slow │ ├── test-addExtraMarkers.R │ ├── test-arsaRaw.R │ ├── test-computeAllEpistaticChiSquared.R │ ├── test-computeGenotypeProbabilities2ParentFiniteNoErrors.R │ ├── test-computeGenotypeProbabilities2ParentFiniteWithErrors.R │ ├── test-computeGenotypeProbabilities4ParentFiniteNoErrors.R │ ├── test-computeGenotypeProbabilities4ParentFiniteWithErrors.R │ ├── test-computeGenotypeProbabilities8ParentFinite.R │ ├── test-eightParentPedigreeRandomFunnels.R │ ├── test-estimateRf16Parent.R │ ├── test-estimateRf2Parent.R │ ├── test-estimateRf4Parent.R │ ├── test-estimateRf8Parent.R │ ├── test-estimateRf8ParentImproper.R │ ├── test-estimateRfBackcross.R │ ├── test-estimateRfSingle16Parent.R │ ├── test-estimateRfSingle8Parent.R │ ├── test-gbLimitOption.R │ ├── test-imputeFounders4ParentFiniteNoIntercrossWithErrors.R │ ├── test-imputeTheta.R │ ├── test-openmp.R │ └── test-order.R ├── testthat.R └── testthat │ ├── test-addExtraMarkerFromRawCall.R │ ├── test-addMpcross.R │ ├── test-addMpcrossRf.R │ ├── test-approximatelyUninformative8.R │ ├── test-as.mpInterval4Parent.R │ ├── test-as.mpInterval8Parent.R │ ├── test-assignFounderPatternPrototype.R │ ├── test-backcrossPedigree.R │ ├── test-biparentalDominant.R │ ├── test-changeMarkerPosition.R │ ├── test-combineGenotypes.R │ ├── test-combineKeepRF.R │ ├── test-combinedEstimateRf2Parent.R │ ├── test-computeGenotypeProbabilities2ParentInfiniteNoErrors.R │ ├── test-computeGenotypeProbabilities2ParentInfiniteWithErrors.R │ ├── test-computeGenotypeProbabilities4ParentInfinite.R │ ├── test-computeGenotypeProbabilities8ParentInfinite.R │ ├── test-constructLookupTable.R │ ├── test-countValuesToEstimate.R │ ├── test-detailedPedigree.R │ ├── test-detailedPedigreeValidation.R │ ├── test-dspMatrix.R │ ├── test-eightParentPedigreeImproperFunnels.R │ ├── test-eightParentPedigreeSingleFunnel.R │ ├── test-estimateMap.R │ ├── test-estimateMapFromImputation.R │ ├── test-estimateRFInternal.R │ ├── test-estimateRf.R │ ├── test-estimateRfMarkerRowsColumns.R │ ├── test-expand.R │ ├── test-expandedProbabilities.R │ ├── test-formGroups.R │ ├── test-fourParentPedigreeRandomFunnels.R │ ├── test-fourParentPedigreeSingleFunnel.R │ ├── test-generateGenotypes.R │ ├── test-generateIntervalMidPoints.R │ ├── test-geneticDataValidation.R │ ├── test-getAllFunnels.R │ ├── test-getChromosomes.R │ ├── test-getPositions.R │ ├── test-hclustMatrices.R │ ├── test-hetDataValidation.R │ ├── test-hets.R │ ├── test-imputationGenerics.R │ ├── test-imputeFounders2ParentFiniteNoErrors.R │ ├── test-imputeFounders2ParentInfiniteNoErrors.R │ ├── test-imputeFounders2ParentInfiniteWithErrors.R │ ├── test-imputeFounders4ParentFiniteIntercrossNoErrors.R │ ├── test-imputeFounders4ParentFiniteIntercrossWithErrors.R │ ├── test-imputeFounders4ParentFiniteNoIntercrossNoErrors.R │ ├── test-imputeFounders4ParentInfiniteNoErrors.R │ ├── test-imputeFounders4ParentInfiniteWithErrors.R │ ├── test-imputeFounders8ParentInfiniteNoErrors.R │ ├── test-imputeFoundersExtraPositions.R │ ├── test-imputeFoundersImproper.R │ ├── test-lgValidation.R │ ├── test-mapValidation.R │ ├── test-mpcross.R │ ├── test-mpcrossLGValidation.R │ ├── test-mpcrossMappedValidation.R │ ├── test-mpcrossRFValidation.R │ ├── test-mpcrossValidation.R │ ├── test-multiparentSNP.R │ ├── test-pedigreeValidation.R │ ├── test-plot.R │ ├── test-plotProbabilities.R │ ├── test-preClusterStep.R │ ├── test-rawSymmetricMatrix.R │ ├── test-removeHets.R │ ├── test-reorderPedigree.R │ ├── test-rfValidation.R │ ├── test-simulateMPCross.R │ ├── test-singleIndexToPair.R │ ├── test-singleLocusProbabilities.R │ ├── test-sixteenParentPedigreeRandomFunnels.R │ ├── test-subset.mpcross.R │ ├── test-subset.mpcrossLG.R │ ├── test-subset.mpcrossMapped.R │ ├── test-subset.mpcrossRF.R │ ├── test-toMpMap.R │ ├── test-transposeProbabilities.R │ ├── test-uninformative4.R │ ├── test-uninformative8.R │ ├── test-warnImproperFunnels.R │ └── test-withoutLineWeights.R └── vignettes ├── MAGIC4.pdf ├── MAGIC8.pdf ├── approximatelyFlatSingleFunnel00.pdf ├── approximatelyFlatSingleFunnel01.pdf ├── approximatelyFlatSingleFunnel10.pdf ├── approximatelyFlatSingleFunnel11.pdf ├── funnelsIllustration.pdf ├── informativeSingleFunnel00.pdf ├── informativeSingleFunnel01.pdf ├── informativeSingleFunnel10.pdf ├── informativeSingleFunnel11.pdf ├── mpMap2.Rnw ├── mpMap2.bib ├── multipointApproximation.pdf ├── uninformativeSingleFunnel00.pdf ├── uninformativeSingleFunnel01.pdf ├── uninformativeSingleFunnel10.pdf └── uninformativeSingleFunnel11.pdf /.gitignore: -------------------------------------------------------------------------------- 1 | inst/doc 2 | doc 3 | Meta 4 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: required 2 | dist: trusty 3 | services: docker 4 | 5 | env: 6 | global: 7 | - DOCKER_OPTS="--rm -ti -v $(pwd):/mnt -w /mnt" 8 | 9 | before_install: 10 | - docker pull rohanshahcsiro/mpmap2-ci 11 | 12 | install: 13 | - docker run ${DOCKER_OPTS} rohanshahcsiro/mpmap2-ci R CMD build --no-build-vignettes . 14 | 15 | notifications: 16 | email: 17 | on_success: change 18 | on_failure: always 19 | 20 | after_failure: 21 | - find *Rcheck -name '*.fail' -print -exec cat '{}' \; 22 | - find *Rcheck -name '00install.out' -print -exec tail -n 100 '{}' \; 23 | - find *Rcheck -name '00check.log' -print -exec tail -n 100 '{}' \; 24 | 25 | script: 26 | - docker run ${DOCKER_OPTS} --env _R_CHECK_FORCE_SUGGESTS_=false rohanshahcsiro/mpmap2-ci R CMD check --no-vignettes --no-manual mpMap2_*.tar.gz 27 | -------------------------------------------------------------------------------- /DESCRIPTION.in: -------------------------------------------------------------------------------- 1 | Package: mpMap2 2 | Type: Package 3 | Title: Genetic Analysis of Multi-Parent Recombinant Inbred Lines 4 | Version: 1.0.3 5 | Date: 2020-04-23 6 | Author: Rohan Shah [aut, cre], 7 | Emma Huang [aut], 8 | Matthew Morell [ctb], 9 | Alex Whan [ctb], 10 | Colin Cavanagh [ctb] 11 | Authors@R: c(person("Rohan", "Shah", role = c("aut", "cre"), email = "cran@bookshah.com"), 12 | person("B.", "Emma", "Huang", role = c("aut")), 13 | person("Matthew", "Morell", role = "ctb"), 14 | person("Alex", "Whan", role = "ctb"), 15 | person("Colin", "Cavanagh", role = "ctb")) 16 | Maintainer: Rohan Shah 17 | Description: Constructing linkage maps, reconstructing haplotypes, 18 | estimating linkage disequilibrium and quantitative trait loci 19 | (QTL) mapping in multi-parent Recombinant Inbred Lines designs. 20 | License: GPL-2 21 | SystemRequirements: C++11 22 | LazyLoad: yes 23 | Depends: 24 | R (>= 3.5.0), 25 | progress 26 | Suggests: 27 | testthat, 28 | knitr, 29 | rmarkdown, 30 | Heatplus, 31 | gridExtra 32 | Imports: 33 | ggplot2, 34 | Matrix, 35 | methods, 36 | qtl, 37 | igraph, 38 | fastcluster, 39 | pryr, 40 | nnls, 41 | RColorBrewer, 42 | jsonlite, 43 | sn, 44 | car 45 | VignetteBuilder: knitr 46 | 47 | -------------------------------------------------------------------------------- /R/Pillai.R: -------------------------------------------------------------------------------- 1 | #copied from car package 2 | # which itself has a note that that was a copy of an unexported function from the stats package 3 | Pillai <- function (eig, q, df.res) { 4 | test <- sum(eig/(1 + eig)) 5 | p <- length(eig) 6 | s <- min(p, q) 7 | n <- 0.5 * (df.res - p - 1) 8 | m <- 0.5 * (abs(p - q) - 1) 9 | tmp1 <- 2 * m + s + 1 10 | tmp2 <- 2 * n + s + 1 11 | c(test, (tmp2/tmp1 * test)/(s - test), s * tmp1, s * tmp2) 12 | } 13 | -------------------------------------------------------------------------------- /R/Rcpp_exceptions.R: -------------------------------------------------------------------------------- 1 | .rcpp_error_recorder <- function(e){ 2 | invisible( .Call( "rcpp_error_recorder", e ) ) 3 | } 4 | 5 | .warningsEnv <- new.env() 6 | .warningsEnv$warnings <- character() 7 | 8 | .rcpp_warning_recorder <- function(w){ 9 | .warningsEnv$warnings <- append(.warningsEnv$warnings, w$message) 10 | invokeRestart("muffleWarning") 11 | } 12 | 13 | .rcpp_collect_warnings <- function() { 14 | warnings <- .warningsEnv$warnings 15 | .warningsEnv$warnings <- character() 16 | warnings 17 | } 18 | 19 | 20 | -------------------------------------------------------------------------------- /R/backcrossPedigree.R: -------------------------------------------------------------------------------- 1 | #' @title Generate a backcross pedigree which starts from inbred founders 2 | #' 3 | #' @description Generate a backcross pedigree which starts from inbred founders 4 | #' @details Generate a backcross pedigree which starts from inbred founders 5 | #' 6 | #' @param populationSize The size of the generated population. 7 | #' @return An object of class \code{detailedPedigree} representing the experimental design, suitable for simulation using simulateMPCross. 8 | #' @examples 9 | #' pedigree <- backcrossPedigree(1000) 10 | #' #This pedigree is automatically marked as involving finite generations of selfing. 11 | #' selfing(pedigree) 12 | #' @export 13 | backcrossPedigree <- function(populationSize) 14 | { 15 | entries <- 6 + populationSize 16 | father <- mother <- vector(mode = "integer", entries) 17 | observed <- vector(mode = "logical", entries) 18 | observed[7:(6+populationSize)] <- TRUE 19 | lineNames <- paste0("L", 1:entries) 20 | 21 | mother[1:4] <- father[1:4] <- 0L 22 | mother[5] <- father[5] <- 2L 23 | mother[6] <- 1L 24 | father[6] <- 2L 25 | mother[7:(6+populationSize)] <- 6L 26 | father[7:(6+populationSize)] <- 5L 27 | return(new("detailedPedigree", lineNames = lineNames, mother = mother, father = father, initial = 1:4L, observed = observed, selfing = "finite", warnImproperFunnels = FALSE)) 28 | } 29 | -------------------------------------------------------------------------------- /R/combineGenotypes.R: -------------------------------------------------------------------------------- 1 | combineGenotypes <- function(finals, hetData) 2 | { 3 | isHetDataArgument(hetData) 4 | isNumericMatrixArgument(finals) 5 | if(ncol(finals) != 2*length(hetData)) 6 | { 7 | stop("Inconsistent dimensions for inputs") 8 | } 9 | if(any(colnames(finals) != names(hetData))) 10 | { 11 | stop("Inconsistent names for inputs") 12 | } 13 | .Call("combineGenotypes", finals, hetData, PACKAGE = "mpMap2") 14 | } -------------------------------------------------------------------------------- /R/compressedProbabilities.R: -------------------------------------------------------------------------------- 1 | compressedProbabilities <- function(nFounders, r, nFunnels, intercrossingGenerations, selfingGenerations, infiniteSelfing) 2 | { 3 | if(!(nFounders %in% c(2, 4, 8, 16))) stop("Input nFounders must be one of 2, 4, 8, or 16") 4 | .Call("compressedProbabilities", nFounders, r, nFunnels, intercrossingGenerations, selfingGenerations, infiniteSelfing, PACKAGE="mpMap2") 5 | } 6 | -------------------------------------------------------------------------------- /R/expandedProbabilities.R: -------------------------------------------------------------------------------- 1 | expandedProbabilitiesInfinite <- function(nFounders, r, nFunnels, intercrossingGenerations) 2 | { 3 | if(!(nFounders %in% c(2, 4, 8, 16))) stop("Input nFounders must be one of 2, 4, 8, or 16") 4 | .Call("expandedProbabilitiesInfinite", nFounders, r, nFunnels, intercrossingGenerations, PACKAGE="mpMap2") 5 | } 6 | expandedProbabilitiesFinite <- function(nFounders, r, nFunnels, intercrossingGenerations, selfingGenerations, phased) 7 | { 8 | if(!(nFounders %in% c(2, 4, 8, 16))) stop("Input nFounders must be one of 2, 4, 8, or 16") 9 | .Call("expandedProbabilitiesFinite", nFounders, r, nFunnels, intercrossingGenerations, selfingGenerations, phased, PACKAGE="mpMap2") 10 | } 11 | -------------------------------------------------------------------------------- /R/extraImputationPoints.R: -------------------------------------------------------------------------------- 1 | #' @title Get out non-marker positions used for IBD genotype imputation 2 | #' @description Get out non-marker positions used for IBD genotype imputation 3 | #' @details Extract non-marker positions used for IBD genotype imputation 4 | #' @param mpcrossMapped The object from which to get the non-marker positions 5 | #' @return A vector of genetic position names. 6 | #' @export 7 | extraImputationPoints <- function(mpcrossMapped) 8 | { 9 | if(!inherits(mpcrossMapped, "mpcrossMapped")) 10 | { 11 | stop("Input object must have class mpcrossMapped") 12 | } 13 | if(length(mpcrossMapped) != 1) 14 | { 15 | stop("Input object must contain only a single experiment") 16 | } 17 | return(setdiff(flatImputationMapNames(mpcrossMapped), unlist(lapply(mpcrossMapped@map, names)))) 18 | } 19 | -------------------------------------------------------------------------------- /R/f2Pedigree.R: -------------------------------------------------------------------------------- 1 | #' @title Generate an F2 pedigree which starts from inbred founders 2 | #' 3 | #' @description 4 | #' Generate an F2 pedigree which starts from inbred founders 5 | #' 6 | #' @param populationSize The size of the generated population. 7 | #' @return An object of class \code{detailedPedigree} representing the experimental design, suitable for simulation using simulateMPCross. 8 | #' @export 9 | #' @examples 10 | #' pedigree <- f2Pedigree(1000) 11 | #' #This pedigree is automatically marked as involving finite generations of selfing. 12 | #' selfing(pedigree) 13 | f2Pedigree <- function(populationSize) 14 | { 15 | pedigree <- twoParentPedigree(initialPopulationSize = 1, selfingGenerations = 1, intercrossingGenerations = 0, nSeeds = populationSize) 16 | pedigree@selfing <- "finite" 17 | return(pedigree) 18 | } 19 | -------------------------------------------------------------------------------- /R/fullHetData.R: -------------------------------------------------------------------------------- 1 | fullHetData <- function(map, nFounders) 2 | { 3 | nonNegativeIntegerArgument(nFounders) 4 | isMapArgument(map) 5 | 6 | repeatedValue <- cbind(as.matrix(expand.grid(1:nFounders, 1:nFounders)), 0L) 7 | repeatedValue[seq(1, nFounders*nFounders, by = nFounders+1),3] <- 1:nFounders 8 | 9 | #Put in allele values 10 | for(row in 1:nrow(repeatedValue)) 11 | { 12 | if(repeatedValue[row, 3] == 0) 13 | { 14 | if(repeatedValue[row, 2] > repeatedValue[row, 1]) 15 | { 16 | repeatedValue[row, 3] <- repeatedValue[nFounders * (repeatedValue[row,1]-1) + repeatedValue[row,2],3] 17 | } 18 | else repeatedValue[row, 3] <- max(repeatedValue[,3])+1L 19 | } 20 | } 21 | dimnames(repeatedValue) <- NULL 22 | allMarkers <- unlist(lapply(map, names)) 23 | retVal <- replicate(length(allMarkers), repeatedValue, simplify=FALSE) 24 | names(retVal) <- allMarkers 25 | return(new("hetData", retVal)) 26 | } -------------------------------------------------------------------------------- /R/generateGridPositions.R: -------------------------------------------------------------------------------- 1 | #' @title Specify an equally spaced grid of genetic positions 2 | #' @description Specify an equally spaced grid of genetic positions 3 | #' @details Some functions, such as \code{imputeFounders} and \code{computeGenotypeProbabilities}, take in a set of genetic positions as one of the inputs. This function is an easy way to specify an equally spaced grid of positions. 4 | #' 5 | #' Note that the return value is itself a function, which is applied internally by \code{imputeFounders} or \code{computeGenotypeProbabilities} to an object of class \code{mpcrossMapped}. 6 | #' @param spacing The spacing of the genetic positions, in cM. 7 | #' @return A function which can be applied to an object of class \code{mpcrossMapped} by \code{imputeFounders} or \code{computeGenotypeProbabilities}. 8 | #' @examples 9 | #' data(simulatedFourParentData) 10 | #' #Create object that includes the correct map 11 | #' mapped <- new("mpcrossMapped", simulatedFourParentData, map = simulatedFourParentMap) 12 | #' #Estimate IBD genotypes at all the markers, and marker midpoints 13 | #' imputed <- imputeFounders(mapped, errorProb = 0.02, 14 | #' extraPositions = generateGridPositions(1)) 15 | #' @export 16 | generateGridPositions <- function(spacing) 17 | { 18 | retFunction <- function(object) 19 | { 20 | result <- lapply(as.list(names(object@map)), function(chrName) 21 | { 22 | x <- object@map[[chrName]] 23 | range <- range(x) 24 | positions <- seq(range[1], range[2], by = spacing) 25 | names(positions) <- paste0("Chr", chrName, "Loc", 1:length(positions)) 26 | positions 27 | }) 28 | names(result) <- names(object@map) 29 | result 30 | } 31 | return(retFunction) 32 | } 33 | -------------------------------------------------------------------------------- /R/getChromosomes.R: -------------------------------------------------------------------------------- 1 | #' @title Get chromosome assignment per marker 2 | #' @description Get chromosome assignment per marker from an \code{mpcross} object. 3 | #' @details Extract a character vector, with names corresponding to markers, and values corresponding to the chromosome on which the named marker is located. 4 | #' @param markers The markers for which we want the chromosomes 5 | #' @param mpcrossMapped The object containing the map of interest 6 | #' @return A character vector, with names corresponding to markers, and values corresponding to the chromosome on which the named marker is located. 7 | #' @examples 8 | #' map <- qtl::sim.map() 9 | #' pedigree <- f2Pedigree(1000) 10 | #' cross <- simulateMPCross(map = map, pedigree = pedigree, mapFunction = haldane, seed = 1) 11 | #' mappedCross <- mpcrossMapped(cross = cross, map = map) 12 | #' chromosomeAssignment <- getChromosomes(mappedCross, markers(mappedCross)) 13 | #' chromosomeAssignment 14 | #' @export 15 | getChromosomes <- function(mpcrossMapped, markers) 16 | { 17 | isNewMpcrossMappedArgument(mpcrossMapped) 18 | if(missing(markers) || !is.character(markers) || any(is.na(markers))) 19 | { 20 | stop("Input markers must be a character vector, without missing values") 21 | } 22 | chromosomeIndices <- unlist(sapply(markers, function(marker) 23 | { 24 | which(unlist(lapply(mpcrossMapped@map, function(x) !is.na(match(marker, names(x)))))) 25 | })) 26 | result <- names(mpcrossMapped@map)[chromosomeIndices] 27 | names(result) <- markers 28 | return(result) 29 | } 30 | -------------------------------------------------------------------------------- /R/getIntercrossingAndSelfingGenerations.R: -------------------------------------------------------------------------------- 1 | #' @title Identify number of generations of intercrossing and selfing, per genetic line 2 | #' @description Identify number of generations of intercrossing and selfing, per genetic line 3 | #' @details Many structured populations consist of a number of generations of mixing, followed by a number of generations of intercrossing, followed by inbreeding. This function identifies the number of generations of selfing and intercrossing, for each genetic line, in the case of 4-way, 8-way or 16-way multi-parent design. 4 | #' @param cross The \code{mpcross} object containing the pedigree to be analysed. 5 | #' @return An integer matrix with two columns, giving the number of generations of selfing and intercrossing, for each genetic line. Or in the case of multiple experiments contained within a single object, a list of such matrices. 6 | #' @export 7 | getIntercrossingAndSelfingGenerations <- function(cross) 8 | { 9 | if(length(cross@geneticData) == 1) 10 | { 11 | result <- .Call("getIntercrossingAndSelfingGenerationsExport", cross@geneticData[[1]]@pedigree, cross@geneticData[[1]]@finals, PACKAGE="mpMap2") 12 | asMatrix <- do.call(cbind, result) 13 | rownames(asMatrix) <- rownames(finals(cross)) 14 | return(asMatrix) 15 | } 16 | else 17 | { 18 | result <- lapply(cross@geneticData, 19 | function(x) 20 | { 21 | asMatrix <- do.call(cbind, .Call("getIntercrossingAndSelfingGenerationsExport", x@pedigree, x@finals, PACKAGE="mpMap2")) 22 | rownames(asMatrix) <- rownames(x@finals) 23 | return(asMatrix) 24 | }) 25 | return(result) 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /R/getPositions.R: -------------------------------------------------------------------------------- 1 | #' @title Get positions of genetic markers 2 | #' @description Get positions of genetic markers, on their respective chromosomes 3 | #' @details Get positions of genetic markers in cM, on their respective chromosomes 4 | #' @examples 5 | #' map <- qtl::sim.map() 6 | #' pedigree <- f2Pedigree(1000) 7 | #' cross <- simulateMPCross(map = map, pedigree = pedigree, mapFunction = haldane, seed = 1) 8 | #' mappedCross <- mpcrossMapped(cross = cross, map = map) 9 | #' getPositions(mappedCross, c("D13M3", "DXM1", "DXM3")) 10 | #' @param mpcrossMapped The \code{mpcross} object containing the map of interest 11 | #' @param markers The markers for which to get the positions 12 | #' @return A named vector of numbers, with names corresponding to the selected genetic markers, and values corresponding to genetic positions. 13 | #' @export 14 | getPositions <- function(mpcrossMapped, markers) 15 | { 16 | isNewMpcrossMappedArgument(mpcrossMapped) 17 | if(missing(markers) || !is.character(markers) || any(is.na(markers))) 18 | { 19 | stop("Input markers must be a character vector, without missing values") 20 | } 21 | markerPositions <- unlist(sapply(markers, function(marker) 22 | { 23 | na.omit(unlist(lapply(mpcrossMapped@map, function(x) x[marker]))) 24 | })) 25 | names(markerPositions) <- markers 26 | return(markerPositions) 27 | } 28 | -------------------------------------------------------------------------------- /R/hetData-class.R: -------------------------------------------------------------------------------- 1 | checkHets <- function(object) 2 | { 3 | if(is.null(names(object)) || any(names(object) == "")) 4 | { 5 | return("Every entry must have a valid name") 6 | } 7 | if(length(unique(names(object))) != length(object)) 8 | { 9 | return("Names must be unique") 10 | } 11 | return(.Call("checkHets", object)) 12 | } 13 | .hetData <- setClass("hetData", contains = "list", validity = checkHets) -------------------------------------------------------------------------------- /R/hetData.R: -------------------------------------------------------------------------------- 1 | #' @include mpcross-class.R 2 | #' @include geneticData-class.R 3 | #' @title Get the encoding of marker heterozygotes 4 | #' @description Get the encoding of marker heterozygotes 5 | #' @rdname hetData 6 | #' @details Get the encoding of markers heterozygotes, either for all markers, or a specific marker. 7 | #' @param object The object from which to extract the encoding data 8 | #' @param marker The marker of interest. If this is missing, heterozygote encoding data is returned for all markers. 9 | #' @return Heterozygote encoding data, for either a specific marker or all markers. 10 | #' @export 11 | setGeneric(name = "hetData", def = function(object, marker){standardGeneric("hetData")}) 12 | #' @rdname hetData 13 | setMethod(f = "hetData", signature = c("mpcross", "ANY"), definition = function(object, marker) 14 | { 15 | if(length(object@geneticData) == 1) 16 | { 17 | if(missing(marker)) 18 | { 19 | return(object@geneticData[[1]]@hetData) 20 | } 21 | else 22 | { 23 | return(object@geneticData[[1]]@hetData[[marker]]) 24 | } 25 | } 26 | return(lapply(object@geneticData, function(x) x@hetData[[marker]])) 27 | }) 28 | #' @rdname hetData 29 | setMethod(f = "hetData", signature = c("geneticData", "ANY"), definition = function(object, marker) 30 | { 31 | if(missing(marker)) 32 | { 33 | return(object@hetData) 34 | } 35 | else 36 | { 37 | return(object@hetData[[marker]]) 38 | } 39 | }) 40 | -------------------------------------------------------------------------------- /R/identC.R: -------------------------------------------------------------------------------- 1 | .identC <- function (c1 = NULL, c2 = NULL) 2 | { 3 | .Call("identC", c1, c2, PACKAGE="mpMap2") 4 | } 5 | -------------------------------------------------------------------------------- /R/map-class.R: -------------------------------------------------------------------------------- 1 | checkMap <- function(object) 2 | { 3 | if(length(object) == 0) 4 | { 5 | return("Map object must contain at least one chromosome") 6 | } 7 | if(any(unlist(lapply(object, length)) == 0)) 8 | { 9 | return("All chromosomes of a map must contain at least one marker") 10 | } 11 | allNumeric <- unlist(lapply(object, is.numeric)) 12 | if(!all(allNumeric)) return("A map object must be a list of numeric vectors") 13 | 14 | if(length(unique(names(object))) != length(object)) 15 | { 16 | return("Chromosome names must be unique") 17 | } 18 | 19 | if(length(unique(unlist(lapply(object, names)))) != length(unlist(object))) 20 | { 21 | return("Marker names must be unique") 22 | } 23 | if(any(unlist(lapply(object, function(x) order(x) != 1:length(x))))) 24 | { 25 | return("Marker positions must be in ascending order within every chromosome") 26 | } 27 | return(TRUE) 28 | } 29 | .map4 <- setClass("map4", contains = "list", validity = checkMap) 30 | setOldClass("map", S4Class = "map4") 31 | removeClass("map4") 32 | -------------------------------------------------------------------------------- /R/mapFunctions.R: -------------------------------------------------------------------------------- 1 | #' @title Map functions 2 | #' @name mapFunctions 3 | NULL 4 | #' @describeIn mapFunctions Convert from Haldane distance to recombination fraction 5 | #' @description Functions used to convert between recombination fractions and centiMorgan distances. 6 | #' @param x centiMorgan distance 7 | #' @return Recombination fraction. 8 | #' @export 9 | haldaneToRf <- function(x) 10 | { 11 | return(.5*(1-exp(-2*x/100))) 12 | } 13 | #' @describeIn mapFunctions Convert from Haldane distance to recombination fraction 14 | #' @export 15 | haldane <- haldaneToRf 16 | #' @describeIn mapFunctions Convert from recombination fraction to Haldane distance 17 | #' @param r recombination fraction 18 | #' @return Genetic distance in cM. 19 | #' @export 20 | rfToHaldane <- function(r) 21 | { 22 | return(-50*log(1-2*r)) 23 | } 24 | #' @describeIn mapFunctions Convert from recombination fraction to Kosambi distance 25 | #' @return Genetic distance in cM. 26 | #' @export 27 | rfToKosambi <- function(r) 28 | { 29 | return(50*atanh(2*r)) 30 | } 31 | #' @describeIn mapFunctions Convert from Kosambi distance to recombination fraction 32 | #' @return Recombination fraction. 33 | #' @export 34 | kosambiToRf <- function(x) 35 | { 36 | return(.5*tanh(2*x/100)) 37 | } 38 | #' @describeIn mapFunctions Convert from recombination fraction to Kosambi distance 39 | #' @return Recombination fraction. 40 | #' @export 41 | kosambi <- kosambiToRf 42 | -------------------------------------------------------------------------------- /R/markers.R: -------------------------------------------------------------------------------- 1 | #' @include mpcross-class.R 2 | #' @include rf-class.R 3 | #' @include lg-class.R 4 | #' @include hetData-class.R 5 | #' @title Genotyped markers 6 | #' 7 | #' Return the names of the genotyped markers. 8 | #' 9 | #' If an \code{mpcross} object contains multiple experiments, all experiments are required to have the same markers. So a single vector of marker names is returned, in all cases. 10 | #' @rdname markers 11 | #' @param object The \code{mpcross} object from which to extract the marker names 12 | #' @return The names of the genetic markers. 13 | #' @export 14 | setGeneric(name = "markers", def = function(object){standardGeneric("markers")}) 15 | #' @rdname markers 16 | setMethod(f = "markers", signature = "mpcross", definition = function(object) 17 | { 18 | return(markers(object@geneticData[[1]])) 19 | }) 20 | #' @rdname markers 21 | setMethod(f = "markers", signature = "geneticData", definition = function(object) 22 | { 23 | return(colnames(object@finals)) 24 | }) 25 | #' @rdname markers 26 | setMethod(f = "markers", signature = "rf", definition = function(object) 27 | { 28 | return(object@theta@markers) 29 | }) 30 | #' @rdname markers 31 | setMethod(f = "markers", signature = "lg", definition = function(object) 32 | { 33 | return(names(object@groups)) 34 | }) 35 | #' @rdname markers 36 | setMethod(f = "markers", signature = "hetData", definition = function(object) 37 | { 38 | return(names(object)) 39 | }) 40 | -------------------------------------------------------------------------------- /R/nFounders.R: -------------------------------------------------------------------------------- 1 | #' @include detailedPedigree-class.R 2 | #' @include pedigree-class.R 3 | #' @include mpcross-class.R 4 | #' @include geneticData-class.R 5 | #' @title Number of genotyped markers 6 | #' 7 | #' Return the number of genotyped markers in an object. 8 | #' 9 | #' If an \code{mpcross} object contains multiple experiments, one number is returned per experiment. 10 | #' @rdname nFounders 11 | #' @param object The \code{mpcross} object from which to extract the number of founders 12 | #' @return The number of founding lines in the population, or a list of numbers in the case of multiple experiments contained in a single object. 13 | #' @export 14 | setGeneric(name = "nFounders", def = function(object){standardGeneric("nFounders")}) 15 | #' @rdname nFounders 16 | setMethod(f = "nFounders", signature = "detailedPedigree", definition = function(object) 17 | { 18 | return(length(object@initial)) 19 | }) 20 | #' @rdname nFounders 21 | setMethod(f = "nFounders", signature = "pedigree", definition = function(object) 22 | { 23 | return(sum(object@mother == 0 & object@father == 0)) 24 | }) 25 | #' @rdname nFounders 26 | setMethod(f = "nFounders", signature = "mpcross", definition = function(object) 27 | { 28 | return(unlist(lapply(object@geneticData, nFounders))) 29 | }) 30 | #' @rdname nFounders 31 | setMethod(f = "nFounders", signature = "geneticData", definition = function(object) 32 | { 33 | return(nrow(object@founders)) 34 | }) 35 | -------------------------------------------------------------------------------- /R/nLines.R: -------------------------------------------------------------------------------- 1 | #' @include detailedPedigree-class.R 2 | #' @include mpcross-class.R 3 | #' @include geneticData-class.R 4 | #' @title Number of genotyped lines 5 | #' 6 | #' Return the number of genotyped lines in an object. 7 | #' 8 | #' This includes only the number of final lines genotyped in the population, and does not include the founding lines. If an \code{mpcross} object contains multiple experiments, one number is returned per experiment. 9 | #' @param object The \code{mpcross} object from which to extract the number of genotyped lines. 10 | #' @return The number of genetic lines in the population, or a list of numbers in the case of multiple experiments contained in a single object. 11 | #' @rdname nLines 12 | #' @export 13 | setGeneric(name = "nLines", def = function(object){standardGeneric("nLines")}) 14 | #' @rdname nLines 15 | setMethod(f = "nLines", signature = "mpcross", definition = function(object) 16 | { 17 | return(unlist(lapply(object@geneticData, nLines))) 18 | }) 19 | #' @rdname nLines 20 | setMethod(f = "nLines", signature = "geneticData", definition = function(object) 21 | { 22 | return(nrow(object@finals)) 23 | }) 24 | -------------------------------------------------------------------------------- /R/nMarkers.R: -------------------------------------------------------------------------------- 1 | #' @include mpcross-class.R 2 | #' @include geneticData-class.R 3 | #' @title Number of genotyped markers 4 | #' 5 | #' Return the number of genotyped markers in an object. 6 | #' 7 | #' If an \code{mpcross} object contains multiple experiments, all experiments are required to have the same markers. So only one number is returned, in all cases. 8 | #' @rdname nMarkers 9 | #' @param object The \code{mpcross} object from which to extract the marker names 10 | #' @return The number of markers in an object of class \code{mpcross}. 11 | #' @export 12 | setGeneric(name = "nMarkers", def = function(object){standardGeneric("nMarkers")}) 13 | #' @rdname nMarkers 14 | setMethod(f = "nMarkers", signature = "mpcross", definition = function(object) 15 | { 16 | return(ncol(object@geneticData[[1]]@finals)) 17 | }) 18 | #' @rdname nMarkers 19 | setMethod(f = "nMarkers", signature = "geneticData", definition = function(object) 20 | { 21 | return(ncol(object@finals)) 22 | }) 23 | -------------------------------------------------------------------------------- /R/num_threads.R: -------------------------------------------------------------------------------- 1 | #' @title Get or set number of threads for OpenMP 2 | #' @rdname openmp 3 | #' @export 4 | #' @description Get or set the number of threads for OpenMP 5 | #' @details Some functions in mpMap2 are parallelised. Depending on the number of cores available, and the type of workload, it may be advantageous to turn parallelisation on or off, by setting the number of OpenMP threads appropriately. Setting the number of threads to 1 turns parallelisation off 6 | #' 7 | #' In particular, for small examples on a computer with a large number of threads, parallelisation may result in a huge decrease in performance. 8 | #' 9 | #' This function returns an error if the package was not compiled with OpenMP. 10 | #' @param num New number of threads for OpenMP 11 | #' @return None 12 | omp_set_num_threads <- function(num) 13 | { 14 | .Call("omp_set_num_threads", num, PACKAGE = "mpMap2") 15 | } 16 | #' @export 17 | #' @rdname openmp 18 | #' @return The number of threads for OpenMP 19 | omp_get_num_threads <- function() 20 | { 21 | .Call("omp_get_num_threads", PACKAGE = "mpMap2") 22 | } 23 | -------------------------------------------------------------------------------- /R/pedigreeGraph-class.R: -------------------------------------------------------------------------------- 1 | checkPedigreeGraph <- function(object) 2 | { 3 | errors <- c() 4 | if(class(object@graph) != "igraph") 5 | { 6 | errors <- c(errors, "Slot graph must have class igraph") 7 | } 8 | if(!is.numeric(object@layout) || ncol(object@layout) != 2) 9 | { 10 | errors <- c(errors, "Slot layout must be a numeric matrix with two columns") 11 | } 12 | if(length(errors) > 0) return(errors) 13 | if(length(V(object@graph)) != nrow(object@layout)) 14 | { 15 | errors <- c(errors, "Slot layout had the wrong number of rows") 16 | } 17 | if(length(errors) > 0) return(errors) 18 | return(TRUE) 19 | } 20 | #' @title Graph for a pedigree 21 | #' @description Graph for a pedigree 22 | #' @details This class contains the directed graph corresponding to a pedigree, and data for laying out the graph on a plane. 23 | #' @slot graph An object of class igraph. 24 | #' @slot layout A matrix where each row gives the position of a graph vertex in the plane. 25 | .pedigreeGraph <- setClass("pedigreeGraph", slots = list(graph = "ANY", layout = "matrix"), validity = checkPedigreeGraph) 26 | -------------------------------------------------------------------------------- /R/pedigreeGraph.R: -------------------------------------------------------------------------------- 1 | #' @include pedigreeGraph-class.R 2 | #' @title Plot the graph of a pedigree 3 | #' @description Plot the graph of a pedigree 4 | #' @details Plot the graph of a pedigree, after the graph has been generated by \code{\link{pedigreeToGraph}} 5 | #' @param x pedigree graph to plot 6 | #' @param y unused 7 | #' @param ... Other options to plot.igraph 8 | #' @return None 9 | #' @seealso \code{\link{pedigreeToGraph}} 10 | setMethod(f = "plot", signature = "pedigreeGraph", definition = function(x, y, ...) 11 | { 12 | igraph::plot.igraph(x@graph, layout = x@layout, vertex.frame.color=NA, edge.arrow.mode="-", frame = 0, margin=0, ...) 13 | }) 14 | -------------------------------------------------------------------------------- /R/plot.R: -------------------------------------------------------------------------------- 1 | #' @include mpcross-class.R 2 | #' @include geneticData-class.R 3 | #' @title Plot methods 4 | #' @description There are multiple meaningful ways to plot some mpMap2 objects. Please use \code{\link{plotProbabilities}} or \code{\link{plotMosaic}} instead. 5 | #' @rdname plot 6 | #' @details There are multiple meaningful ways to plot some mpMap2 objects. In these cases the plot function is implemented but returns an error. Please use \code{\link{plotProbabilities}} or \code{\link{plotMosaic}} instead. 7 | #' @param x Unused 8 | #' @param y Unused 9 | #' @param ... Unused 10 | #' @return None 11 | setMethod(f = "plot", signature = "mpcross", definition = function(x, ...) 12 | { 13 | stop("Function plot is not defined for an object of class \"mpcross\". Use functions plotProbabilities or plotMosaic instead") 14 | }) 15 | #' @rdname plot 16 | setMethod(f = "plot", signature = "geneticData", definition = function(x, ...) 17 | { 18 | stop("Function plot is not defined for an object of class \"geneticData\". Use functions plotProbabilities or plotMosaic instead") 19 | }) 20 | #' @rdname plot 21 | setMethod(f = "plot", signature = "probabilities", definition = function(x, ...) 22 | { 23 | stop("Function plot is not defined for an object of class \"probabilities\". Use functions plotProbabilities or plotMosaic instead") 24 | }) 25 | #' @rdname plot 26 | setMethod(f = "plot", signature = "imputed", definition = function(x, ...) 27 | { 28 | stop("Function plot is not defined for an object of class \"imputed\". Use functions plotProbabilities or plotMosaic instead") 29 | }) 30 | 31 | -------------------------------------------------------------------------------- /R/purdyToPedigree.R: -------------------------------------------------------------------------------- 1 | purdyToPedigree <- function(lineNames, purdy, selfing, warnImproperFunnels) 2 | { 3 | if(!is.character(lineNames) || !is.character(purdy)) 4 | { 5 | stop("Inputs lineNames and purdy must be character vectors") 6 | } 7 | if(length(lineNames) != length(purdy)) 8 | { 9 | stop("Inputs lineNames and purdy must have the same lengths") 10 | } 11 | parsed <- .Call("parsePurdy", lineNames, purdy, PACKAGE="mpMap2") 12 | lineNames <- parsed[,1] 13 | mother <- sapply(parsed[,2], function(x) 14 | { 15 | if(x == "") return(0) 16 | return(match(x, lineNames)) 17 | }) 18 | father <- sapply(parsed[,3], function(x) 19 | { 20 | if(x == "") return(0) 21 | return(match(x, lineNames)) 22 | }) 23 | names(father) <- names(mother) <- NULL 24 | pedigree <- pedigree(lineNames = lineNames, mother = mother, father = father, selfing = selfing, warnImproperFunnels = warnImproperFunnels) 25 | return(pedigree) 26 | } 27 | -------------------------------------------------------------------------------- /R/reorderPedigree.R: -------------------------------------------------------------------------------- 1 | reorderPedigree <- function(mother, father, lineNames, warnImproperFunnels, selfing) 2 | { 3 | success <- FALSE 4 | try( 5 | { 6 | result <- .Call("reorderPedigree", mother, father, lineNames, PACKAGE="mpMap2") 7 | success <- TRUE 8 | }, silent=TRUE) 9 | #There will be an error if package was compiled without boost support 10 | if(success) 11 | { 12 | return(new("pedigree", lineNames = result$lineNames, mother = result$mother, father = result$father, selfing = selfing, warnImproperFunnels = warnImproperFunnels)) 13 | } 14 | else 15 | { 16 | return(NULL) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /R/rf-class.R: -------------------------------------------------------------------------------- 1 | #' @include rawSymmetricMatrix.R 2 | setClassUnion("dspMatrixOrNULL", c("dspMatrix", "NULL")) 3 | checkRF <- function(object) 4 | { 5 | errors <- c() 6 | thetaMarkers <- object@theta@markers 7 | if(!is.null(object@lod)) 8 | { 9 | if(is.null(colnames(object@lod))) 10 | { 11 | errors <- c(errors, "Slot @lod must have column names") 12 | } 13 | else if(nrow(object@lod) != length(thetaMarkers)) 14 | { 15 | errors <- c(errors, "Dimensions of @lod were inconsistent with those of @theta") 16 | } 17 | else if(any(thetaMarkers != colnames(object@lod))) 18 | { 19 | errors <- c(errors, "Column names of @lod were inconsistent with those of @theta") 20 | } 21 | } 22 | if(!is.null(object@lkhd)) 23 | { 24 | if(is.null(colnames(object@lkhd))) 25 | { 26 | errors <- c(errors, "Slot @lkhd must have column names") 27 | } 28 | else if(nrow(object@lkhd) != length(thetaMarkers)) 29 | { 30 | errors <- c(errors, "Dimensions of @lkhd were inconsistent with those of @theta") 31 | } 32 | else if(any(thetaMarkers != colnames(object@lkhd))) 33 | { 34 | errors <- c(errors, "Column names of @lkhd were inconsistent with those of @theta") 35 | } 36 | 37 | } 38 | if(length(errors) > 0) return(errors) 39 | return(TRUE) 40 | } 41 | .rf <- setClass("rf", slots = list(theta = "rawSymmetricMatrix", lod = "dspMatrixOrNULL", lkhd = "dspMatrixOrNULL", gbLimit = "numeric"), validity = checkRF) 42 | -------------------------------------------------------------------------------- /R/rilPedigree.R: -------------------------------------------------------------------------------- 1 | #' @title Generate a two-parent RIL pedigree which starts from inbred founders 2 | #' 3 | #' @description 4 | #' Generate a two-parent RIL pedigree which starts from inbred founders 5 | #' 6 | #' @param populationSize The size of the generated population 7 | #' @param selfingGenerations Number of generations of selfing. Specifying one generation leads to an F2 design. 8 | #' @return An object of class \code{detailedPedigree} representing the experimental design, suitable for simulation using simulateMPCross. 9 | #' @export 10 | rilPedigree <- function(populationSize, selfingGenerations) 11 | { 12 | return(twoParentPedigree(initialPopulationSize = populationSize, selfingGenerations = selfingGenerations, intercrossingGenerations = 0, nSeeds = 1)) 13 | } 14 | -------------------------------------------------------------------------------- /R/show.R: -------------------------------------------------------------------------------- 1 | #' @include mpcross-class.R 2 | #' @include print.R 3 | setMethod(f = "show", signature = "mpcrossRF", definition = function(object) print(object)) 4 | setMethod(f = "show", signature = "mpcross", definition = function(object) print(object)) 5 | setMethod(f = "show", signature = "mpcrossLG", definition = function(object) print(object)) 6 | -------------------------------------------------------------------------------- /R/singleLocusProbabilities.R: -------------------------------------------------------------------------------- 1 | singleLocusProbabilities <- function(nFounders, nFunnels, intercrossingGenerations, selfingGenerations, infiniteSelfing) 2 | { 3 | if(!(nFounders %in% c(2, 4, 8, 16))) stop("Input nFounders must be one of 2, 4, 8, or 16") 4 | if(infiniteSelfing) .Call("singleLocusProbabilitiesInfinite", nFounders, nFunnels, intercrossingGenerations, selfingGenerations, PACKAGE="mpMap2") 5 | else .Call("singleLocusProbabilitiesFinite", nFounders, nFunnels, intercrossingGenerations, selfingGenerations, PACKAGE="mpMap2") 6 | } 7 | -------------------------------------------------------------------------------- /data/callFromMapExampleLocalisationStatistics.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rohan-shah/mpMap2/c43bb51b348bdf6937e1b11298b9cdfe7a85e001/data/callFromMapExampleLocalisationStatistics.RData -------------------------------------------------------------------------------- /data/eightParentSubsetMap.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rohan-shah/mpMap2/c43bb51b348bdf6937e1b11298b9cdfe7a85e001/data/eightParentSubsetMap.RData -------------------------------------------------------------------------------- /data/simulatedFourParentData.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rohan-shah/mpMap2/c43bb51b348bdf6937e1b11298b9cdfe7a85e001/data/simulatedFourParentData.RData -------------------------------------------------------------------------------- /data/wsnp_Ku_rep_c103074_89904851.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rohan-shah/mpMap2/c43bb51b348bdf6937e1b11298b9cdfe7a85e001/data/wsnp_Ku_rep_c103074_89904851.RData -------------------------------------------------------------------------------- /inst/generateDatasets/generateExample1.R: -------------------------------------------------------------------------------- 1 | library(mpMap2) 2 | library(purrr) 3 | if(!exists("previousMap")) 4 | { 5 | previousMapFile <- "/OSM/CBR/AG_MAGICLM/source/data/8way_mapV2/investigate2B2DInfinite.RData" 6 | load(previousMapFile) 7 | previousMap <- combined 8 | rm(combined) 9 | } 10 | 11 | #Extract start of chromosomes 1A, 1B and 1D. 12 | toOutput <- subset(previousMap, chromosomes = c("1A", "1B", "1D")) 13 | subMap <- lapply(toOutput@map, function(x) keep(x, function(y) y < 35)) 14 | toOutput <- subset(toOutput, markers = unlist(lapply(subMap, names))) 15 | 16 | class(subMap) <- "map" 17 | toOutput <- mpcrossMapped(toOutput, map = subMap) 18 | 19 | originalImputationMap <- previousMap@geneticData[[1]]@imputed@map 20 | subImputationMap <- lapply(originalImputationMap, function(x) keep(x, function(y) y < 35)) 21 | toOutput@geneticData[[1]]@imputed <- subset(previousMap@geneticData[[1]]@imputed, positions = unlist(lapply(subImputationMap, names))) 22 | 23 | eightParentSubsetMap <- redact(toOutput) 24 | save(eightParentSubsetMap, file = "../../data/eightParentSubsetMap.RData") 25 | -------------------------------------------------------------------------------- /inst/mathematica/.gitignore: -------------------------------------------------------------------------------- 1 | /*.pdf 2 | -------------------------------------------------------------------------------- /man/assignFounderPattern.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/assignFounderPattern.R 3 | \name{assignFounderPattern} 4 | \alias{assignFounderPattern} 5 | \title{Set founder genotypes} 6 | \usage{ 7 | assignFounderPattern(founderMatrix) 8 | } 9 | \arguments{ 10 | \item{founderMatrix}{The new matrix of founder genotypes} 11 | } 12 | \value{ 13 | An object of internal class \code{assignFounderPattern}, suitable for application to an object of class \code{mpcross} using the addition operation. 14 | } 15 | \description{ 16 | Set founder genotypes 17 | } 18 | \details{ 19 | Set the founder genotypes to a specified matrix, for an object with fully informative markers. This can allow the same set of founder genotypes to be used for multiple simulation runs. 20 | } 21 | -------------------------------------------------------------------------------- /man/backcrossPedigree.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/backcrossPedigree.R 3 | \name{backcrossPedigree} 4 | \alias{backcrossPedigree} 5 | \title{Generate a backcross pedigree which starts from inbred founders} 6 | \usage{ 7 | backcrossPedigree(populationSize) 8 | } 9 | \arguments{ 10 | \item{populationSize}{The size of the generated population.} 11 | } 12 | \value{ 13 | An object of class \code{detailedPedigree} representing the experimental design, suitable for simulation using simulateMPCross. 14 | } 15 | \description{ 16 | Generate a backcross pedigree which starts from inbred founders 17 | } 18 | \details{ 19 | Generate a backcross pedigree which starts from inbred founders 20 | } 21 | \examples{ 22 | pedigree <- backcrossPedigree(1000) 23 | #This pedigree is automatically marked as involving finite generations of selfing. 24 | selfing(pedigree) 25 | } 26 | -------------------------------------------------------------------------------- /man/biparentalDominant.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/biparentalDominant.R 3 | \name{biparentalDominant} 4 | \alias{biparentalDominant} 5 | \title{Make markers in a biparental cross dominant} 6 | \usage{ 7 | biparentalDominant() 8 | } 9 | \value{ 10 | An object of internal type \code{biparentalDominant}, which can be combined with an object of class \code{mpcross} using the addition operator. 11 | } 12 | \description{ 13 | Change the markers in a biparental cross from fully informative to dominant. The dominant founder is chosen randomly for every marker. The transformation is applied to an object using the addition operator, see the example below for details. 14 | } 15 | \examples{ 16 | #Simulate an F2 design 17 | f2Pedigree <- f2Pedigree(1000) 18 | map <- qtl::sim.map(len = 100, n.mar = 11, include.x=FALSE) 19 | cross <- simulateMPCross(map = map, pedigree = f2Pedigree, mapFunction = haldane, seed = 1) 20 | founders(cross) 21 | finals(cross)[1:10,] 22 | #The heterozygotes are initially coded as 3 23 | hetData(cross)[[1]] 24 | #Make all markers dominant 25 | dominantCross <- cross + biparentalDominant() 26 | founders(dominantCross) 27 | finals(dominantCross)[1:10,] 28 | #The heterozygotes are now coded the same as one of the homozygotes 29 | hetData(dominantCross)[1:4] 30 | } 31 | -------------------------------------------------------------------------------- /man/changeMarkerPosition.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/changeMarkerPosition.R 3 | \name{changeMarkerPosition} 4 | \alias{changeMarkerPosition} 5 | \title{Change the position of a single marker} 6 | \usage{ 7 | changeMarkerPosition(mpcrossMapped, marker, newChromosome, newPosition) 8 | } 9 | \arguments{ 10 | \item{mpcrossMapped}{The object of class \code{mpcrossMapped}, containing a marker to be modified} 11 | 12 | \item{marker}{The name of the marker to change} 13 | 14 | \item{newChromosome}{The new chromosome for the specified marker} 15 | 16 | \item{newPosition}{The new position for the specified marker in cM, on the new chromosome} 17 | } 18 | \value{ 19 | A copy of the input object, with the specified marker shifted to the new position and chromosome. 20 | } 21 | \description{ 22 | Change the position of a single marker 23 | } 24 | \details{ 25 | For an object of class \code{mpcrossMapped}, change the position of a single marker 26 | } 27 | -------------------------------------------------------------------------------- /man/computeAllEpistaticChiSquared.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/computeAllEpistaticChiSquared.R 3 | \name{computeAllEpistaticChiSquared} 4 | \alias{computeAllEpistaticChiSquared} 5 | \title{Compute chi-squared test statistics for independence} 6 | \usage{ 7 | computeAllEpistaticChiSquared(mpcrossMapped, verbose = TRUE) 8 | } 9 | \arguments{ 10 | \item{mpcrossMapped}{An object of class \code{mpcrossMapped} with IBD probability data.} 11 | 12 | \item{verbose}{If this is \code{TRUE} a progress bar is generated} 13 | } 14 | \value{ 15 | A square matrix with rows and columns corresponding to genetic locations, and values corresponding to test statistics. 16 | } 17 | \description{ 18 | Compute chi-squared test statistics for independence 19 | } 20 | \details{ 21 | This function computes what are (approximately) chi-squared test statistics for independence of the genotypes at different points on the genome. This computation is done using the IBD probability data. Significant non-independence between IBD probabilities at distant points on the same chromosome, or points on different chromosomes, can indicate non-standard genetic inheritance or selective pressure. 22 | } 23 | -------------------------------------------------------------------------------- /man/eightParentSubsetMap.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/roxygen.R 3 | \docType{data} 4 | \name{eightParentSubsetMap} 5 | \alias{eightParentSubsetMap} 6 | \title{Genetic map and genetic data from an 8-parent MAGIC population.} 7 | \description{ 8 | Genetic map and genetic data from an 8-parent MAGIC population. 9 | } 10 | \author{ 11 | Alex Whan, Matthew Morell, Rohan Shah, Colin Cavanagh 12 | This dataset contains the genetic map, genetic data, and imputed IBD genotypes for parts of chromosomes 1A, 1B and 1D, from an 8-way MAGIC population of 4229 lines. 13 | } 14 | -------------------------------------------------------------------------------- /man/estimateMapFromImputation.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/estimateMapFromImputation.R 3 | \name{estimateMapFromImputation} 4 | \alias{estimateMapFromImputation} 5 | \title{Re-estimate large gaps in a genetic map from IBD genotype imputations} 6 | \usage{ 7 | estimateMapFromImputation( 8 | mpcrossMapped, 9 | gapSize = 5, 10 | recombinationFractions = c(0:60/600, 11:49/100) 11 | ) 12 | } 13 | \arguments{ 14 | \item{mpcrossMapped}{An object of class \code{mpcrossMapped}} 15 | 16 | \item{gapSize}{The size of the gap to reestimate.} 17 | 18 | \item{recombinationFractions}{The recombination fractions to use for numerical maximum likelihood estimation} 19 | } 20 | \value{ 21 | An object of class \code{mpcrossMapped} with a re-estimated map. 22 | } 23 | \description{ 24 | Re-estimate large gaps in a genetic map from IBD genotype imputations 25 | } 26 | \details{ 27 | For larger gaps in a genetic map, the pairwise recombination fractions are not (by themselves) useful. An alternative is to estimate the IBD genotypes, and use the imputed IBD genotypes to re-estimate larger gaps using numerical maximum likelihood. Although the IBD genotypes are based on an existing genetic map, they may not be strongly affected by a large gap that has been poorly estimated, as the imputed IBD genotypes represent a consensus across all nearby markers, and also allow for genotyping errors. As a result, the re-estimated map may be different from the original map, and potentially more accurate. 28 | } 29 | -------------------------------------------------------------------------------- /man/existingLocalisationStatistics.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/roxygen.R 3 | \docType{data} 4 | \name{existingLocalisationStatistics} 5 | \alias{existingLocalisationStatistics} 6 | \title{Localisation statistics for example of callFromMap} 7 | \description{ 8 | This dataset contains the localisation statistics for the example for running \code{callFromMap}. This makes the example fast enough to pass the CRAN check. 9 | } 10 | -------------------------------------------------------------------------------- /man/expand.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/expand.R 3 | \name{expand} 4 | \alias{expand} 5 | \title{Expand markers contained within object} 6 | \usage{ 7 | expand(mpcross, newMarkers) 8 | } 9 | \arguments{ 10 | \item{mpcross}{The input \code{mpcross} object} 11 | 12 | \item{newMarkers}{The names of the new markers to add} 13 | } 14 | \value{ 15 | An object of class \code{mpcross} with a larger set of markers. 16 | } 17 | \description{ 18 | Expand set of markers within object, adding extra markers with missing observations as necessary. 19 | } 20 | \details{ 21 | This function expands the set of markres within an \code{mpcross} object. The new set of marker names must contain all the existing marker names, with any desired extra marker names. Any added markers will have all observations marked as missing. Any existing non-genetic information (genetic map, assignment of linkage groups, IBD genotypes, IBD probabilitieS) will be removed. 22 | } 23 | -------------------------------------------------------------------------------- /man/exportMapToPretzl.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/exportMapToPretzl.R 3 | \name{exportMapToPretzl} 4 | \alias{exportMapToPretzl} 5 | \title{Export genetic map to Pretzl} 6 | \usage{ 7 | exportMapToPretzl(inputObject, name, separateChromosomes = FALSE) 8 | } 9 | \arguments{ 10 | \item{inputObject}{The object of class \code{mpcrossMapped} containing the genetic map} 11 | 12 | \item{name}{If a single JSON object is being exported, the name of the exported map.} 13 | 14 | \item{separateChromosomes}{If \code{TRUE}, separate exports will be generated for each chromosome. The name associated with each chromosome map will contain the chromosome name as a suffix.} 15 | } 16 | \value{ 17 | A list containing JSON, suitable for import into Pretzl. 18 | } 19 | \description{ 20 | Export genetic map to Pretzl 21 | } 22 | \details{ 23 | Convert the genetic map from an object of class \code{mpcrossMapped} to the JSON format used by Pretzl. Pretzl is a web app for visualising and comparing genetic maps. 24 | } 25 | -------------------------------------------------------------------------------- /man/extraImputationPoints.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/extraImputationPoints.R 3 | \name{extraImputationPoints} 4 | \alias{extraImputationPoints} 5 | \title{Get out non-marker positions used for IBD genotype imputation} 6 | \usage{ 7 | extraImputationPoints(mpcrossMapped) 8 | } 9 | \arguments{ 10 | \item{mpcrossMapped}{The object from which to get the non-marker positions} 11 | } 12 | \value{ 13 | A vector of genetic position names. 14 | } 15 | \description{ 16 | Get out non-marker positions used for IBD genotype imputation 17 | } 18 | \details{ 19 | Extract non-marker positions used for IBD genotype imputation 20 | } 21 | -------------------------------------------------------------------------------- /man/f2Pedigree.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/f2Pedigree.R 3 | \name{f2Pedigree} 4 | \alias{f2Pedigree} 5 | \title{Generate an F2 pedigree which starts from inbred founders} 6 | \usage{ 7 | f2Pedigree(populationSize) 8 | } 9 | \arguments{ 10 | \item{populationSize}{The size of the generated population.} 11 | } 12 | \value{ 13 | An object of class \code{detailedPedigree} representing the experimental design, suitable for simulation using simulateMPCross. 14 | } 15 | \description{ 16 | Generate an F2 pedigree which starts from inbred founders 17 | } 18 | \examples{ 19 | pedigree <- f2Pedigree(1000) 20 | #This pedigree is automatically marked as involving finite generations of selfing. 21 | selfing(pedigree) 22 | } 23 | -------------------------------------------------------------------------------- /man/finalNames.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/finals.R 3 | \name{finalNames} 4 | \alias{finalNames} 5 | \alias{finalNames,mpcross-method} 6 | \alias{finalNames,geneticData-method} 7 | \title{Names of genetic lines 8 | 9 | Return the names of the genetic lines 10 | 11 | If the \code{mpcross} object contains a single experiment a vector of names of genetic lines is returned. The names of the founding lines for the population are excluded. If an \code{mpcross} object contains multiple experiments a list of vectors of names is returned.} 12 | \usage{ 13 | finalNames(object) 14 | 15 | \S4method{finalNames}{mpcross}(object) 16 | 17 | \S4method{finalNames}{geneticData}(object) 18 | } 19 | \arguments{ 20 | \item{object}{The \code{mpcross} object from which to extract the names of the genetic lines} 21 | } 22 | \value{ 23 | The names of the genetic lines in the final population. 24 | } 25 | \description{ 26 | Names of genetic lines 27 | 28 | Return the names of the genetic lines 29 | 30 | If the \code{mpcross} object contains a single experiment a vector of names of genetic lines is returned. The names of the founding lines for the population are excluded. If an \code{mpcross} object contains multiple experiments a list of vectors of names is returned. 31 | } 32 | -------------------------------------------------------------------------------- /man/finals.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/finals.R 3 | \name{finals} 4 | \alias{finals} 5 | \alias{finals,mpcross-method} 6 | \alias{finals,geneticData-method} 7 | \title{Genetic data for final lines 8 | 9 | Return the genetic data matrix for the final lines 10 | 11 | If the \code{mpcross} object contains a single experiment a matrix is returned, with rows corresponding to genotyped lines and columns corresponding to markers. The founding lines of the population are excluded from this matrix. If an \code{mpcross} object contains multiple experiments a list of such matrices is returned, one for each experiment.} 12 | \usage{ 13 | finals(object) 14 | 15 | \S4method{finals}{mpcross}(object) 16 | 17 | \S4method{finals}{geneticData}(object) 18 | } 19 | \arguments{ 20 | \item{object}{The \code{mpcross} object from which to extract the genetic data matrix} 21 | } 22 | \value{ 23 | An integer matrix with rows corresponding to genotyped lines and columns corresponding to markers. 24 | } 25 | \description{ 26 | Genetic data for final lines 27 | 28 | Return the genetic data matrix for the final lines 29 | 30 | If the \code{mpcross} object contains a single experiment a matrix is returned, with rows corresponding to genotyped lines and columns corresponding to markers. The founding lines of the population are excluded from this matrix. If an \code{mpcross} object contains multiple experiments a list of such matrices is returned, one for each experiment. 31 | } 32 | -------------------------------------------------------------------------------- /man/fixedNumberOfFounderAlleles.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/fixedNumberOfFounderAlleles.R 3 | \name{fixedNumberOfFounderAlleles} 4 | \alias{fixedNumberOfFounderAlleles} 5 | \title{Convert fully informative experiment to one with a fixed number of alleles per marker} 6 | \usage{ 7 | fixedNumberOfFounderAlleles(alleles) 8 | } 9 | \arguments{ 10 | \item{alleles}{Number of alleles for each marker} 11 | } 12 | \value{ 13 | An object of internal class \code{fixedNumberOfFounderAlleles} suitable for application to an object of class \code{mpcross} using the addition operation. 14 | } 15 | \description{ 16 | Convert a fully informative experiment to one with a fixed number of alleles per marker 17 | } 18 | \details{ 19 | By default, simulated data is fully informative, so every founder carries its own allele, and all heterozygotes are distinguishable. 20 | 21 | This function takes in a fully informative experiment, and changes every marker so that it has a fixed number of founder alleles. Heterozygotes are also changed, so every combination of different alleles is still distinguishable. 22 | } 23 | \examples{ 24 | data(simulatedFourParentData) 25 | founders(simulatedFourParentData)[, 1:10] 26 | altered <- simulatedFourParentData + fixedNumberOfFounderAlleles(3) 27 | founders(altered)[, 1:10] 28 | } 29 | -------------------------------------------------------------------------------- /man/flatImputationMapNames.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/imputationGenerics.R 3 | \name{flatImputationMapNames} 4 | \alias{flatImputationMapNames} 5 | \alias{flatImputationMapNames,imputed-method} 6 | \alias{flatImputationMapNames,geneticData-method} 7 | \alias{flatImputationMapNames,mpcrossMapped-method} 8 | \title{Get names of positions for IBD genotype imputation} 9 | \usage{ 10 | flatImputationMapNames(object, ...) 11 | 12 | \S4method{flatImputationMapNames}{imputed}(object, ...) 13 | 14 | \S4method{flatImputationMapNames}{geneticData}(object, ...) 15 | 16 | \S4method{flatImputationMapNames}{mpcrossMapped}(object, ...) 17 | } 18 | \arguments{ 19 | \item{object}{The object from which to get the names of positions} 20 | 21 | \item{...}{Extra parameters, currently only \code{"experiment"} is supported.} 22 | } 23 | \value{ 24 | The names of all positions at which IBD genotype imputation has already been performed. 25 | } 26 | \description{ 27 | Get the names of all positions at which IBD genotype imputation has already been performed 28 | } 29 | \details{ 30 | Get the names of all positions at which IBD genotype imputation has already been performed 31 | } 32 | -------------------------------------------------------------------------------- /man/founderNames.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/founders.R 3 | \name{founderNames} 4 | \alias{founderNames} 5 | \alias{founderNames,mpcross-method} 6 | \alias{founderNames,geneticData-method} 7 | \title{Names of founding genetic lines 8 | 9 | Return the names of the founding genetic lines 10 | 11 | If the \code{mpcross} object contains a single experiment a vector of names of genetic lines is returned. If an \code{mpcross} object contains multiple experiments a list of vectors of names is returned.} 12 | \usage{ 13 | founderNames(object) 14 | 15 | \S4method{founderNames}{mpcross}(object) 16 | 17 | \S4method{founderNames}{geneticData}(object) 18 | } 19 | \arguments{ 20 | \item{object}{The \code{mpcross} object from which to extract the names of the founding genetic lines} 21 | } 22 | \value{ 23 | A vector of names of genetic lines, or a list of such vectors, in the case of multiple experiments. 24 | } 25 | \description{ 26 | Names of founding genetic lines 27 | 28 | Return the names of the founding genetic lines 29 | 30 | If the \code{mpcross} object contains a single experiment a vector of names of genetic lines is returned. If an \code{mpcross} object contains multiple experiments a list of vectors of names is returned. 31 | } 32 | -------------------------------------------------------------------------------- /man/founders.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/founders.R 3 | \name{founders} 4 | \alias{founders} 5 | \alias{founders,mpcross-method} 6 | \alias{founders,geneticData-method} 7 | \title{Genetic data for founding lines 8 | 9 | Return the genetic data matrix for the founding lines 10 | 11 | If the \code{mpcross} object contains a single experiment a matrix is returned, with rows corresponding to founding lines and columns corresponding to markers. If an \code{mpcross} object contains multiple experiments a list of such matrices is returned, one for each experiment.} 12 | \usage{ 13 | founders(object) 14 | 15 | \S4method{founders}{mpcross}(object) 16 | 17 | \S4method{founders}{geneticData}(object) 18 | } 19 | \arguments{ 20 | \item{object}{The \code{mpcross} object from which to extract the genetic data matrix of the founding lines} 21 | } 22 | \value{ 23 | An integer matrix, with rows corresponding to founding lines and columns corresponding to markers, or a list of such matrices in the case of multiple experiments. 24 | } 25 | \description{ 26 | Genetic data for founding lines 27 | 28 | Return the genetic data matrix for the founding lines 29 | 30 | If the \code{mpcross} object contains a single experiment a matrix is returned, with rows corresponding to founding lines and columns corresponding to markers. If an \code{mpcross} object contains multiple experiments a list of such matrices is returned, one for each experiment. 31 | } 32 | -------------------------------------------------------------------------------- /man/fourParentPedigreeRandomFunnels.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/fourParentPedigreeRandomFunnels.R 3 | \name{fourParentPedigreeRandomFunnels} 4 | \alias{fourParentPedigreeRandomFunnels} 5 | \title{Generate a four-parent pedigree} 6 | \usage{ 7 | fourParentPedigreeRandomFunnels( 8 | initialPopulationSize, 9 | selfingGenerations, 10 | nSeeds = 1L, 11 | intercrossingGenerations 12 | ) 13 | } 14 | \arguments{ 15 | \item{initialPopulationSize}{The number of F1 lines generated} 16 | 17 | \item{selfingGenerations}{The number of selfing generations at the end of the pedigree} 18 | 19 | \item{nSeeds}{The number of progeny taken from each intercrossing line, or from each F1 if no intercrossing is specified. These lines are then selfed according to selfingGenerations} 20 | 21 | \item{intercrossingGenerations}{The number of generations of random mating performed from the F1 generation. Population size is maintained at that specified by initialPopulationSize} 22 | } 23 | \value{ 24 | An object of class \code{detailedPedigree} representing the experimental design, suitable for simulation using simulateMPCross. 25 | } 26 | \description{ 27 | Generate a four-parent pedigree starting from inbred founders, using a random funnel 28 | } 29 | \seealso{ 30 | \code{\link{fourParentPedigreeSingleFunnel}}, \code{\link{twoParentPedigree}} 31 | } 32 | -------------------------------------------------------------------------------- /man/fourParentPedigreeSingleFunnel.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/fourParentPedigreeSingleFunnel.R 3 | \name{fourParentPedigreeSingleFunnel} 4 | \alias{fourParentPedigreeSingleFunnel} 5 | \title{Generate a four-parent pedigree} 6 | \usage{ 7 | fourParentPedigreeSingleFunnel( 8 | initialPopulationSize, 9 | selfingGenerations, 10 | nSeeds = 1L, 11 | intercrossingGenerations 12 | ) 13 | } 14 | \arguments{ 15 | \item{initialPopulationSize}{The number of F1 lines generated} 16 | 17 | \item{selfingGenerations}{The number of selfing generations at the end of the pedigree} 18 | 19 | \item{nSeeds}{The number of progeny taken from each intercrossing line, or from each F1 if no intercrossing is specified. These lines are then selfed according to selfingGenerations} 20 | 21 | \item{intercrossingGenerations}{The number of generations of intercrossing, after each F2 line is generated.} 22 | } 23 | \value{ 24 | An object of class \code{detailedPedigree} representing the experimental design, suitable for simulation using simulateMPCross. 25 | } 26 | \description{ 27 | Generate a four-parent pedigree starting from inbred founders, using a single funnel 28 | } 29 | \details{ 30 | Note that unlike \code{\link{fourParentPedigreeRandomFunnels}}, there is no intercrossing allowed in the single funnel case because the relevant haplotype probabilities assume randomly chosen funnels 31 | } 32 | \seealso{ 33 | \code{\link{fourParentPedigreeRandomFunnels}}, \code{\link{twoParentPedigree}} 34 | } 35 | -------------------------------------------------------------------------------- /man/fromMpMap.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/mpcross.R 3 | \name{fromMpMap} 4 | \alias{fromMpMap} 5 | \title{Convert from mpMap format to mpMap2 format} 6 | \usage{ 7 | fromMpMap(mpcross, selfing = "infinite", fixCodingErrors = FALSE) 8 | } 9 | \arguments{ 10 | \item{mpcross}{Object to convert} 11 | 12 | \item{selfing}{Number of generations of selfing to put in the pedigree, for the converted object. Must be \code{"finite"} or \code{"infinite"}.} 13 | 14 | \item{fixCodingErrors}{Should we attempt to fix coding errors, by replacing invalid values by NA? Defaults to FALSE.} 15 | } 16 | \value{ 17 | An object of class \code{mpcross} or \code{mpcrossMapped}, depending on the data contained in the input object. 18 | } 19 | \description{ 20 | Convert an object from mpMap format into mpMap2 format 21 | } 22 | \details{ 23 | Convert an object from mpMap format (the predecessor to mpMap2) into mpMap2 format. It is unlikely that this function will ever need to be used. 24 | } 25 | -------------------------------------------------------------------------------- /man/generateGridPositions.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/generateGridPositions.R 3 | \name{generateGridPositions} 4 | \alias{generateGridPositions} 5 | \title{Specify an equally spaced grid of genetic positions} 6 | \usage{ 7 | generateGridPositions(spacing) 8 | } 9 | \arguments{ 10 | \item{spacing}{The spacing of the genetic positions, in cM.} 11 | } 12 | \value{ 13 | A function which can be applied to an object of class \code{mpcrossMapped} by \code{imputeFounders} or \code{computeGenotypeProbabilities}. 14 | } 15 | \description{ 16 | Specify an equally spaced grid of genetic positions 17 | } 18 | \details{ 19 | Some functions, such as \code{imputeFounders} and \code{computeGenotypeProbabilities}, take in a set of genetic positions as one of the inputs. This function is an easy way to specify an equally spaced grid of positions. 20 | 21 | Note that the return value is itself a function, which is applied internally by \code{imputeFounders} or \code{computeGenotypeProbabilities} to an object of class \code{mpcrossMapped}. 22 | } 23 | \examples{ 24 | data(simulatedFourParentData) 25 | #Create object that includes the correct map 26 | mapped <- new("mpcrossMapped", simulatedFourParentData, map = simulatedFourParentMap) 27 | #Estimate IBD genotypes at all the markers, and marker midpoints 28 | imputed <- imputeFounders(mapped, errorProb = 0.02, 29 | extraPositions = generateGridPositions(1)) 30 | } 31 | -------------------------------------------------------------------------------- /man/generateIntervalMidPoints.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/generateIntervalMidPoints.R 3 | \name{generateIntervalMidPoints} 4 | \alias{generateIntervalMidPoints} 5 | \title{Specify interval midpoints} 6 | \usage{ 7 | generateIntervalMidPoints(object) 8 | } 9 | \arguments{ 10 | \item{object}{The object of class \code{mpcrossMapped} from which to take the interval midpoints.} 11 | } 12 | \value{ 13 | A function which can be applied to an object of class \code{mpcrossMapped} by \code{imputeFounders} or \code{computeGenotypeProbabilities}. 14 | } 15 | \description{ 16 | Specify interval midpoints 17 | } 18 | \details{ 19 | Some functions, such as \code{imputeFounders} and \code{computeGenotypeProbabilities}, take in a set of genetic positions as one of the inputs. This function is an easy way to specify the midpoint of every marker interval. 20 | 21 | Note that you don't have to explicitly evaluate this function, it can be passed in directly (see examples). 22 | } 23 | \examples{ 24 | data(simulatedFourParentData) 25 | #Create object that includes the correct map 26 | mapped <- new("mpcrossMapped", simulatedFourParentData, map = simulatedFourParentMap) 27 | #Estimate IBD genotypes at all the markers, and marker midpoints 28 | imputed <- imputeFounders(mapped, errorProb = 0.02, 29 | extraPositions = generateIntervalMidPoints(mapped)) 30 | #Alternatively we can explicitly evaluate the function. This is identical to above. 31 | imputed <- imputeFounders(mapped, errorProb = 0.02, 32 | extraPositions = generateIntervalMidPoints) 33 | } 34 | -------------------------------------------------------------------------------- /man/getChromosomes.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/getChromosomes.R 3 | \name{getChromosomes} 4 | \alias{getChromosomes} 5 | \title{Get chromosome assignment per marker} 6 | \usage{ 7 | getChromosomes(mpcrossMapped, markers) 8 | } 9 | \arguments{ 10 | \item{mpcrossMapped}{The object containing the map of interest} 11 | 12 | \item{markers}{The markers for which we want the chromosomes} 13 | } 14 | \value{ 15 | A character vector, with names corresponding to markers, and values corresponding to the chromosome on which the named marker is located. 16 | } 17 | \description{ 18 | Get chromosome assignment per marker from an \code{mpcross} object. 19 | } 20 | \details{ 21 | Extract a character vector, with names corresponding to markers, and values corresponding to the chromosome on which the named marker is located. 22 | } 23 | \examples{ 24 | map <- qtl::sim.map() 25 | pedigree <- f2Pedigree(1000) 26 | cross <- simulateMPCross(map = map, pedigree = pedigree, mapFunction = haldane, seed = 1) 27 | mappedCross <- mpcrossMapped(cross = cross, map = map) 28 | chromosomeAssignment <- getChromosomes(mappedCross, markers(mappedCross)) 29 | chromosomeAssignment 30 | } 31 | -------------------------------------------------------------------------------- /man/getIntercrossingAndSelfingGenerations.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/getIntercrossingAndSelfingGenerations.R 3 | \name{getIntercrossingAndSelfingGenerations} 4 | \alias{getIntercrossingAndSelfingGenerations} 5 | \title{Identify number of generations of intercrossing and selfing, per genetic line} 6 | \usage{ 7 | getIntercrossingAndSelfingGenerations(cross) 8 | } 9 | \arguments{ 10 | \item{cross}{The \code{mpcross} object containing the pedigree to be analysed.} 11 | } 12 | \value{ 13 | An integer matrix with two columns, giving the number of generations of selfing and intercrossing, for each genetic line. Or in the case of multiple experiments contained within a single object, a list of such matrices. 14 | } 15 | \description{ 16 | Identify number of generations of intercrossing and selfing, per genetic line 17 | } 18 | \details{ 19 | Many structured populations consist of a number of generations of mixing, followed by a number of generations of intercrossing, followed by inbreeding. This function identifies the number of generations of selfing and intercrossing, for each genetic line, in the case of 4-way, 8-way or 16-way multi-parent design. 20 | } 21 | -------------------------------------------------------------------------------- /man/getPositions.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/getPositions.R 3 | \name{getPositions} 4 | \alias{getPositions} 5 | \title{Get positions of genetic markers} 6 | \usage{ 7 | getPositions(mpcrossMapped, markers) 8 | } 9 | \arguments{ 10 | \item{mpcrossMapped}{The \code{mpcross} object containing the map of interest} 11 | 12 | \item{markers}{The markers for which to get the positions} 13 | } 14 | \value{ 15 | A named vector of numbers, with names corresponding to the selected genetic markers, and values corresponding to genetic positions. 16 | } 17 | \description{ 18 | Get positions of genetic markers, on their respective chromosomes 19 | } 20 | \details{ 21 | Get positions of genetic markers in cM, on their respective chromosomes 22 | } 23 | \examples{ 24 | map <- qtl::sim.map() 25 | pedigree <- f2Pedigree(1000) 26 | cross <- simulateMPCross(map = map, pedigree = pedigree, mapFunction = haldane, seed = 1) 27 | mappedCross <- mpcrossMapped(cross = cross, map = map) 28 | getPositions(mappedCross, c("D13M3", "DXM1", "DXM3")) 29 | } 30 | -------------------------------------------------------------------------------- /man/hetData.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/hetData.R 3 | \name{hetData} 4 | \alias{hetData} 5 | \alias{hetData,mpcross-method} 6 | \alias{hetData,geneticData-method} 7 | \title{Get the encoding of marker heterozygotes} 8 | \usage{ 9 | hetData(object, marker) 10 | 11 | \S4method{hetData}{mpcross}(object, marker) 12 | 13 | \S4method{hetData}{geneticData}(object, marker) 14 | } 15 | \arguments{ 16 | \item{object}{The object from which to extract the encoding data} 17 | 18 | \item{marker}{The marker of interest. If this is missing, heterozygote encoding data is returned for all markers.} 19 | } 20 | \value{ 21 | Heterozygote encoding data, for either a specific marker or all markers. 22 | } 23 | \description{ 24 | Get the encoding of marker heterozygotes 25 | } 26 | \details{ 27 | Get the encoding of markers heterozygotes, either for all markers, or a specific marker. 28 | } 29 | -------------------------------------------------------------------------------- /man/hetsForSNPMarkers.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/mpcross-class.R 3 | \name{hetsForSNPMarkers} 4 | \alias{hetsForSNPMarkers} 5 | \title{Create heterozygote encodings for SNP markers} 6 | \usage{ 7 | hetsForSNPMarkers(founders, finals, pedigree) 8 | } 9 | \arguments{ 10 | \item{founders}{Genetic data for the founding lines of the population} 11 | 12 | \item{finals}{Genetic data for the final genotyped lines of the population} 13 | 14 | \item{pedigree}{Pedigree for the population. Unused by this particular function.} 15 | } 16 | \value{ 17 | An object of class \code{hetData}, which contains encodings for the marker heterozygotes and the (unique) marker heterozygote 18 | } 19 | \description{ 20 | Create encoding which assumes that the single non-homozygote value for a SNP marker is the heterozygote 21 | } 22 | \details{ 23 | This function takes in genotype data for the founding lines and the final poulation. It returns an encoding for hetorozygotes for all markers, where multiallelic markers are assumed to have no heterozygotes. For biallelic markers with three observed alleles in the final population, the extra allele is assumed to be the heterozygote. 24 | } 25 | -------------------------------------------------------------------------------- /man/imputationMap.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/imputationGenerics.R 3 | \name{imputationMap} 4 | \alias{imputationMap} 5 | \alias{imputationMap,imputed-method} 6 | \alias{imputationMap,geneticData-method} 7 | \alias{imputationMap,mpcrossMapped-method} 8 | \title{Get map used for IBD genotype imputation} 9 | \usage{ 10 | imputationMap(object, ...) 11 | 12 | \S4method{imputationMap}{imputed}(object, ...) 13 | 14 | \S4method{imputationMap}{geneticData}(object, ...) 15 | 16 | \S4method{imputationMap}{mpcrossMapped}(object, ...) 17 | } 18 | \arguments{ 19 | \item{object}{The object from which to extract the IBD genotype imputation positions.} 20 | 21 | \item{...}{Extra parameters. Currently only \code{"experiment"} is supported, letting the user extract the imputation map for a specific experiment.} 22 | } 23 | \value{ 24 | The map of positions used for IBD genotype imputation. 25 | } 26 | \description{ 27 | Get map used for IBD genotype imputation 28 | } 29 | \details{ 30 | Get the map of positions used for IBD genotype imputation. This is necessary because the points at which IBD genotype imputation has been performed may include non-marker points. See \code{\link{imputeFounders}} for further details. 31 | } 32 | -------------------------------------------------------------------------------- /man/initialize.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/canSkipValidity.R, R/geneticData-class.R 3 | \name{initialize,canSkipValidity-method} 4 | \alias{initialize,canSkipValidity-method} 5 | \alias{initialize,geneticDataList-method} 6 | \title{Initialize method which can skip the validity check} 7 | \usage{ 8 | \S4method{initialize}{canSkipValidity}(.Object, ...) 9 | 10 | \S4method{initialize}{geneticDataList}(.Object, ...) 11 | } 12 | \arguments{ 13 | \item{.Object}{the object to initialize} 14 | 15 | \item{...}{Other arguments. Only \code{skipValidity} is used.} 16 | } 17 | \description{ 18 | This is an initialization method with an optional \code{skipValidity} argument. If this argument is set to \code{TRUE}, the validity check is skipped. This is used by some internal functions within the package, as the validity check can be slow, and internal code is (presumably) guaranteed to produce valid objects. 19 | } 20 | \details{ 21 | Initialize method which can skip the validity check 22 | } 23 | -------------------------------------------------------------------------------- /man/jitterMap.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/jitterMap.R 3 | \name{jitterMap} 4 | \alias{jitterMap} 5 | \title{Add noise to marker positions} 6 | \usage{ 7 | jitterMap(map) 8 | } 9 | \arguments{ 10 | \item{map}{The map to add noise to.} 11 | } 12 | \value{ 13 | A copy of the input map, with noise added to genetic positions. 14 | } 15 | \description{ 16 | Add noise to marker positions, so that no markers are co-located 17 | } 18 | \details{ 19 | Add noise to marker positions, so that no markers are located at the same position on a single chromosome. This was necessary before there was an error model implemented in the IBD genotype imputation and IBD genotype probabliity code. There is little reason to use this function now. 20 | } 21 | -------------------------------------------------------------------------------- /man/lineNamesGeneric.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/lineNames.R 3 | \name{lineNames} 4 | \alias{lineNames} 5 | \title{Get or set the genetic line names} 6 | \usage{ 7 | lineNames(object) 8 | } 9 | \arguments{ 10 | \item{object}{The object from which to extract the line names} 11 | } 12 | \value{ 13 | Vector of genetic line names 14 | } 15 | \description{ 16 | Get or set the genetic line names associated with a pedigree or \code{mpcross} object. 17 | } 18 | \details{ 19 | These functions get or set the names of the genetic lines associated with a pedigree or \code{mpcross} object. 20 | } 21 | -------------------------------------------------------------------------------- /man/lineNamesMpcross.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/lineNames.R 3 | \name{lineNames,mpcross-method} 4 | \alias{lineNames,mpcross-method} 5 | \alias{lineNames,geneticData-method} 6 | \title{Get the genetic line names} 7 | \usage{ 8 | \S4method{lineNames}{mpcross}(object) 9 | 10 | \S4method{lineNames}{geneticData}(object) 11 | } 12 | \arguments{ 13 | \item{object}{The object from which to extract the line names} 14 | } 15 | \value{ 16 | Vector of genetic line names 17 | } 18 | \description{ 19 | Get the genetic line names of a population 20 | } 21 | \details{ 22 | These functions get the names of the genetic lines associated with an \code{mpcross} object. 23 | } 24 | -------------------------------------------------------------------------------- /man/lineNamesPedigree.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/lineNames.R 3 | \name{lineNames<-} 4 | \alias{lineNames<-} 5 | \alias{lineNames,pedigree-method} 6 | \alias{lineNames<-,detailedPedigree-method} 7 | \alias{lineNames<-,pedigree-method} 8 | \title{Get or set the genetic line names of a pedigree} 9 | \usage{ 10 | lineNames(object) <- value 11 | 12 | \S4method{lineNames}{pedigree}(object) 13 | 14 | \S4method{lineNames}{detailedPedigree}(object) <- value 15 | 16 | \S4method{lineNames}{pedigree}(object) <- value 17 | } 18 | \arguments{ 19 | \item{object}{The object for which to get or set the line names} 20 | 21 | \item{value}{The vector of new genetic line names} 22 | } 23 | \value{ 24 | None 25 | } 26 | \description{ 27 | Get or set the genetic line names of a pedigree 28 | } 29 | \details{ 30 | These functions get or set the names of the genetic lines associated with a pedigree. 31 | } 32 | -------------------------------------------------------------------------------- /man/linesByNames.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/pedigree.R 3 | \name{linesByNames} 4 | \alias{linesByNames} 5 | \title{Extract pedigree by names} 6 | \usage{ 7 | linesByNames(pedigree, names) 8 | } 9 | \arguments{ 10 | \item{pedigree}{An object of class \code{pedigree}} 11 | 12 | \item{names}{The names of the lines for which to extract the pedigree} 13 | } 14 | \value{ 15 | A matrix giving the genetic lines and their parents, by line name. 16 | } 17 | \description{ 18 | Extract part of pedigree in human-readable format 19 | } 20 | \details{ 21 | Pedigrees in mpMap2 are stored using indices for maternal and paternal lines, which is not a human-readable format. This function takes in a pedigree, and returns a human-readable subset. 22 | } 23 | -------------------------------------------------------------------------------- /man/listCodingErrors.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/listCodingErrors.R 3 | \name{listCodingErrors} 4 | \alias{listCodingErrors} 5 | \title{Generate a list of encoding errors} 6 | \usage{ 7 | listCodingErrors(founders, finals, hetData) 8 | } 9 | \arguments{ 10 | \item{founders}{Genetic data for the founding lines of the population} 11 | 12 | \item{finals}{Genetic data for the final lines of the population} 13 | 14 | \item{hetData}{Data about the encoding of marker heterozygotes} 15 | } 16 | \value{ 17 | List with the following entries: 18 | \describe{ 19 | \item{finals}{Markers with an invalid observed value.} 20 | \item{null}{Markers with a missing value for a founding line, for which the are observations for at least one genetic line.} 21 | \item{missingHetData}{Markers for which a homozygote did not have an encoding.} 22 | \item{invalidHetData}{Markers for which the heterozygote encoding data was invalid.} 23 | } 24 | } 25 | \description{ 26 | Generate a list of encoding errors from genetic data 27 | } 28 | \details{ 29 | Given genetic data matrices for the founding lines and the final lines of a population, and information about the encoding of marker heterozygotes, generate a list of errors. 30 | These errors include observed values which don't correspond to a known combination of marker alleles, missing values in the genetic data for the founding lines, etc. 31 | 32 | The results of this function allow human-readable lists of errors to be generated, or errors to be automatically fixed (if the errors are sufficiently simple). 33 | } 34 | -------------------------------------------------------------------------------- /man/listCodingErrorsInfiniteSelfing.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/listCodingErrors.R 3 | \name{listCodingErrorsInfiniteSelfing} 4 | \alias{listCodingErrorsInfiniteSelfing} 5 | \title{Generate a list of encoding errors assuming infinite selfing} 6 | \usage{ 7 | listCodingErrorsInfiniteSelfing(founders, finals) 8 | } 9 | \arguments{ 10 | \item{founders}{Genetic data for the founding lines of the population} 11 | 12 | \item{finals}{Genetic data for the final lines of the population} 13 | } 14 | \value{ 15 | List with the following entries: 16 | \describe{ 17 | \item{finals}{Markers with an invalid observed value.} 18 | \item{null}{Markers with a missing value for a founding line, for which the are observations for at least one genetic line.} 19 | \item{missingHetData}{Markers for which a homozygote did not have an encoding.} 20 | \item{invalidHetData}{Markers for which the heterozygote encoding data was invalid.} 21 | } 22 | } 23 | \description{ 24 | Generate a list of encoding errors assuming infinite selfing 25 | } 26 | \details{ 27 | Generate a list of encoding errors assuming infinite selfing. Given the infinite selfing assumption, no information about heterozygote encoding is required. 28 | } 29 | -------------------------------------------------------------------------------- /man/mapFunctions.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/mapFunctions.R 3 | \name{mapFunctions} 4 | \alias{mapFunctions} 5 | \alias{haldaneToRf} 6 | \alias{haldane} 7 | \alias{rfToHaldane} 8 | \alias{rfToKosambi} 9 | \alias{kosambiToRf} 10 | \alias{kosambi} 11 | \title{Map functions} 12 | \usage{ 13 | haldaneToRf(x) 14 | 15 | haldane(x) 16 | 17 | rfToHaldane(r) 18 | 19 | rfToKosambi(r) 20 | 21 | kosambiToRf(x) 22 | 23 | kosambi(x) 24 | } 25 | \arguments{ 26 | \item{x}{centiMorgan distance} 27 | 28 | \item{r}{recombination fraction} 29 | } 30 | \value{ 31 | Recombination fraction. 32 | 33 | Genetic distance in cM. 34 | 35 | Genetic distance in cM. 36 | 37 | Recombination fraction. 38 | 39 | Recombination fraction. 40 | } 41 | \description{ 42 | Functions used to convert between recombination fractions and centiMorgan distances. 43 | } 44 | \section{Functions}{ 45 | \itemize{ 46 | \item \code{haldaneToRf}: Convert from Haldane distance to recombination fraction 47 | 48 | \item \code{haldane}: Convert from Haldane distance to recombination fraction 49 | 50 | \item \code{rfToHaldane}: Convert from recombination fraction to Haldane distance 51 | 52 | \item \code{rfToKosambi}: Convert from recombination fraction to Kosambi distance 53 | 54 | \item \code{kosambiToRf}: Convert from Kosambi distance to recombination fraction 55 | 56 | \item \code{kosambi}: Convert from recombination fraction to Kosambi distance 57 | }} 58 | 59 | -------------------------------------------------------------------------------- /man/markers.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/markers.R 3 | \name{markers} 4 | \alias{markers} 5 | \alias{markers,mpcross-method} 6 | \alias{markers,geneticData-method} 7 | \alias{markers,rf-method} 8 | \alias{markers,lg-method} 9 | \alias{markers,hetData-method} 10 | \title{Genotyped markers 11 | 12 | Return the names of the genotyped markers. 13 | 14 | If an \code{mpcross} object contains multiple experiments, all experiments are required to have the same markers. So a single vector of marker names is returned, in all cases.} 15 | \usage{ 16 | markers(object) 17 | 18 | \S4method{markers}{mpcross}(object) 19 | 20 | \S4method{markers}{geneticData}(object) 21 | 22 | \S4method{markers}{rf}(object) 23 | 24 | \S4method{markers}{lg}(object) 25 | 26 | \S4method{markers}{hetData}(object) 27 | } 28 | \arguments{ 29 | \item{object}{The \code{mpcross} object from which to extract the marker names} 30 | } 31 | \value{ 32 | The names of the genetic markers. 33 | } 34 | \description{ 35 | Genotyped markers 36 | 37 | Return the names of the genotyped markers. 38 | 39 | If an \code{mpcross} object contains multiple experiments, all experiments are required to have the same markers. So a single vector of marker names is returned, in all cases. 40 | } 41 | -------------------------------------------------------------------------------- /man/mpcross-class.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/mpcross-class.R 3 | \docType{class} 4 | \name{mpcross-class} 5 | \alias{mpcross-class} 6 | \alias{.mpcross} 7 | \title{A collection of multi-parent populations without a genetic map} 8 | \description{ 9 | A collection of multi-parent populations without a genetic map 10 | } 11 | \details{ 12 | An object of class \code{mpcross} contains data about one or more multi-parent populations, without a genetic map. As there is no genetic map, there is no information about IBD imputed genotypes or IBD genotype probabilities. There is also no information about estimated recombination fractions. 13 | 14 | A \code{mpcross} object must contain (at a minimum) genetic data about the founding lines of the population, genetic lines about the final lines of the population, a pedigree with information about how the final lines were generated from the founding lines, and information about how heterozygotes have been encoded. See \code{\link{geneticData-class}} for further information. See \code{\link{mpcross}} for the constructor function. 15 | } 16 | \section{Slots}{ 17 | 18 | \describe{ 19 | \item{\code{geneticData}}{A list of objects of class \code{\link{geneticData-class}}, each representing a population.} 20 | }} 21 | 22 | -------------------------------------------------------------------------------- /man/mpcrossMapped-class.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/mpcross-class.R 3 | \docType{class} 4 | \name{mpcrossMapped-class} 5 | \alias{mpcrossMapped-class} 6 | \alias{.mpcrossMapped} 7 | \title{A collection of multi-parent populations with a genetic map} 8 | \description{ 9 | A collection of multi-parent populations with a genetic map 10 | } 11 | \details{ 12 | An object of class \code{mpcrossMapped} contains genetic data for one or more populations, and a genetic map. It might also contain data about the recombination fractions between markers (or it might not). 13 | } 14 | \section{Slots}{ 15 | 16 | \describe{ 17 | \item{\code{map}}{The genetic map for all populations} 18 | 19 | \item{\code{rf}}{The recombination fraction data (which might be NULL).} 20 | 21 | \item{\code{geneticData}}{A list of objects of class \code{geneticData}, each representing a population.} 22 | }} 23 | 24 | -------------------------------------------------------------------------------- /man/mpcrossMapped.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/mpcross.R 3 | \name{mpcrossMapped} 4 | \alias{mpcrossMapped} 5 | \title{Create object of class mpcrossMapped} 6 | \usage{ 7 | mpcrossMapped(cross, map, rf = NULL) 8 | } 9 | \arguments{ 10 | \item{cross}{An object of class \code{mpcross}} 11 | 12 | \item{map}{A genetic map, formatted as in the \code{qtl} package.} 13 | 14 | \item{rf}{Optional recombination fraction data. Leave as NULL if there is no such data.} 15 | } 16 | \value{ 17 | An object of class \code{mpcrossMapped}, constructed from the arguments. 18 | } 19 | \description{ 20 | Create object of class mpcrossMapped 21 | } 22 | \details{ 23 | This function constructs an object of class \code{mpcrossMapped} representing a multi-parent population with a map. It takes in an object of class \code{mpcross}, a genetic map, and optional recombination fraction data. 24 | } 25 | -------------------------------------------------------------------------------- /man/mpcrossRF-class.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/mpcross-class.R 3 | \docType{class} 4 | \name{mpcrossRF-class} 5 | \alias{mpcrossRF-class} 6 | \alias{.mpcrossRF} 7 | \title{A collection of multi-parent populations with recombination fraction estimates} 8 | \description{ 9 | A collection of multi-parent populations with recombination fraction estimates 10 | } 11 | \details{ 12 | An object of class \code{mpcrossRF} contains data about one or more multi-parent populations, without a genetic map, but with recombination fraction estimates. As there is no genetic map, there is no information about IBD imputed genotypes or IBD genotype probabilities. 13 | } 14 | \section{Slots}{ 15 | 16 | \describe{ 17 | \item{\code{geneticData}}{A list of objects of class \code{geneticData}, each representing a population.} 18 | 19 | \item{\code{rf}}{Estimates of recombination fractions between every pair of genetic markers.} 20 | }} 21 | 22 | -------------------------------------------------------------------------------- /man/multiparentSNP.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/multiparentSNP.R 3 | \name{multiparentSNP} 4 | \alias{multiparentSNP} 5 | \title{Convert all markers to SNP markers} 6 | \usage{ 7 | multiparentSNP(keepHets) 8 | } 9 | \arguments{ 10 | \item{keepHets}{Should heterozygotes for the SNP marker be kept?} 11 | } 12 | \value{ 13 | An object of internal type \code{multiparentSNP}, which can be combined with an object of class \code{mpcross} using the addition operator. 14 | } 15 | \description{ 16 | Convert all markers in an object with fully informative markers to SNP markers 17 | } 18 | \details{ 19 | When initially generated, objects of class \code{mpcross} have markers that are fully informative - Every founder carries a different allele, and all marker heterozygotes are distinguishable. This function can be used to convert a simulated object to one with SNP markers. The resulting markers have two alleles, and the marker heterozygote might or might be observable. 20 | } 21 | -------------------------------------------------------------------------------- /man/nFounders.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/nFounders.R 3 | \name{nFounders} 4 | \alias{nFounders} 5 | \alias{nFounders,detailedPedigree-method} 6 | \alias{nFounders,pedigree-method} 7 | \alias{nFounders,mpcross-method} 8 | \alias{nFounders,geneticData-method} 9 | \title{Number of genotyped markers 10 | 11 | Return the number of genotyped markers in an object. 12 | 13 | If an \code{mpcross} object contains multiple experiments, one number is returned per experiment.} 14 | \usage{ 15 | nFounders(object) 16 | 17 | \S4method{nFounders}{detailedPedigree}(object) 18 | 19 | \S4method{nFounders}{pedigree}(object) 20 | 21 | \S4method{nFounders}{mpcross}(object) 22 | 23 | \S4method{nFounders}{geneticData}(object) 24 | } 25 | \arguments{ 26 | \item{object}{The \code{mpcross} object from which to extract the number of founders} 27 | } 28 | \value{ 29 | The number of founding lines in the population, or a list of numbers in the case of multiple experiments contained in a single object. 30 | } 31 | \description{ 32 | Number of genotyped markers 33 | 34 | Return the number of genotyped markers in an object. 35 | 36 | If an \code{mpcross} object contains multiple experiments, one number is returned per experiment. 37 | } 38 | -------------------------------------------------------------------------------- /man/nLines.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/nLines.R 3 | \name{nLines} 4 | \alias{nLines} 5 | \alias{nLines,mpcross-method} 6 | \alias{nLines,geneticData-method} 7 | \title{Number of genotyped lines 8 | 9 | Return the number of genotyped lines in an object. 10 | 11 | This includes only the number of final lines genotyped in the population, and does not include the founding lines. If an \code{mpcross} object contains multiple experiments, one number is returned per experiment.} 12 | \usage{ 13 | nLines(object) 14 | 15 | \S4method{nLines}{mpcross}(object) 16 | 17 | \S4method{nLines}{geneticData}(object) 18 | } 19 | \arguments{ 20 | \item{object}{The \code{mpcross} object from which to extract the number of genotyped lines.} 21 | } 22 | \value{ 23 | The number of genetic lines in the population, or a list of numbers in the case of multiple experiments contained in a single object. 24 | } 25 | \description{ 26 | Number of genotyped lines 27 | 28 | Return the number of genotyped lines in an object. 29 | 30 | This includes only the number of final lines genotyped in the population, and does not include the founding lines. If an \code{mpcross} object contains multiple experiments, one number is returned per experiment. 31 | } 32 | -------------------------------------------------------------------------------- /man/nMarkers.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/nMarkers.R 3 | \name{nMarkers} 4 | \alias{nMarkers} 5 | \alias{nMarkers,mpcross-method} 6 | \alias{nMarkers,geneticData-method} 7 | \title{Number of genotyped markers 8 | 9 | Return the number of genotyped markers in an object. 10 | 11 | If an \code{mpcross} object contains multiple experiments, all experiments are required to have the same markers. So only one number is returned, in all cases.} 12 | \usage{ 13 | nMarkers(object) 14 | 15 | \S4method{nMarkers}{mpcross}(object) 16 | 17 | \S4method{nMarkers}{geneticData}(object) 18 | } 19 | \arguments{ 20 | \item{object}{The \code{mpcross} object from which to extract the marker names} 21 | } 22 | \value{ 23 | The number of markers in an object of class \code{mpcross}. 24 | } 25 | \description{ 26 | Number of genotyped markers 27 | 28 | Return the number of genotyped markers in an object. 29 | 30 | If an \code{mpcross} object contains multiple experiments, all experiments are required to have the same markers. So only one number is returned, in all cases. 31 | } 32 | -------------------------------------------------------------------------------- /man/normalPhenotype.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/simulatePhenotypes.R 3 | \name{normalPhenotype} 4 | \alias{normalPhenotype} 5 | \title{Simulate normally distributed phenotype} 6 | \usage{ 7 | normalPhenotype(means, standardDeviations, phenotypeName, marker) 8 | } 9 | \arguments{ 10 | \item{means}{The means of the phenotype for all the different founder alleles} 11 | 12 | \item{standardDeviations}{The standard deviations of the phenotype for all the different founder alleles} 13 | 14 | \item{phenotypeName}{The name of the new phenotype} 15 | 16 | \item{marker}{The name of the marker which controls this phenotype} 17 | } 18 | \value{ 19 | An object of class \code{normalPhenotype} representing the phenotype. 20 | } 21 | \description{ 22 | Add a normally distributed phenotype 23 | } 24 | \details{ 25 | Add a normally distributed phenotype to a given populations 26 | } 27 | -------------------------------------------------------------------------------- /man/openmp.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/num_threads.R 3 | \name{omp_set_num_threads} 4 | \alias{omp_set_num_threads} 5 | \alias{omp_get_num_threads} 6 | \title{Get or set number of threads for OpenMP} 7 | \usage{ 8 | omp_set_num_threads(num) 9 | 10 | omp_get_num_threads() 11 | } 12 | \arguments{ 13 | \item{num}{New number of threads for OpenMP} 14 | } 15 | \value{ 16 | None 17 | 18 | The number of threads for OpenMP 19 | } 20 | \description{ 21 | Get or set the number of threads for OpenMP 22 | } 23 | \details{ 24 | Some functions in mpMap2 are parallelised. Depending on the number of cores available, and the type of workload, it may be advantageous to turn parallelisation on or off, by setting the number of OpenMP threads appropriately. Setting the number of threads to 1 turns parallelisation off 25 | 26 | In particular, for small examples on a computer with a large number of threads, parallelisation may result in a huge decrease in performance. 27 | 28 | This function returns an error if the package was not compiled with OpenMP. 29 | } 30 | -------------------------------------------------------------------------------- /man/pedigree-class.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/pedigree-class.R 3 | \name{pedigree-class} 4 | \alias{pedigree-class} 5 | \title{Pedigree class} 6 | \description{ 7 | This class describes a pedigree for an experimental design. Although package mpMap2 only allows for the analysis of pedigrees corresponding to multi-parent crosses, this pedigree class can describe arbitrary experimental designs. 8 | } 9 | \section{Slots}{ 10 | 11 | \describe{ 12 | \item{\code{mother}}{The index within the pedigree of the mother of this individual} 13 | 14 | \item{\code{father}}{The index within the pedigree of the father of this individual} 15 | 16 | \item{\code{lineName}}{The name of this individual} 17 | 18 | \item{\code{selfing}}{A value indicating whether analysis of an experiment using this pedigree should assume infinite generations of selfing. A value of \code{"infinite"} indicates infinite generations of selfing, and a value of \code{"finite"} indicates finite generations of selfing.} 19 | 20 | \item{\code{warnImproperFunnels}}{A value indicating whether to warn the user about funnels with repeated founders.} 21 | }} 22 | 23 | \seealso{ 24 | \code{\link[mpMap2]{pedigree-class}}, \code{\link[mpMap2]{simulateMPCross}}, \code{\link[mpMap2]{detailedPedigree-class}}, \code{\link[mpMap2]{rilPedigree}}, \code{\link[mpMap2]{f2Pedigree}}, \code{\link[mpMap2]{fourParentPedigreeRandomFunnels}}, \code{\link[mpMap2]{fourParentPedigreeSingleFunnel}}, \code{\link[mpMap2]{eightParentPedigreeRandomFunnels}}, \code{\link[mpMap2]{eightParentPedigreeSingleFunnel}}, \code{\link[mpMap2]{sixteenParentPedigreeRandomFunnels}} 25 | } 26 | -------------------------------------------------------------------------------- /man/pedigreeGraph-class.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/pedigreeGraph-class.R 3 | \docType{class} 4 | \name{pedigreeGraph-class} 5 | \alias{pedigreeGraph-class} 6 | \alias{.pedigreeGraph} 7 | \title{Graph for a pedigree} 8 | \description{ 9 | Graph for a pedigree 10 | } 11 | \details{ 12 | This class contains the directed graph corresponding to a pedigree, and data for laying out the graph on a plane. 13 | } 14 | \section{Slots}{ 15 | 16 | \describe{ 17 | \item{\code{graph}}{An object of class igraph.} 18 | 19 | \item{\code{layout}}{A matrix where each row gives the position of a graph vertex in the plane.} 20 | }} 21 | 22 | -------------------------------------------------------------------------------- /man/pedigreeToGraph.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/pedigreeToGraph.R 3 | \name{pedigreeToGraph} 4 | \alias{pedigreeToGraph} 5 | \title{Convert pedigree to a graph} 6 | \usage{ 7 | pedigreeToGraph(pedigree) 8 | } 9 | \arguments{ 10 | \item{pedigree}{The pedigree to convert into a graph} 11 | } 12 | \value{ 13 | An object of class \code{pedigreeGraph}, containing the graph and a planar layout for the graph. 14 | } 15 | \description{ 16 | Convert pedigree to a graph 17 | } 18 | \details{ 19 | It is often useful for visualisation purposes to generate the pedigree graph. In this graph, every genetic line is a vertex in a graph, and there is an edge from every parent to all the offspring. This function generates the graph, and lays the graph out in the plane in a way that tends to make the structure of the graph as clear as possible. 20 | } 21 | -------------------------------------------------------------------------------- /man/plot-addExtraMarkersStatistics-ANY-method.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/addExtraMarkers.R 3 | \name{plot,addExtraMarkersStatistics,ANY-method} 4 | \alias{plot,addExtraMarkersStatistics,ANY-method} 5 | \title{Plot chi-squared statistics for independence} 6 | \usage{ 7 | \S4method{plot}{addExtraMarkersStatistics,ANY}(x, y, ...) 8 | } 9 | \arguments{ 10 | \item{x}{Object of class \code{addExtraMarkersStatistics} containing test-statistic values.} 11 | 12 | \item{y}{Unused} 13 | 14 | \item{...}{Unused} 15 | } 16 | \value{ 17 | A ggplot object suitable for display. 18 | } 19 | \description{ 20 | Plot the chi-squared statistics for independence, used to map a new marker to an existing genetic map 21 | } 22 | \details{ 23 | This function plots a trace of the chi-squared test-statistics used to map a new genetic marker to an existing genetic map. This can be useful to, for example, see if a single polymorphism is present at multiple points on the genome. 24 | } 25 | -------------------------------------------------------------------------------- /man/plot-pedigreeGraph-ANY-method.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/pedigreeGraph.R 3 | \name{plot,pedigreeGraph,ANY-method} 4 | \alias{plot,pedigreeGraph,ANY-method} 5 | \title{Plot the graph of a pedigree} 6 | \usage{ 7 | \S4method{plot}{pedigreeGraph,ANY}(x, y, ...) 8 | } 9 | \arguments{ 10 | \item{x}{pedigree graph to plot} 11 | 12 | \item{y}{unused} 13 | 14 | \item{...}{Other options to plot.igraph} 15 | } 16 | \value{ 17 | None 18 | } 19 | \description{ 20 | Plot the graph of a pedigree 21 | } 22 | \details{ 23 | Plot the graph of a pedigree, after the graph has been generated by \code{\link{pedigreeToGraph}} 24 | } 25 | \seealso{ 26 | \code{\link{pedigreeToGraph}} 27 | } 28 | -------------------------------------------------------------------------------- /man/plot.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plot.R 3 | \name{plot,mpcross,ANY-method} 4 | \alias{plot,mpcross,ANY-method} 5 | \alias{plot,geneticData,ANY-method} 6 | \alias{plot,probabilities,ANY-method} 7 | \alias{plot,imputed,ANY-method} 8 | \title{Plot methods} 9 | \usage{ 10 | \S4method{plot}{mpcross,ANY}(x, y, ...) 11 | 12 | \S4method{plot}{geneticData,ANY}(x, y, ...) 13 | 14 | \S4method{plot}{probabilities,ANY}(x, y, ...) 15 | 16 | \S4method{plot}{imputed,ANY}(x, y, ...) 17 | } 18 | \arguments{ 19 | \item{x}{Unused} 20 | 21 | \item{y}{Unused} 22 | 23 | \item{...}{Unused} 24 | } 25 | \value{ 26 | None 27 | } 28 | \description{ 29 | There are multiple meaningful ways to plot some mpMap2 objects. Please use \code{\link{plotProbabilities}} or \code{\link{plotMosaic}} instead. 30 | } 31 | \details{ 32 | There are multiple meaningful ways to plot some mpMap2 objects. In these cases the plot function is implemented but returns an error. Please use \code{\link{plotProbabilities}} or \code{\link{plotMosaic}} instead. 33 | } 34 | -------------------------------------------------------------------------------- /man/plotMosaic.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/plotMosaic.R 3 | \name{plotMosaic} 4 | \alias{plotMosaic} 5 | \title{Plot estimated genetic composition of lines} 6 | \usage{ 7 | plotMosaic(inputObject, chromosomes, positions, lines, ...) 8 | } 9 | \arguments{ 10 | \item{inputObject}{An object of class \code{mpcrossMapped} containing imputed IBD genotypes} 11 | 12 | \item{chromosomes}{Chromosomes to plot} 13 | 14 | \item{positions}{Genetic positions to plot} 15 | 16 | \item{lines}{Genetic lines to plot} 17 | 18 | \item{...}{Extra inputs to \code{heatmap_2}} 19 | } 20 | \value{ 21 | None 22 | } 23 | \description{ 24 | Plot estimated genetic composition of lines 25 | } 26 | \details{ 27 | This function produces a heatmap showing the genetic composition of lines, as measured by the imputed IBD genotypes. Rows correspond to genetic lines, columns correspond to genetic positions, and colours indicate founder alleles. All heterozygotes are marked in the same colour, otherwise there are generally too many colours to be useful. 28 | } 29 | -------------------------------------------------------------------------------- /man/probabilities-class.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/geneticData-class.R 3 | \docType{class} 4 | \name{probabilities-class} 5 | \alias{probabilities-class} 6 | \alias{.probabilities} 7 | \title{Identity-by-descent genotype probabilities} 8 | \arguments{ 9 | \item{data}{An integer matrix containing the IBD genotype probabilities. Rows correspond to combinations of genetic lines and founder lines, and columns correspond to genetic positions.} 10 | 11 | \item{key}{A matrix identifying how pairs of founder alleles are mapped to rows of the data slot.} 12 | 13 | \item{map}{The map of positions at which IBD genotype probabilities are computed.} 14 | } 15 | \description{ 16 | Identity-by-descent genotype probabilities 17 | } 18 | \details{ 19 | This object contains the identify-by-descent genotype probabilities, as computed by \code{\link{computeGenotypeProbabilities}}. The slot \code{data} is a numeric matrix containing the actual computations, where columns correspond to genetic positions. 20 | 21 | Describing the rows of the data matrix is more complicated. The slot \code{key} is a matrix containing three columns, the first two being founder alleles, and the third being an encoding of that combination. If \code{k} is the number of rows in \code{key}, then the first \code{k} rows of the data matrix correspond to the first genetic line in the population. Specifically, the first row corresponds to genotype probabilities for the first line, for the combination of founder alleles encoding as 1. The second corresponds to genotype probabilities for the first line, for the combination encoded as 2, etc. 22 | } 23 | -------------------------------------------------------------------------------- /man/redact.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/redact.R 3 | \name{redact} 4 | \alias{redact} 5 | \alias{redact,mpcross-method} 6 | \alias{redact,mpcrossRF-method} 7 | \alias{redact,mpcrossLG-method} 8 | \alias{redact,mpcrossMapped-method} 9 | \alias{redact,geneticData-method} 10 | \title{Redact sensitive information 11 | 12 | This function redacts possibly sensitive information from objects, resulting in an object that is safe to publish.} 13 | \usage{ 14 | redact(object) 15 | 16 | \S4method{redact}{mpcross}(object) 17 | 18 | \S4method{redact}{mpcrossRF}(object) 19 | 20 | \S4method{redact}{mpcrossLG}(object) 21 | 22 | \S4method{redact}{mpcrossMapped}(object) 23 | 24 | \S4method{redact}{geneticData}(object) 25 | } 26 | \arguments{ 27 | \item{object}{The object of class \code{mpcross} to redact.} 28 | } 29 | \value{ 30 | An object of class \code{mpcross}, with identifying information removed. 31 | } 32 | \description{ 33 | Sensitive information includes names of genetic lines (both founding lines and final population lines) and marker names. All actual data (marker genotypes, imputed IBD genotypes, IBD probabilities, etc) are preserved. 34 | } 35 | -------------------------------------------------------------------------------- /man/removeHets.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/removeHets.R 3 | \name{removeHets} 4 | \alias{removeHets} 5 | \title{Remove heterozygotes} 6 | \usage{ 7 | removeHets() 8 | } 9 | \value{ 10 | An object of internal class \code{removeHets}, which can be combined with an object of class \code{mpcross} using the addition operator. 11 | } 12 | \description{ 13 | Remove all heterozygotes from dataset 14 | } 15 | \details{ 16 | This function can be used to remove all heterozygotes from an \code{mpcross} object. Information about how pairs of different marker alleles are encoded as genotypes is discarded, and all observations of heterozygotes will be marked as \code{NA}. Any information calculated based on the genetic data (imputed IBD genotypes, IBD probabilities) will be discarded. 17 | } 18 | \examples{ 19 | pedigree <- eightParentPedigreeImproperFunnels(initialPopulationSize = 10, 20 | selfingGenerations = 1, nSeeds = 1) 21 | #Generate map 22 | map <- qtl::sim.map() 23 | #Simulate data 24 | cross <- simulateMPCross(map = map, pedigree = pedigree, mapFunction = haldane) 25 | finals(cross)[1:5, 1:5] 26 | hetData(cross)[[1]] 27 | cross <- cross + removeHets() 28 | finals(cross)[1:5, 1:5] 29 | hetData(cross)[[1]] 30 | } 31 | -------------------------------------------------------------------------------- /man/reverseChromosomes.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/reverseChromosomes.R 3 | \name{reverseChromosomes} 4 | \alias{reverseChromosomes} 5 | \title{Reverse the order of the specified chromosomes} 6 | \usage{ 7 | reverseChromosomes(mpcrossMapped, chromosomes) 8 | } 9 | \arguments{ 10 | \item{mpcrossMapped}{The initial object, for which we want to reverse some of the chromosomes} 11 | 12 | \item{chromosomes}{The names of the chromosomes to reverse} 13 | } 14 | \value{ 15 | An object of class \code{mpcrossMapped}, with certain chromosomes reversed. 16 | } 17 | \description{ 18 | Create a new object, with the specified chromosomes reversed 19 | } 20 | \details{ 21 | Create a new object, with the specified chromosomes reversed 22 | } 23 | \examples{ 24 | map <- qtl::sim.map() 25 | pedigree <- f2Pedigree(1000) 26 | cross <- simulateMPCross(map = map, pedigree = pedigree, mapFunction = haldane, seed = 1) 27 | mappedCross <- mpcrossMapped(cross = cross, map = map) 28 | reversedX <- reverseChromosomes(mappedCross, "X") 29 | reversedX@map[["X"]] 30 | mappedCross@map[["X"]] 31 | } 32 | -------------------------------------------------------------------------------- /man/rilPedigree.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/rilPedigree.R 3 | \name{rilPedigree} 4 | \alias{rilPedigree} 5 | \title{Generate a two-parent RIL pedigree which starts from inbred founders} 6 | \usage{ 7 | rilPedigree(populationSize, selfingGenerations) 8 | } 9 | \arguments{ 10 | \item{populationSize}{The size of the generated population} 11 | 12 | \item{selfingGenerations}{Number of generations of selfing. Specifying one generation leads to an F2 design.} 13 | } 14 | \value{ 15 | An object of class \code{detailedPedigree} representing the experimental design, suitable for simulation using simulateMPCross. 16 | } 17 | \description{ 18 | Generate a two-parent RIL pedigree which starts from inbred founders 19 | } 20 | -------------------------------------------------------------------------------- /man/simulateMPCross.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/simulateMPCross.R 3 | \name{simulateMPCross} 4 | \alias{simulateMPCross} 5 | \title{Simulate data from multi-parent designs} 6 | \usage{ 7 | simulateMPCross(map, pedigree, mapFunction, seed) 8 | } 9 | \arguments{ 10 | \item{map}{Linkage map with which to generate data. See \code{\link[qtl]{sim.map}}} 11 | 12 | \item{pedigree}{Pedigree for a multi-parent cross.} 13 | 14 | \item{mapFunction}{Map function used to convert distances to recombination fractions} 15 | 16 | \item{seed}{Random seed to use.} 17 | } 18 | \value{ 19 | Object of class \code{mpcross}. 20 | } 21 | \description{ 22 | Data is simulated according to a pedigree, map and QTL model 23 | } 24 | -------------------------------------------------------------------------------- /man/simulatedFourParentData.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/roxygen.R 3 | \docType{data} 4 | \name{simulatedFourParentData} 5 | \alias{simulatedFourParentData} 6 | \alias{simulatedFourParentMap} 7 | \title{Simulated data from a four-parent population.} 8 | \description{ 9 | Simulated data from a four-parent population. Used in the examples given in the documentation. 10 | } 11 | \examples{ 12 | set.seed(1) 13 | #This data was generated by the following script 14 | pedigree <- fourParentPedigreeRandomFunnels(initialPopulationSize = 1000, 15 | selfingGenerations = 6, intercrossingGenerations = 0) 16 | #Assume infinite generations of selfing in subsequent analysis 17 | selfing(pedigree) <- "infinite" 18 | #Generate random map 19 | simulatedFourParentMap <- qtl::sim.map(len = 100, n.mar = 101, anchor.tel = TRUE, 20 | include.x = FALSE) 21 | #Simulate data 22 | simulatedFourParentData <- simulateMPCross(map = simulatedFourParentMap, pedigree = pedigree, 23 | mapFunction = haldane, seed = 1L) 24 | } 25 | -------------------------------------------------------------------------------- /man/sixteenParentPedigreeRandomFunnels.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/sixteenParentPedigreeRandomFunnels.R 3 | \name{sixteenParentPedigreeRandomFunnels} 4 | \alias{sixteenParentPedigreeRandomFunnels} 5 | \title{Generate a sixteen-parent pedigree} 6 | \usage{ 7 | sixteenParentPedigreeRandomFunnels( 8 | initialPopulationSize, 9 | selfingGenerations, 10 | nSeeds = 1L, 11 | intercrossingGenerations 12 | ) 13 | } 14 | \arguments{ 15 | \item{initialPopulationSize}{The number of F1 lines generated} 16 | 17 | \item{selfingGenerations}{The number of selfing generations at the end of the pedigree} 18 | 19 | \item{nSeeds}{The number of progeny taken from each intercrossing line, or from each F1 if no intercrossing is specified. These lines are then selfed according to selfingGenerations} 20 | 21 | \item{intercrossingGenerations}{The number of generations of random mating performed from the F1 generation. Population size is maintained at that specified by initialPopulationSize} 22 | } 23 | \value{ 24 | An object of class \code{detailedPedigree} representing the experimental design, suitable for simulation using simulateMPCross. 25 | } 26 | \description{ 27 | Generate a sixteen-parent pedigree starting from inbred founders, using a random funnel 28 | } 29 | \seealso{ 30 | \code{\link{eightParentPedigreeSingleFunnel}}, \code{\link{fourParentPedigreeSingleFunnel}}, \code{\link{fourParentPedigreeRandomFunnels}}, \code{\link{twoParentPedigree}} 31 | } 32 | -------------------------------------------------------------------------------- /man/stripPedigree.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/stripPedigree.R 3 | \name{stripPedigree} 4 | \alias{stripPedigree} 5 | \title{Strip pedigree of unneccessary lines} 6 | \usage{ 7 | stripPedigree(pedigree, finalLines) 8 | } 9 | \arguments{ 10 | \item{pedigree}{The initial pedigree, which may contain some unneccessary extra genetic lines} 11 | 12 | \item{finalLines}{The list of lines of interest. Lines in the pedigree which do not make a genetic contribution to the lines in \code{finalLines} will be removed.} 13 | } 14 | \value{ 15 | An object of class \code{detailedPedigree} representing the experimental design, suitable for simulation using simulateMPCross. 16 | } 17 | \description{ 18 | Strip pedigree of lines that make no genetic contribution to the specified set of lines. 19 | } 20 | \details{ 21 | Pedigrees for structured experiments can be messy. Often they include lines that make no genetic contribution to the lines that were finally genotyped. When it comes to visualising the structure of the pedigree of the final population, these unneccessary extra lines can make it difficult to see the structure. This function takes in a pedigree and a list of genetic lines, and returns a subpedigree that contains only those lines that make a genetic contribution to the named lines. 22 | 23 | This function relies on the use of the Boost C++ libraries, and may not be available in every distributed version of mpMap2. If this function is unavailable, the function will return \code{NULL}. 24 | } 25 | -------------------------------------------------------------------------------- /man/testDistortion.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/testDistortion.R 3 | \name{testDistortion} 4 | \alias{testDistortion} 5 | \title{Test for distortion using IBD genotype probabilities} 6 | \usage{ 7 | testDistortion(object) 8 | } 9 | \arguments{ 10 | \item{object}{An object of class \code{mpcrossMapped} which contains imputed IBD genotype data} 11 | } 12 | \value{ 13 | A data.frame containing p-values and test-statistic values for each position at which there is IBD genotype probability data. 14 | } 15 | \description{ 16 | Test for distortion using IBD genotype probabilities 17 | } 18 | \details{ 19 | In real experiments, genetic inheritance may not follow the expected model. This function tests for deviations from expected inheritance by using the genetic composition of the population at individual positions, as measured by the IBD genotype probabilities. 20 | 21 | At a particular point, the mean for each founder allele of the IBD genotype probabilities for each founder allele are summed across the population. The average is taken, and this is then compared with the proportion expected to be inherited from that founder, under standard models of genetic inheritance. 22 | 23 | The result is a matrix containing p-values, test-statistic values, and the L1 and L2 distances between the observed genetic proportions, and the expected genetic proportions. 24 | } 25 | -------------------------------------------------------------------------------- /man/toMpMap.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/toMpMap.R 3 | \name{toMpMap} 4 | \alias{toMpMap} 5 | \title{Convert to mpMap format} 6 | \usage{ 7 | toMpMap(mpcross) 8 | } 9 | \arguments{ 10 | \item{mpcross}{The object of class \code{mpcross} to convert.} 11 | } 12 | \value{ 13 | An object with structure compatible with the older mpMap package. 14 | } 15 | \description{ 16 | Convert to the format used by the original mpMap package. 17 | } 18 | \details{ 19 | Converts an \code{mpcross} object to the format used by the original mpMap, the predecessor of this package. It is unlikely that this function will ever need to be used. 20 | } 21 | -------------------------------------------------------------------------------- /src/.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | mpMap2.dll -------------------------------------------------------------------------------- /src/Makefile.in: -------------------------------------------------------------------------------- 1 | #This is only used as part of the CMake build system 2 | default_target: all 3 | .PHONY : default_target 4 | 5 | clean: 6 | cd @PROJECT_BINARY_DIR@; \ 7 | MAKE= MAKEFLAGS= @FULL_MAKE_PROGRAM@ @PROJECT_BINARY_DIR@/Makefile clean 8 | 9 | all: 10 | cd @PROJECT_BINARY_DIR@; \ 11 | MAKE= MAKEFLAGS= @FULL_MAKE_PROGRAM@ @PROJECT_BINARY_DIR@/Makefile all; \ 12 | MAKE= MAKEFLAGS= @FULL_MAKE_PROGRAM@ @PROJECT_BINARY_DIR@/Makefile install 13 | 14 | -------------------------------------------------------------------------------- /src/Makevars: -------------------------------------------------------------------------------- 1 | PKG_CXXFLAGS=-I. $(SHLIB_OPENMP_CXXFLAGS) 2 | PKG_LIBS=$(SHLIB_OPENMP_CXXFLAGS) 3 | -------------------------------------------------------------------------------- /src/alleleDataErrors.h: -------------------------------------------------------------------------------- 1 | #ifndef ALLELE_DATA_ERRORS_HEADER_GUARD 2 | #define ALLELE_DATA_ERRORS_HEADER_GUARD 3 | #include 4 | RcppExport SEXP alleleDataErrors(SEXP Robject, SEXP Rlimit); 5 | RcppExport void codingErrorsToStrings(Rcpp::List codingErrors, std::vector& codingErrorsAsStrings, Rcpp::IntegerMatrix finals, Rcpp::List hetData, int limit); 6 | RcppExport SEXP listCodingErrors(SEXP founders, SEXP finals, SEXP hetData); 7 | #endif 8 | 9 | -------------------------------------------------------------------------------- /src/array2.h: -------------------------------------------------------------------------------- 1 | #ifndef ARRAY_2_HEADER_GUARD 2 | #define ARRAY_2_HEADER_GUARD 3 | template struct array2 4 | { 5 | public: 6 | array2() 7 | {} 8 | double values[n][n]; 9 | }; 10 | #endif 11 | -------------------------------------------------------------------------------- /src/arsa.h: -------------------------------------------------------------------------------- 1 | #ifndef MPMAP2_ARSA_HEADER_GUARD 2 | #define MPMAP2_ARSA_HEADER_GUARD 3 | #include "Rcpp.h" 4 | #include 5 | #include 6 | SEXP arsaExportedR(SEXP n_, SEXP dist_, SEXP cool_, SEXP temperatureMin_, SEXP nReps_, SEXP maxMove_sexp, SEXP effortMultiplier_sexp, SEXP randomStart_sexp); 7 | struct arsaArgs 8 | { 9 | public: 10 | R_xlen_t n; 11 | double* dist; 12 | int nReps; 13 | double temperatureMin, cool; 14 | double effortMultiplier; 15 | bool randomStart; 16 | int maxMove; 17 | std::vector bestPermutationAllReps; 18 | std::function progressFunction; 19 | }; 20 | void arsa(arsaArgs& args); 21 | #endif 22 | 23 | -------------------------------------------------------------------------------- /src/arsaRaw.h: -------------------------------------------------------------------------------- 1 | #ifndef MPMAP2_ARSA_RAW_HEADER_GUARD 2 | #define MPMAP2_ARSA_RAW_HEADER_GUARD 3 | #include "Rcpp.h" 4 | #include 5 | namespace arsaRaw 6 | { 7 | struct arsaRawArgs 8 | { 9 | public: 10 | arsaRawArgs(std::vector& levels, std::vector& permutation) 11 | :n(-1), rawDist(NULL), cool(0.5), temperatureMin(0.1), nReps(1), randomStart(true), maxMove(0), effortMultiplier(1), levels(levels), permutation(permutation) 12 | {} 13 | long n; 14 | Rbyte* rawDist; 15 | double cool; 16 | double temperatureMin; 17 | long nReps; 18 | std::function progressFunction; 19 | bool randomStart; 20 | int maxMove; 21 | double effortMultiplier; 22 | std::vector& levels; 23 | std::vector& permutation; 24 | }; 25 | void arsaRaw(arsaRawArgs& args); 26 | void arsaRawExported(arsaRawArgs& args); 27 | #ifdef _OPENMP 28 | void arsaRawParallel(arsaRawArgs& args); 29 | #endif 30 | } 31 | #endif 32 | -------------------------------------------------------------------------------- /src/arsaRawREntryPoint.h: -------------------------------------------------------------------------------- 1 | #ifndef MPMAP2_ARSA_RAW_R_ENTRY_POINT_HEADER_GUARD 2 | #define MPMAP2_ARSA_RAW_R_ENTRY_POINT_HEADER_GUARD 3 | #include "Rcpp.h" 4 | #include 5 | SEXP arsaRawREntryPoint(SEXP n_, SEXP rawDist_, SEXP levels_, SEXP cool_, SEXP temperatureMin_, SEXP nReps_, SEXP maxMove_sexp, SEXP effortMultiplier_sexp, SEXP randomStart_sexp); 6 | #endif 7 | 8 | -------------------------------------------------------------------------------- /src/assignFounderPattern.h: -------------------------------------------------------------------------------- 1 | #ifndef ASSIGN_FOUNDER_PATTERN_HEADER_GUARD 2 | #define ASSIGN_FOUNDER_PATTERN_HEADER_GUARD 3 | #include 4 | RcppExport SEXP assignFounderPattern(SEXP geneticData, SEXP founderMatrix); 5 | #endif 6 | -------------------------------------------------------------------------------- /src/checkHets.h: -------------------------------------------------------------------------------- 1 | #ifndef CHECK_HETS_HEADER_GUARD 2 | #define CHECK_HETS_HEADER_GUARD 3 | #include 4 | RcppExport SEXP checkHets(SEXP hets); 5 | #endif 6 | 7 | -------------------------------------------------------------------------------- /src/checkImputedBounds.cpp: -------------------------------------------------------------------------------- 1 | #include "checkImputedBounds.h" 2 | SEXP checkImputedBounds(SEXP imputed_sexp) 3 | { 4 | BEGIN_RCPP 5 | Rcpp::S4 imputed; 6 | try 7 | { 8 | imputed = Rcpp::as(imputed_sexp); 9 | } 10 | catch(...) 11 | { 12 | throw std::runtime_error("Input imputed must be an S4 object"); 13 | } 14 | 15 | Rcpp::IntegerVector dataMatrix; 16 | try 17 | { 18 | dataMatrix = Rcpp::as(imputed.slot("data")); 19 | } 20 | catch(...) 21 | { 22 | throw std::runtime_error("Input imputed@data must be an integer matrix"); 23 | } 24 | 25 | Rcpp::IntegerMatrix keyMatrix; 26 | try 27 | { 28 | keyMatrix = Rcpp::as(imputed.slot("key")); 29 | } 30 | catch(...) 31 | { 32 | throw std::runtime_error("Input imputed@key must be an integer matrix"); 33 | } 34 | 35 | if(keyMatrix.ncol() != 3) 36 | { 37 | throw std::runtime_error("Input imputed@key must have three columns"); 38 | } 39 | 40 | std::vector encodings; 41 | for(int i = 0; i < keyMatrix.nrow(); i++) 42 | { 43 | encodings.push_back(keyMatrix(i, 2)); 44 | } 45 | std::sort(encodings.begin(), encodings.end()); 46 | encodings.erase(std::unique(encodings.begin(), encodings.end()), encodings.end()); 47 | if(encodings[0] != 1 || *encodings.rbegin() != (int)encodings.size()) 48 | { 49 | throw std::runtime_error("Encodings in imputed@key must be consecutive integers"); 50 | } 51 | 52 | int upperBound = (int)encodings.size(); 53 | for(int i = 0; i < dataMatrix.size(); i++) 54 | { 55 | if(dataMatrix(i) < 1 || dataMatrix(i) > upperBound) 56 | { 57 | return Rcpp::wrap(false); 58 | } 59 | } 60 | return Rcpp::wrap(true); 61 | END_RCPP 62 | } 63 | -------------------------------------------------------------------------------- /src/checkImputedBounds.h: -------------------------------------------------------------------------------- 1 | #ifndef CHECK_IMPUTED_BOUNDS_HEADER_GUARD 2 | #define CHECK_IMPUTED_BOUNDS_HEADER_GUARD 3 | #include 4 | SEXP checkImputedBounds(SEXP imputed); 5 | #endif 6 | -------------------------------------------------------------------------------- /src/combineGenotypes.cpp: -------------------------------------------------------------------------------- 1 | #include "combineGenotypes.h" 2 | SEXP combineGenotypes(SEXP Rfinals, SEXP RhetData) 3 | { 4 | BEGIN_RCPP 5 | Rcpp::IntegerMatrix finals; 6 | try 7 | { 8 | finals = Rfinals; 9 | } 10 | catch(Rcpp::not_compatible&) 11 | { 12 | throw std::runtime_error("Input finals must be an integer matrix"); 13 | } 14 | Rcpp::List hetData; 15 | try 16 | { 17 | hetData = RhetData; 18 | } 19 | catch(Rcpp::not_compatible&) 20 | { 21 | throw std::runtime_error("Input hetData must be an S4 object"); 22 | } 23 | int nLines = finals.nrow(); 24 | int nMarkers = finals.ncol()/2; 25 | Rcpp::IntegerMatrix result(nLines, nMarkers); 26 | for(Rcpp::List::iterator markerIterator = hetData.begin(); markerIterator != hetData.end(); markerIterator++) 27 | { 28 | Rcpp::IntegerMatrix hetDataThisMarker = *markerIterator; 29 | int markerIndex = std::distance(hetData.begin(), markerIterator); 30 | int hetDataRows = hetDataThisMarker.nrow(); 31 | for(int lineCounter = 0; lineCounter < nLines; lineCounter++) 32 | { 33 | int allele1 = finals(lineCounter, markerIndex), allele2 = finals(lineCounter, markerIndex+nMarkers); 34 | int i = 0; 35 | for(; i < hetDataRows; i++) 36 | { 37 | if(hetDataThisMarker(i, 0) == allele1 && hetDataThisMarker(i, 1) == allele2) 38 | { 39 | result(lineCounter, markerIndex) = hetDataThisMarker(i, 2); 40 | break; 41 | } 42 | } 43 | if(i == hetDataRows) 44 | { 45 | throw std::runtime_error("Invalid marker encoding found. Please validate the input object using validObject."); 46 | } 47 | } 48 | } 49 | return Rcpp::wrap(result); 50 | END_RCPP 51 | } 52 | 53 | -------------------------------------------------------------------------------- /src/combineGenotypes.h: -------------------------------------------------------------------------------- 1 | #ifndef COMBINE_GENOTYPES_HEADER_GUARD 2 | #define COMBINE_GENOTYPES_HEADER_GUARD 3 | #include 4 | RcppExport SEXP combineGenotypes(SEXP Rfinals, SEXP RhetData); 5 | #endif 6 | 7 | -------------------------------------------------------------------------------- /src/combineRFDisjoint.h: -------------------------------------------------------------------------------- 1 | #ifndef COMBINE_RF_DISJOINT_HEADER_GUARD 2 | #define COMBINE_RF_DISJOINT_HEADER_GUARD 3 | #include 4 | RcppExport SEXP combineRFDisjoint(SEXP rf1, SEXP rf2); 5 | #endif 6 | -------------------------------------------------------------------------------- /src/compressedProbabilities.cpp: -------------------------------------------------------------------------------- 1 | #include "compressedProbabilities.h" 2 | const int compressedProbabilities<2, true>::nDifferentProbs; 3 | const int compressedProbabilities<2, false>::nDifferentProbs; 4 | const int compressedProbabilities<4, true>::nDifferentProbs; 5 | const int compressedProbabilities<4, false>::nDifferentProbs; 6 | const int compressedProbabilities<8, true>::nDifferentProbs; 7 | const int compressedProbabilities<8, false>::nDifferentProbs; 8 | const int compressedProbabilities<16, true>::nDifferentProbs; 9 | const int compressedProbabilities<16, false>::nDifferentProbs; 10 | -------------------------------------------------------------------------------- /src/compressedProbabilities.h: -------------------------------------------------------------------------------- 1 | template struct compressedProbabilities; 2 | template<> struct compressedProbabilities<2, true> 3 | { 4 | static const int nDifferentProbs = 2; 5 | }; 6 | template<> struct compressedProbabilities<2, false> 7 | { 8 | static const int nDifferentProbs = 5; 9 | }; 10 | template<> struct compressedProbabilities<4, true> 11 | { 12 | static const int nDifferentProbs = 3; 13 | }; 14 | template<> struct compressedProbabilities<4, false> 15 | { 16 | static const int nDifferentProbs = 18; 17 | }; 18 | template<> struct compressedProbabilities<8, true> 19 | { 20 | static const int nDifferentProbs = 3; 21 | }; 22 | template<> struct compressedProbabilities<8, false> 23 | { 24 | static const int nDifferentProbs = 46; 25 | }; 26 | template<> struct compressedProbabilities<16, true> 27 | { 28 | static const int nDifferentProbs = 4; 29 | }; 30 | template<> struct compressedProbabilities<16, false> 31 | { 32 | static const int nDifferentProbs = 95; 33 | }; 34 | -------------------------------------------------------------------------------- /src/compressedProbabilities_RInterface.h: -------------------------------------------------------------------------------- 1 | #ifndef COMPRESSED_PROBABILITIES_HEADER_GUARD_R_INTERFACE 2 | #define COMPRESSED_PROBABILITIES_HEADER_GUARD_R_INTERFACE 3 | #include 4 | SEXP compressedProbabilities_RInterface(SEXP nFounders, SEXP r, SEXP nFunnels, SEXP intercrossingGenerations, SEXP selfingGenerations, SEXP infiniteSelfing); 5 | #endif 6 | -------------------------------------------------------------------------------- /src/computeAllEpistaticChiSquared.h: -------------------------------------------------------------------------------- 1 | #ifndef COMPUTE_ALL_EPISTATIC_CHI_SQUARED_PROB_HEADER_GUARD 2 | #define COMPUTE_ALL_EPISTATIC_CHI_SQUARED_PROB_HEADER_GUARD 3 | #include 4 | SEXP computeAllEpistaticChiSquared(SEXP probabilities, SEXP nFounders, SEXP infiniteSelfing, SEXP showProgress); 5 | #endif 6 | -------------------------------------------------------------------------------- /src/computeGenotypeProbabilities.h: -------------------------------------------------------------------------------- 1 | #ifndef COMPUTE_GENOTYPE_PROBABILITIES_HEADER_GUARD 2 | #define COMPUTE_GENOTYPE_PROBABILITIES_HEADER_GUARD 3 | #include "Rcpp.h" 4 | SEXP computeGenotypeProbabilities(SEXP geneticData_sexp, SEXP map_sexp, SEXP homozygoteMissingProb_sexp, SEXP hetrozygoteMissingProb_sexp, SEXP errorProb_sexp, SEXP extraPositions_sexp); 5 | #endif 6 | -------------------------------------------------------------------------------- /src/convertGeneticData.cpp: -------------------------------------------------------------------------------- 1 | #include "convertGeneticData.h" 2 | void convertGeneticData(Rcpp::S4 obj) 3 | { 4 | Rcpp::RObject finals = obj.slot("finals"); 5 | Rcpp::Function convert("storage.mode<-"); 6 | if(finals.sexp_type() == REALSXP) 7 | { 8 | finals = obj.slot("finals") = convert(finals, "integer"); 9 | } 10 | Rcpp::RObject founders = obj.slot("founders"); 11 | if(founders.sexp_type() == REALSXP) 12 | { 13 | founders = obj.slot("founders") = convert(founders, "integer"); 14 | } 15 | Rcpp::List hetData = obj.slot("hetData"); 16 | for(int i = 0; i < hetData.size(); i++) 17 | { 18 | if(Rcpp::as(hetData(i)).sexp_type() == REALSXP) 19 | { 20 | hetData(i) = convert(Rcpp::as(hetData(i)), "integer"); 21 | } 22 | } 23 | } 24 | 25 | -------------------------------------------------------------------------------- /src/convertGeneticData.h: -------------------------------------------------------------------------------- 1 | #ifndef CONVERT_GENETIC_DATA_HEADER_GUARD 2 | #define CONVERT_GENETIC_DATA_HEADER_GUARD 3 | #include 4 | void convertGeneticData(Rcpp::S4 obj); 5 | #endif 6 | 7 | -------------------------------------------------------------------------------- /src/crc32.h: -------------------------------------------------------------------------------- 1 | #ifndef CRC_32_HEADER_GUARD 2 | #define CRC_32_HEADER_GUARD 3 | #include 4 | #include 5 | uint32_t crc32(const void* data, std::size_t length, uint32_t previousCrc32 = 0); 6 | #endif 7 | -------------------------------------------------------------------------------- /src/dspMatrix.cpp: -------------------------------------------------------------------------------- 1 | #include "dspMatrix.h" 2 | #include "matrixChunks.h" 3 | SEXP assignDspMatrixFromEstimateRF(SEXP destination_, SEXP rowIndices_, SEXP columnIndices_, SEXP source_) 4 | { 5 | BEGIN_RCPP 6 | Rcpp::S4 destination = destination_; 7 | Rcpp::NumericVector source = source_; 8 | Rcpp::NumericVector destinationData = destination.slot("x"); 9 | Rcpp::IntegerVector rowIndices = rowIndices_; 10 | Rcpp::IntegerVector columnIndices = columnIndices_; 11 | 12 | if(&(source(0)) == &(destinationData(0))) 13 | { 14 | throw std::runtime_error("Source and destination cannot be the same in assignRawSymmetricMatrixDiagonal"); 15 | } 16 | 17 | std::vector markerRows, markerColumns; 18 | markerRows = Rcpp::as >(rowIndices); 19 | markerColumns = Rcpp::as >(columnIndices); 20 | if(countValuesToEstimate(markerRows, markerColumns) != (unsigned long long)source.size()) 21 | { 22 | throw std::runtime_error("Mismatch between index length and source object size"); 23 | } 24 | 25 | triangularIterator iterator(markerRows, markerColumns); 26 | int counter = 0; 27 | for(; !iterator.isDone(); iterator.next()) 28 | { 29 | std::pair markerPair = iterator.get(); 30 | int markerRow = markerPair.first, markerColumn = markerPair.second; 31 | destinationData((markerColumn*(markerColumn-1))/2 + (markerRow - 1)) = source(counter); 32 | counter++; 33 | } 34 | return R_NilValue; 35 | END_RCPP 36 | } 37 | -------------------------------------------------------------------------------- /src/dspMatrix.h: -------------------------------------------------------------------------------- 1 | #ifndef DSP_MATRIX_HEADER_GUARD 2 | #define DSP_MATRIX_HEADER_GUARD 3 | #include 4 | SEXP assignDspMatrixFromEstimateRF(SEXP destination, SEXP rowIndices, SEXP columnIndices, SEXP source); 5 | #endif 6 | -------------------------------------------------------------------------------- /src/eightParentPedigreeImproperFunnels.h: -------------------------------------------------------------------------------- 1 | #ifndef EIGHT_PARENT_PEDIGREE_IMPROPER_FUNNELS_HEADER_GUARD 2 | #define EIGHT_PARENT_PEDIGREE_IMPROPER_FUNNELS_HEADER_GUARD 3 | #include 4 | SEXP eightParentPedigreeImproperFunnels(SEXP initialPopulationSize_sexp, SEXP selfingGenerations_sexp, SEXP nSeeds_sexp); 5 | #endif 6 | -------------------------------------------------------------------------------- /src/eightParentPedigreeRandomFunnels.h: -------------------------------------------------------------------------------- 1 | #ifndef EIGHT_PARENT_PEDIGREE_RANDOM_FUNNELS_HEADER_GUARD 2 | #define EIGHT_PARENT_PEDIGREE_RANDOM_FUNNELS_HEADER_GUARD 3 | #include 4 | SEXP eightParentPedigreeRandomFunnels(SEXP initialPopulationSize_sexp, SEXP selfingGenerations_sexp, SEXP nSeeds_sexp, SEXP intercrossingGenerations_sexp); 5 | #endif 6 | -------------------------------------------------------------------------------- /src/eightParentPedigreeSingleFunnel.h: -------------------------------------------------------------------------------- 1 | #ifndef EIGHT_PARENT_PEDIGREE_SINGLE_FUNNEL_HEADER_GUARD 2 | #define EIGHT_PARENT_PEDIGREE_SINGLE_FUNNEL_HEADER_GUARD 3 | #include 4 | SEXP eightParentPedigreeSingleFunnel(SEXP initialPopulationSize_sexp, SEXP selfingGenerations_sexp, SEXP nSeeds_sexp, SEXP intercrossingGenerations_sexp); 5 | #endif 6 | -------------------------------------------------------------------------------- /src/estimateRF.h: -------------------------------------------------------------------------------- 1 | #ifndef _RFHAPS_H 2 | #define _RFHAPS_H 3 | #include 4 | struct funnelType 5 | { 6 | int val[16]; 7 | }; 8 | /** Estimate pairwise recombination fractions 9 | * 10 | * Estimate pairwise recombination fractions using numerical maximum likelihood 11 | * @param object The mpcross object to use 12 | * @param recombinationFractions The recombination fractions to test. Must be given in increasing order. 13 | * @param markerRows The rows of markers (as a pair of indices) which we wish to consider 14 | * @param markerColumns The columns of markers (as a pair of indices) which we wish to consider 15 | * @param lineWeights The line weights, in case we wish to correct for some kind of distortion 16 | * @param keepLod Boolean telling whether or not to return the likelihood ratio statistic for testing the estimated value being different from 0. 17 | * @param gbLimit The number of gigabytes to use for the results matrix. A value of negative 1 indicates no limit. 18 | * @param keepLkhd Boolean telling whether or not to return the maximum likelihood value 19 | * @param verbose Boolean telling whether or not to output diagnostic and progress information 20 | * @return A list returning the specified data. In the case of theta, the values are returned as a raw vector. Each entry is an index into the possible recombination fractions. This saves us a factor of 8 in terms of memory usage. The raw vector is indexed column-major, but only contains the values for the upper triangular part of the matrix. 21 | **/ 22 | SEXP estimateRF(SEXP object, SEXP recombinationFractions, SEXP markerRows, SEXP markerColumns, SEXP lineWeights, SEXP keepLod, SEXP keepLkhd, SEXP gbLimit, SEXP verbose); 23 | #endif 24 | -------------------------------------------------------------------------------- /src/estimateRFCheckFunnels.h: -------------------------------------------------------------------------------- 1 | #ifndef ESTIMATE_RF_CHECK_FUNNELS_HEADER_GUARD 2 | #define ESTIMATE_RF_CHECK_FUNNELS_HEADER_GUARD 3 | #include 4 | #include 5 | #include 6 | #include "estimateRF.h" 7 | void getAICParentLines(Rcpp::IntegerVector& mother, Rcpp::IntegerVector& father, long pedigreeRow, int intercrossingGenerations, std::vector& individualsToCheckFunnels); 8 | void estimateRFCheckFunnels(Rcpp::IntegerMatrix finals, Rcpp::IntegerMatrix founders, Rcpp::List hetData, Rcpp::S4 pedigree, std::vector& intercrossingGenerations, std::vector& warnings, std::vector& errors, std::vector& allFunnels, std::vector& lineFunnels); 9 | #endif 10 | -------------------------------------------------------------------------------- /src/estimateRFSingleDesign.h: -------------------------------------------------------------------------------- 1 | #ifndef ESTIMATE_RF_SINGLE_DESIGN_HEADER_GUARD 2 | #define ESTIMATE_RF_SINGLE_DESIGN_HEADER_GUARD 3 | #include 4 | SEXP estimateRFSingleDesign(SEXP object, SEXP recombinationFractions, SEXP markerRows, SEXP markerColumns, SEXP lineWeights, SEXP keepLod, SEXP keepLkhd, SEXP verbose); 5 | #endif 6 | -------------------------------------------------------------------------------- /src/expandedProbabilities_RInterface.h: -------------------------------------------------------------------------------- 1 | #ifndef EXPANDED_PROBABILITIES_INFINITE_HEADER_GUARD_R_INTERFACE 2 | #define EXPANDED_PROBABILITIES_INFINITE_HEADER_GUARD_R_INTERFACE 3 | #include 4 | SEXP expandedProbabilitiesInfinite_RInterface(SEXP nFounders, SEXP r, SEXP nFunnels, SEXP intercrossingGenerations); 5 | SEXP expandedProbabilitiesFinite_RInterface(SEXP nFounders_sexp, SEXP r_sexp, SEXP nFunnels_sexp, SEXP intercrossingGenerations_sexp, SEXP selfingGenerations_sexp, SEXP phased_sexp); 6 | #endif 7 | -------------------------------------------------------------------------------- /src/forwardsBackwards.h: -------------------------------------------------------------------------------- 1 | #ifndef FORWARDS_BACKWARDS_HEADER_GUARD 2 | #define FORWARDS_BACKWARDS_HEADER_GUARD 3 | template struct forwardsBackwardsAlgorithm; 4 | #include "forwardsBackwardsInfiniteSelfing.h" 5 | #include "forwardsBackwardsFiniteSelfing.h" 6 | #endif 7 | -------------------------------------------------------------------------------- /src/fourParentPedigreeRandomFunnels.h: -------------------------------------------------------------------------------- 1 | #ifndef FOUR_PARENT_PEDIGREE_RANDOM_FUNNELS_HEADER_GUARD 2 | #define FOUR_PARENT_PEDIGREE_RANDOM_FUNNELS_HEADER_GUARD 3 | #include "Rcpp.h" 4 | SEXP fourParentPedigreeRandomFunnels(SEXP initialPopulationSize_sexp, SEXP selfingGenerations_sexp, SEXP nSeeds_sexp, SEXP intercrossingGenerations_sexp); 5 | #endif 6 | -------------------------------------------------------------------------------- /src/fourParentPedigreeSingleFunnel.h: -------------------------------------------------------------------------------- 1 | #ifndef FOUR_PARENT_PEDIGREE_SINGLE_FUNNEL_HEADER_GUARD 2 | #define FOUR_PARENT_PEDIGREE_SINGLE_FUNNEL_HEADER_GUARD 3 | #include "Rcpp.h" 4 | SEXP fourParentPedigreeSingleFunnel(SEXP initialPopulationSize_sexp, SEXP selfingGenerations_sexp, SEXP nSeeds_sexp, SEXP intercrossingGenerations_sexp); 5 | #endif 6 | -------------------------------------------------------------------------------- /src/funnelHaplotypeToMarker.h: -------------------------------------------------------------------------------- 1 | #ifndef FUNNEL_HAPLOTYPE_TO_MARKER_HEADER_GUARD 2 | #define FUNNEL_HAPLOTYPE_TO_MARKER_HEADER_GUARD 3 | template struct funnelHaplotypeToMarker; 4 | #include "funnelHaplotypeToMarkerInfiniteSelfing.h" 5 | #include "funnelHaplotypeToMarkerFiniteSelfing.h" 6 | #endif 7 | -------------------------------------------------------------------------------- /src/funnelsToUniqueValues.h: -------------------------------------------------------------------------------- 1 | #ifndef FUNNELS_TO_UNIQUE_VALUES_HEADER_GUARD 2 | #define FUNNELS_TO_UNIQUE_VALUES_HEADER_GUARD 3 | #include 4 | #include 5 | #include "estimateRF.h" 6 | #include "unitTypes.h" 7 | void funnelsToUniqueValues(std::map& funnelTranslation, std::vector& lineFunnelIDs, std::vector& lineFunnelEncodings, std::vector& allFunnelEncodings, std::vector& lineFunnels, std::vector& allFunnels, int nFounders); 8 | #endif 9 | -------------------------------------------------------------------------------- /src/generateDesignMatrix.cpp: -------------------------------------------------------------------------------- 1 | #include "generateDesignMatrix.h" 2 | SEXP generateDesignMatrix(SEXP n_, SEXP maxOffset_) 3 | { 4 | BEGIN_RCPP 5 | int n; 6 | try 7 | { 8 | n = Rcpp::as(n_); 9 | } 10 | catch(...) 11 | { 12 | throw std::runtime_error("Input n must be an integer"); 13 | } 14 | 15 | int maxOffset; 16 | try 17 | { 18 | maxOffset = Rcpp::as(maxOffset_); 19 | } 20 | catch(...) 21 | { 22 | throw std::runtime_error("Input maxOffset must be an integer"); 23 | } 24 | if(maxOffset > n) 25 | { 26 | throw std::runtime_error("Input maxOffset cannot be larger than n"); 27 | } 28 | int resultRows = n*maxOffset - maxOffset*(maxOffset - 1)/2; 29 | Rcpp::IntegerMatrix result(resultRows, n); 30 | memset(&(result(0, 0)), 0, sizeof(int) * n * resultRows); 31 | 32 | for(int i = 0; i < n; i++) 33 | { 34 | int offset = 0; 35 | //j is the section going by rows 36 | for(int j = 0; j < maxOffset; j++) 37 | { 38 | int end = std::min(n - j-1, i) + 1; 39 | for(int k = std::max(0, i-j); k < end; k++) result(offset + k, i) = 1; 40 | offset = offset + (n-j); 41 | } 42 | } 43 | return result; 44 | END_RCPP 45 | } 46 | -------------------------------------------------------------------------------- /src/generateDesignMatrix.h: -------------------------------------------------------------------------------- 1 | #ifndef GENERATE_DESIGN_MATRIX_HEADER_GUARD 2 | #define GENERATE_DESIGN_MATRIX_HEADER_GUARD 3 | #include 4 | SEXP generateDesignMatrix(SEXP n, SEXP maxOffset); 5 | #endif 6 | -------------------------------------------------------------------------------- /src/generateGenotypes.h: -------------------------------------------------------------------------------- 1 | #ifndef GENERATE_GENOTYPES_HEADER_GUARD 2 | #define GENERATE_GENOTYPES_HEADER_GUARD 3 | #include 4 | RcppExport SEXP generateGenotypes(SEXP RrecombinationFractions, SEXP RmarkerNames, SEXP Rpedigree); 5 | #endif 6 | 7 | -------------------------------------------------------------------------------- /src/generateKeys.cpp: -------------------------------------------------------------------------------- 1 | #include "generateKeys.h" 2 | void generateKeys(Rcpp::IntegerMatrix& key, Rcpp::IntegerMatrix& outputKey, int nFounders, bool infiniteSelfing) 3 | { 4 | key = Rcpp::IntegerMatrix(nFounders, nFounders); 5 | for(int i = 0; i < nFounders; i++) 6 | { 7 | key(i, i) = i + 1; 8 | } 9 | int counter = nFounders+1; 10 | for(int i = 0; i < nFounders; i++) 11 | { 12 | for(int j = i+1; j < nFounders; j++) 13 | { 14 | key(j, i) = key(i, j) = counter; 15 | counter++; 16 | } 17 | } 18 | //We also want a version closer to the hetData format 19 | if(infiniteSelfing) 20 | { 21 | outputKey = Rcpp::IntegerMatrix(nFounders, 3); 22 | for(int i = 0; i < nFounders; i++) 23 | { 24 | outputKey(i, 0) = i+1; 25 | outputKey(i, 1) = i+1; 26 | outputKey(i, 2) = key(i, i); 27 | } 28 | } 29 | else 30 | { 31 | outputKey = Rcpp::IntegerMatrix(nFounders*nFounders, 3); 32 | int counter = 0; 33 | for(int i = 0; i < nFounders; i++) 34 | { 35 | for(int j = 0; j < nFounders; j++) 36 | { 37 | outputKey(counter, 0) = i+1; 38 | outputKey(counter, 1) = j+1; 39 | outputKey(counter, 2) = key(i, j); 40 | counter++; 41 | } 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/generateKeys.h: -------------------------------------------------------------------------------- 1 | #ifndef GENERATE_KEYS_HEADER_GUARD 2 | #define GENERATE_KEYS_HEADER_GUARD 3 | #include 4 | void generateKeys(Rcpp::IntegerMatrix& key, Rcpp::IntegerMatrix& outputKey, int nFounders, bool infiniteSelfing); 5 | #endif 6 | 7 | -------------------------------------------------------------------------------- /src/getAllFunnels.h: -------------------------------------------------------------------------------- 1 | #ifndef GET_ALL_FUNNELS_HEADER_GUARD 2 | #define GET_ALL_FUNNELS_HEADER_GUARD 3 | #include 4 | SEXP getAllFunnels(SEXP geneticData, SEXP standardised); 5 | #endif 6 | -------------------------------------------------------------------------------- /src/getAllFunnelsIncAIC.h: -------------------------------------------------------------------------------- 1 | #ifndef GET_ALL_FUNNELS_INC_AIC_HEADER_GUARD 2 | #define GET_ALL_FUNNELS_INC_AIC_HEADER_GUARD 3 | #include 4 | SEXP getAllFunnelsIncAIC(SEXP geneticData, SEXP standardised); 5 | #endif 6 | -------------------------------------------------------------------------------- /src/getFunnel.h: -------------------------------------------------------------------------------- 1 | #ifndef GET_FUNNEL_HEADER_GUARD 2 | #define GET_FUNNEL_HEADER_GUARD 3 | #include 4 | void getFunnel(long line, Rcpp::IntegerVector& mother, Rcpp::IntegerVector& father, int* funnel, int nFounders); 5 | #endif 6 | 7 | -------------------------------------------------------------------------------- /src/getMinAIGenerations.cpp: -------------------------------------------------------------------------------- 1 | #include "getMinAIGenerations.h" 2 | #include 3 | int getMinAIGenerations(const std::vector* intercrossingGenerations) 4 | { 5 | int minAIGenerations = 0; 6 | for(std::vector::const_iterator i = intercrossingGenerations->begin(); i != intercrossingGenerations->end(); i++) 7 | { 8 | if(*i != 0) 9 | { 10 | if(minAIGenerations == 0) minAIGenerations = *i; 11 | else minAIGenerations = std::min(minAIGenerations, *i); 12 | } 13 | } 14 | minAIGenerations = std::max(minAIGenerations, 1); 15 | return minAIGenerations; 16 | } 17 | -------------------------------------------------------------------------------- /src/getMinAIGenerations.h: -------------------------------------------------------------------------------- 1 | #ifndef GET_MIN_AI_GENERATIONS_HEADER_GUARD 2 | #define GET_MIN_AI_GENERATIONS_HEADER_GUARD 3 | #include 4 | int getMinAIGenerations(const std::vector* intercrossingGenerations); 5 | #endif 6 | 7 | -------------------------------------------------------------------------------- /src/haldaneToRf.cpp: -------------------------------------------------------------------------------- 1 | #include "haldaneToRf.h" 2 | #include 3 | void haldaneToRf(const std::vector& inputs, std::vector& outputs) 4 | { 5 | outputs.clear(); 6 | for(std::vector::const_iterator i = inputs.begin(); i != inputs.end(); i++) 7 | { 8 | outputs.push_back(0.5*(1.0 - std::exp(-2.0 * *i / 100.0))); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/haldaneToRf.h: -------------------------------------------------------------------------------- 1 | #ifndef HALDANE_TO_RF_HEADER_GUARD 2 | #define HALDANE_TO_RF_HEADER_GUARD 3 | #include 4 | void haldaneToRf(const std::vector& inputs, std::vector& outputs); 5 | #endif 6 | -------------------------------------------------------------------------------- /src/hclustMatrices.h: -------------------------------------------------------------------------------- 1 | #ifndef HCLUST_MATRICES_HEADER_GUARD 2 | #define HCLUST_MATRICES_HEADER_GUARD 3 | #include 4 | SEXP hclustCombinedMatrix(SEXP preClusterResults, SEXP mpcrossRF); 5 | SEXP hclustThetaMatrix(SEXP preClusterResults, SEXP mpcrossRF); 6 | SEXP hclustLodMatrix(SEXP preClusterResults, SEXP mpcrossRF); 7 | #endif 8 | -------------------------------------------------------------------------------- /src/identC.cpp: -------------------------------------------------------------------------------- 1 | #include "Rcpp.h" 2 | //Copied from the methods package 3 | Rcpp::RObject identC_(SEXP e1, SEXP e2) 4 | { 5 | if(TYPEOF(e1) == STRSXP && TYPEOF(e2) == STRSXP && 6 | LENGTH(e1) == 1 && LENGTH(e2) == 1 && 7 | STRING_ELT(e1, 0) == STRING_ELT(e2, 0)) 8 | return Rcpp::wrap(true); 9 | else 10 | return Rcpp::wrap(false); 11 | } 12 | SEXP identC(SEXP e1, SEXP e2) 13 | { 14 | return identC_(e1, e2); 15 | } 16 | 17 | -------------------------------------------------------------------------------- /src/identC.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Rcpp.h" 3 | //Copied from the methods package 4 | SEXP identC(SEXP e1, SEXP e2); 5 | -------------------------------------------------------------------------------- /src/impossibleDataException.h: -------------------------------------------------------------------------------- 1 | #ifndef IMPOSSIBLE_DATA_EXCEPTION_HEADER_GUARD 2 | #define IMPOSSIBLE_DATA_EXCEPTION_HEADER_GUARD 3 | #include 4 | class impossibleDataException : public std::runtime_error 5 | { 6 | public: 7 | impossibleDataException(int marker, int line) 8 | : std::runtime_error("Data is impossible for the given map"), marker(marker), line(line) 9 | {} 10 | int marker, line; 11 | }; 12 | #endif 13 | -------------------------------------------------------------------------------- /src/impute.h: -------------------------------------------------------------------------------- 1 | #ifndef IMPUTE_HEADER_GUARD_MPMAP2 2 | #define IMPUTE_HEADER_GUARD_MPMAP2 3 | #include 4 | #include 5 | #include 6 | #include 7 | bool impute(const unsigned char* originalTheta, unsigned char* imputedTheta, std::vector& thetaLevels, double* lod, double* lkhd, std::vector& markers, std::function statusFunction, bool allErrors, std::vector >& reportedErrors); 8 | SEXP imputeGroup(SEXP mpcrossLG_sexp, SEXP verbose_sexp, SEXP group_sexp, SEXP allErrors); 9 | #endif 10 | -------------------------------------------------------------------------------- /src/imputeFounders.h: -------------------------------------------------------------------------------- 1 | #ifndef IMPUTE_FOUNDERS_HEADER_GUARD 2 | #define IMPUTE_FOUNDERS_HEADER_GUARD 3 | #include "Rcpp.h" 4 | SEXP imputeFounders(SEXP geneticData_sexp, SEXP map_sexp, SEXP homozygoteMissingProb_sexp, SEXP hetrozygoteMissingProb_sexp, SEXP errorProb_sexp, SEXP extraPositions_sexp, SEXP showProgress_sexp); 5 | #endif 6 | -------------------------------------------------------------------------------- /src/intercrossingAndSelfingGenerations.h: -------------------------------------------------------------------------------- 1 | #ifndef INTERCROSSING_AND_SELFING_GENERATIONS_HEADER 2 | #define INTERCROSSING_AND_SELFING_GENERATIONS_HEADER 3 | #include 4 | #include 5 | //Work out the number of intercrossing generations for each individual in the final population 6 | SEXP getIntercrossingAndSelfingGenerationsExport(SEXP pedigree_sexp, SEXP finals_sexp); 7 | bool getIntercrossingAndSelfingGenerations(Rcpp::S4 pedigree, Rcpp::IntegerMatrix finals, int nFounders, std::vector& intecrossing, std::vector& selfing); 8 | #endif 9 | -------------------------------------------------------------------------------- /src/intercrossingHaplotypeToMarker.h: -------------------------------------------------------------------------------- 1 | #ifndef INTERCROSSING_HAPLOTYPE_TO_MARKER_HEADER_GUARD 2 | #define INTERCROSSING_HAPLOTYPE_TO_MARKER_HEADER_GUARD 3 | template struct intercrossingHaplotypeToMarker; 4 | #include "intercrossingHaplotypeToMarkerInfiniteSelfing.h" 5 | #include "intercrossingHaplotypeToMarkerFiniteSelfing.h" 6 | #endif 7 | -------------------------------------------------------------------------------- /src/joinMapWithExtra.h: -------------------------------------------------------------------------------- 1 | #ifndef JOIN_MAP_WITH_EXTRA_HEADER_GUARD 2 | #define JOIN_MAP_WITH_EXTRA_HEADER_GUARD 3 | #include 4 | struct positionData 5 | { 6 | Rcpp::List makeUnifiedMap(); 7 | struct chromosomeDescriptor 8 | { 9 | int start, end; 10 | std::string name; 11 | }; 12 | std::vector names; 13 | std::vector positions; 14 | std::vector markerIndices; 15 | std::vector chromosomes; 16 | }; 17 | void joinMapWithExtra(Rcpp::List map, Rcpp::List extraPositions, positionData& allPositions); 18 | #endif 19 | -------------------------------------------------------------------------------- /src/mapFunctions.cpp: -------------------------------------------------------------------------------- 1 | #include "mapFunctions.h" 2 | #include 3 | double haldaneToRf(double x) 4 | { 5 | return 0.5 * (1 - std::exp(-2 * x/100)); 6 | } 7 | 8 | -------------------------------------------------------------------------------- /src/mapFunctions.h: -------------------------------------------------------------------------------- 1 | #ifndef MAP_FUNCTIONS_HEADER_GUARD 2 | #define MAP_FUNCTIONS_HEADER_GUARD 3 | double haldaneToRf(double x); 4 | #endif 5 | -------------------------------------------------------------------------------- /src/markerPatternsToUniqueValues.h: -------------------------------------------------------------------------------- 1 | #ifndef MARKER_PATTERNS_TO_UNIQUE_VALUES 2 | #define MARKER_PATTERNS_TO_UNIQUE_VALUES 3 | #include 4 | #include 5 | #include 6 | #include "unitTypes.h" 7 | #include "matrices.h" 8 | #include "crc32.h" 9 | struct markerData 10 | { 11 | public: 12 | markerData(int nFounders); 13 | bool operator<(const markerData& other) const; 14 | void computeHash() const; 15 | rowMajorMatrix hetData; 16 | int nObservedValues; 17 | markerData(const markerData& other) 18 | :nObservedValues(other.nObservedValues), hashed(other.hashed), hash(other.hash) 19 | { 20 | hetData = other.hetData.copy(); 21 | } 22 | private: 23 | mutable bool hashed; 24 | mutable int hash; 25 | }; 26 | struct markerPatternsToUniqueValuesArgs 27 | { 28 | public: 29 | std::map markerPatterns; 30 | std::vector markerPatternIDs; 31 | std::vector allMarkerPatterns; 32 | int nFounders; 33 | int nMarkers; 34 | Rcpp::IntegerMatrix recodedFounders; 35 | Rcpp::List recodedHetData; 36 | void swap(markerPatternsToUniqueValuesArgs& other); 37 | }; 38 | void markerPatternsToUniqueValues(markerPatternsToUniqueValuesArgs& args); 39 | #endif 40 | -------------------------------------------------------------------------------- /src/matrix.h: -------------------------------------------------------------------------------- 1 | #ifndef MATRIX_HEADER_GUARD 2 | #define MATRIX_HEADER_GUARD 3 | struct integerMatrix 4 | { 5 | public: 6 | integerMatrix(const integerMatrix& mat) 7 | : data(mat.data), nRow(mat.nRow), nCol(mat.nCol) 8 | {} 9 | integerMatrix() 10 | : data(NULL), nRow(0), nCol(0) 11 | {} 12 | integerMatrix(int* data, std::size_t nRow, std::size_t nCol) 13 | : data(data), nRow(nRow), nCol(nCol) 14 | {} 15 | integerMatrix(Rcpp::IntegerMatrix mat) 16 | : data(&(mat[0])), nRow(mat.nrow()), nCol(mat.ncol()) 17 | {} 18 | integerMatrix& operator=(Rcpp::IntegerMatrix& mat) 19 | { 20 | data = &(mat[0]); 21 | nRow = mat.nrow(); 22 | nCol = mat.ncol(); 23 | return *this; 24 | } 25 | int& operator()(std::size_t row, std::size_t column) 26 | { 27 | return data[column*nRow + row]; 28 | } 29 | int* data; 30 | std::size_t nRow, nCol; 31 | }; 32 | struct numericMatrix 33 | { 34 | public: 35 | numericMatrix(const numericMatrix& mat) 36 | : data(mat.data), nRow(mat.nRow), nCol(mat.nCol) 37 | {} 38 | numericMatrix() 39 | : data(NULL), nRow(-1), nCol(-1) 40 | {} 41 | numericMatrix(double* data, std::size_t nRow, std::size_t nCol) 42 | : data(data), nRow(nRow), nCol(nCol) 43 | {} 44 | numericMatrix& operator=(Rcpp::NumericMatrix& mat) 45 | { 46 | data = &(mat[0]); 47 | nRow = mat.nrow(); 48 | nCol = mat.ncol(); 49 | return *this; 50 | } 51 | numericMatrix(Rcpp::NumericMatrix mat) 52 | : data(&(mat[0])), nRow(mat.nrow()), nCol(mat.ncol()) 53 | {} 54 | double& operator()(std::size_t row, std::size_t column) 55 | { 56 | return data[column*nRow + row]; 57 | } 58 | double* data; 59 | std::size_t nRow, nCol; 60 | }; 61 | #endif 62 | -------------------------------------------------------------------------------- /src/matrixChunks.h: -------------------------------------------------------------------------------- 1 | #ifndef MATRIX_CHUNKS_HEADER_GUARD 2 | #define MATRIX_CHUNKS_HEADER_GUARD 3 | #include 4 | #include 5 | class triangularIterator 6 | { 7 | public: 8 | triangularIterator(const std::vector& markerRows, const std::vector& markerColumns); 9 | std::pair get() const; 10 | void next(); 11 | bool isDone() const; 12 | triangularIterator& operator=(const triangularIterator& other); 13 | private: 14 | const std::vector& markerRows; 15 | const std::vector& markerColumns; 16 | std::vector::const_iterator markerRow, markerColumn; 17 | }; 18 | class triangularIteratorPredicates 19 | { 20 | public: 21 | triangularIteratorPredicates(const std::vector& markerRows, const std::vector& markerColumns, std::function predicate, std::function jointPredicate); 22 | std::pair get() const; 23 | void next(); 24 | bool isDone() const; 25 | triangularIteratorPredicates& operator=(const triangularIteratorPredicates& other); 26 | unsigned long long getFlatIndex() const; 27 | private: 28 | const std::vector& markerRows; 29 | const std::vector& markerColumns; 30 | std::vector::const_iterator markerRow, markerColumn; 31 | std::function predicate; 32 | std::function jointPredicate; 33 | }; 34 | SEXP countValuesToEstimateExported(SEXP markerRows, SEXP markerColumns); 35 | unsigned long long countValuesToEstimate(const std::vector& markerRows, const std::vector& markerColumns); 36 | SEXP singleIndexToPairExported(SEXP markerRows, SEXP markerColumns, SEXP index); 37 | #endif 38 | -------------------------------------------------------------------------------- /src/mpMap2_openmp.cpp: -------------------------------------------------------------------------------- 1 | #include "mpMap2_openmp.h" 2 | #ifdef _OPENMP 3 | #include 4 | #endif 5 | SEXP mpMap2_omp_set_num_threads(SEXP num) 6 | { 7 | BEGIN_RCPP 8 | #ifdef _OPENMP 9 | int nThreads = Rcpp::as(num); 10 | omp_set_num_threads(nThreads); 11 | return R_NilValue; 12 | #else 13 | throw std::runtime_error("Not built with openmp suppport"); 14 | #endif 15 | END_RCPP 16 | } 17 | SEXP mpMap2_omp_get_num_threads() 18 | { 19 | BEGIN_RCPP 20 | #ifdef _OPENMP 21 | int nThreads = omp_get_num_threads(); 22 | return Rcpp::wrap(nThreads); 23 | #else 24 | throw std::runtime_error("Not built with openmp suppport"); 25 | #endif 26 | END_RCPP 27 | } 28 | -------------------------------------------------------------------------------- /src/mpMap2_openmp.h: -------------------------------------------------------------------------------- 1 | #ifndef MPMAP2_OPENMP_HEADER_GUARD 2 | #define MPMAP2_OPENMP_HEADER_GUARD 3 | #include 4 | SEXP mpMap2_omp_set_num_threads(SEXP num); 5 | SEXP mpMap2_omp_get_num_threads(); 6 | #endif 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/multiparentSNP.h: -------------------------------------------------------------------------------- 1 | #ifndef MULTIPARENT_SNP_HEADER_GUARD 2 | #define MULTIPARENT_SNP_HEADER_GUARD 3 | #include 4 | SEXP multiparentSNPRemoveHets(SEXP object); 5 | SEXP multiparentSNPKeepHets(SEXP object); 6 | #endif 7 | -------------------------------------------------------------------------------- /src/order.h: -------------------------------------------------------------------------------- 1 | #ifndef ORDER_HEADER_GUARD 2 | #define ORDER_HEADER_GUARD 3 | #include 4 | SEXP order(SEXP mpcrossLG, SEXP groupsToOrder, SEXP cool_, SEXP temperatureMin_, SEXP nReps_, SEXP maxMove, SEXP effortMultiplier, SEXP randomStart, SEXP verbose_); 5 | #endif 6 | -------------------------------------------------------------------------------- /src/orderFunnel.h: -------------------------------------------------------------------------------- 1 | #ifndef ORDER_FUNNEL_HEADER_GUARD 2 | #define ORDER_FUNNEL_HEADER_GUARD 3 | void orderFunnel(int* funnel, int nFounders); 4 | #endif 5 | 6 | -------------------------------------------------------------------------------- /src/parsePurdy.h: -------------------------------------------------------------------------------- 1 | #ifndef PARSE_PURDY_HEADER_GUARD 2 | #define PARSE_PURDY_HEADER_GUARD 3 | #include 4 | SEXP parsePurdy(SEXP names, SEXP format); 5 | #endif 6 | -------------------------------------------------------------------------------- /src/preClusterStep.h: -------------------------------------------------------------------------------- 1 | #ifndef PRE_CLUSTER_STEP_HEADER_GUARD 2 | #define PRE_CLUSTER_STEP_HEADER_GUARD 3 | #include 4 | SEXP preClusterStep(SEXP mpcrossRF); 5 | #endif 6 | -------------------------------------------------------------------------------- /src/probabilities16.h: -------------------------------------------------------------------------------- 1 | #ifndef PROBABILITIES_16_HEADER_GUARD 2 | #define PROBABILITIES_16_HEADER_GUARD 3 | #include "probabilities.h" 4 | template<> struct probabilityData<16> 5 | { 6 | public: 7 | static const int intermediateProbabilitiesMask[256][256]; 8 | static const int intermediateAllelesMask[16][16]; 9 | static const int infiniteMask[16][16]; 10 | private: 11 | probabilityData(){} 12 | }; 13 | #endif 14 | -------------------------------------------------------------------------------- /src/probabilities2.h: -------------------------------------------------------------------------------- 1 | #ifndef PROBABILITIES_2_HEADER_GUARD 2 | #define PROBABILITIES_2_HEADER_GUARD 3 | #include "probabilities.h" 4 | template<> struct probabilityData<2> 5 | { 6 | public: 7 | static const int intermediateProbabilitiesMask[4][4]; 8 | static const int intermediateAllelesMask[2][2]; 9 | static const int infiniteMask[2][2]; 10 | private: 11 | probabilityData(){} 12 | }; 13 | #endif 14 | -------------------------------------------------------------------------------- /src/probabilities4.h: -------------------------------------------------------------------------------- 1 | #ifndef PROBABILITIES_4_HEADER_GUARD 2 | #define PROBABILITIES_4_HEADER_GUARD 3 | #include "probabilities.h" 4 | template<> struct probabilityData<4> 5 | { 6 | public: 7 | static const int intermediateProbabilitiesMask[16][16]; 8 | static const int intermediateAllelesMask[4][4]; 9 | static const int infiniteMask[4][4]; 10 | private: 11 | probabilityData(){} 12 | }; 13 | #endif 14 | -------------------------------------------------------------------------------- /src/probabilities8.h: -------------------------------------------------------------------------------- 1 | #ifndef PROBABILITIES_8_HEADER_GUARD 2 | #define PROBABILITIES_8_HEADER_GUARD 3 | #include "probabilities.h" 4 | template<> struct probabilityData<8> 5 | { 6 | public: 7 | static const int intermediateProbabilitiesMask[64][64]; 8 | static const int intermediateAllelesMask[8][8]; 9 | static const int infiniteMask[8][8]; 10 | private: 11 | probabilityData(){} 12 | }; 13 | #endif 14 | -------------------------------------------------------------------------------- /src/rawSymmetricMatrix.h: -------------------------------------------------------------------------------- 1 | #ifndef RAW_SYMMETRIC_MATRIX_HEADER_GUARD 2 | #define RAW_SYMMETRIC_MATRIX_HEADER_GUARD 3 | #include 4 | SEXP rawSymmetricMatrixUncompress(SEXP object_); 5 | SEXP rawSymmetricMatrixSubsetIndices(SEXP object, SEXP i, SEXP j, SEXP drop); 6 | SEXP rawSymmetricMatrixSubsetObject(SEXP object, SEXP indices); 7 | SEXP assignRawSymmetricMatrixFromEstimateRF(SEXP destination, SEXP rowIndices, SEXP columnIndices, SEXP source); 8 | SEXP assignRawSymmetricMatrixDiagonal(SEXP destination, SEXP indices, SEXP source); 9 | SEXP checkRawSymmetricMatrix(SEXP rawSymmetric); 10 | SEXP rawSymmetricMatrixSubsetByMatrix(SEXP object_, SEXP index_); 11 | SEXP rawSymmetricMatrixToDist(SEXP object); 12 | SEXP constructDissimilarityMatrixInternal(unsigned char* data, std::vector& levels, int size, SEXP clusters_, int start, const std::vector& permutation); 13 | SEXP constructDissimilarityMatrix(SEXP object, SEXP clusters); 14 | #endif 15 | -------------------------------------------------------------------------------- /src/recodeFoundersFinalsHets.h: -------------------------------------------------------------------------------- 1 | #ifndef RECODE_FOUNDERS_AND_FINALS_AND_HET_DATA_HEADER_GUARD 2 | #define RECODE_FOUNDERS_AND_FINALS_AND_HET_DATA_HEADER_GUARD 3 | #include 4 | struct recodeDataStruct 5 | { 6 | Rcpp::IntegerMatrix recodedFounders; 7 | Rcpp::IntegerMatrix recodedFinals; 8 | Rcpp::List recodedHetData; 9 | Rcpp::IntegerMatrix founders; 10 | Rcpp::IntegerMatrix finals; 11 | Rcpp::S4 hetData; 12 | unsigned int maxAlleles; 13 | }; 14 | void recodeFoundersFinalsHets(recodeDataStruct& inputs); 15 | #endif 16 | 17 | -------------------------------------------------------------------------------- /src/recodeHetsAsNA.h: -------------------------------------------------------------------------------- 1 | #ifndef RECODE_HETS_AS_NA_HEADER_GUARD 2 | #define RECODE_HETS_AS_NA_HEADER_GUARD 3 | #include 4 | void replaceHetsWithNA(Rcpp::IntegerMatrix recodedFounders, Rcpp::IntegerMatrix recodedFinals, Rcpp::List recodedHetData, bool& hasHets, bool& hasHetEncodings); 5 | #endif 6 | -------------------------------------------------------------------------------- /src/removeHets.h: -------------------------------------------------------------------------------- 1 | #ifndef REMOVE_HETS_HEADER_GUARD 2 | #define REMOVE_HETS_HEADER_GUARD 3 | #include 4 | SEXP removeHets(SEXP founders, SEXP finals, SEXP hetData); 5 | #endif 6 | -------------------------------------------------------------------------------- /src/reorderPedigree.h: -------------------------------------------------------------------------------- 1 | #ifndef REORDER_PEDIGREE_HEADER_GUARD 2 | #define REORDER_PEDIGREE_HEADER_GUARD 3 | #include 4 | #ifdef USE_BOOST 5 | SEXP reorderPedigree(SEXP mother_sexp, SEXP father_sexp, SEXP lineNames_sexp); 6 | #endif 7 | #endif 8 | -------------------------------------------------------------------------------- /src/replaceHetsWithNA.cpp: -------------------------------------------------------------------------------- 1 | #include "recodeHetsAsNA.h" 2 | void replaceHetsWithNA(Rcpp::IntegerMatrix recodedFounders, Rcpp::IntegerMatrix recodedFinals, Rcpp::List recodedHetData, bool& hasHets, bool& hasHetEncodings) 3 | { 4 | int nMarkers = recodedFounders.ncol(); 5 | int nFinals = recodedFinals.nrow(); 6 | hasHets = hasHetEncodings = false; 7 | std::vector isHet(100); 8 | for(int markerCounter = 0; markerCounter < nMarkers; markerCounter++) 9 | { 10 | Rcpp::IntegerMatrix currentMarkerHetData = recodedHetData(markerCounter); 11 | std::fill(isHet.begin(), isHet.end(), true); 12 | for(int hetDataRowCounter = 0; hetDataRowCounter < currentMarkerHetData.nrow(); hetDataRowCounter++) 13 | { 14 | if(currentMarkerHetData(hetDataRowCounter, 0) == currentMarkerHetData(hetDataRowCounter, 1)) 15 | { 16 | isHet[currentMarkerHetData(hetDataRowCounter, 2)] = false; 17 | } 18 | else hasHetEncodings = true; 19 | } 20 | for(int finalCounter = 0; finalCounter < nFinals; finalCounter++) 21 | { 22 | int finalValue = recodedFinals(finalCounter, markerCounter); 23 | if(finalValue != NA_INTEGER && isHet[finalValue]) 24 | { 25 | recodedFinals(finalCounter, markerCounter) = NA_INTEGER; 26 | hasHets = true; 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/singleLocusProbabilities_RInterface.h: -------------------------------------------------------------------------------- 1 | #ifndef SINGLE_LOCUS_PROBABILITIES_HEADER_GUARD_R_INTERFACE 2 | #define SINGLE_LOCUS_PROBABILITIES_HEADER_GUARD_R_INTERFACE 3 | #include 4 | SEXP singleLocusProbabilitiesInfinite_RInterface(SEXP nFounders, SEXP nFunnels, SEXP intercrossingGenerations); 5 | SEXP singleLocusProbabilitiesFinite_RInterface(SEXP nFounders_sexp, SEXP nFunnels_sexp, SEXP intercrossingGenerations_sexp, SEXP selfingGenerations_sexp); 6 | #endif 7 | -------------------------------------------------------------------------------- /src/sixteenParentPedigreeRandomFunnels.h: -------------------------------------------------------------------------------- 1 | #ifndef SIXTEEN_PARENT_PEDIGREE_RANDOM_FUNNELS_HEADER_GUARD 2 | #define SIXTEEN_PARENT_PEDIGREE_RANDOM_FUNNELS_HEADER_GUARD 3 | #include 4 | SEXP sixteenParentPedigreeRandomFunnels(SEXP initialPopulationSize_sexp, SEXP selfingGenerations_sexp, SEXP nSeeds_sexp, SEXP intercrossingGenerations_sexp); 5 | #endif 6 | -------------------------------------------------------------------------------- /src/sortPedigreeLineNames.cpp: -------------------------------------------------------------------------------- 1 | #include "sortPedigreeLineNames.h" 2 | void sortPedigreeLineNames(Rcpp::CharacterVector pedigreeLineNames, std::vector& sortedPedigreeLineNames) 3 | { 4 | sortedPedigreeLineNames.clear(); 5 | sortedPedigreeLineNames.reserve(pedigreeLineNames.size()); 6 | 7 | for(int i = 0; i < pedigreeLineNames.size(); i++) 8 | { 9 | sortedPedigreeLineNames.push_back(pedigreeLineStruct(Rcpp::as(pedigreeLineNames[i]), i)); 10 | } 11 | std::sort(sortedPedigreeLineNames.begin(), sortedPedigreeLineNames.end()); 12 | } 13 | -------------------------------------------------------------------------------- /src/sortPedigreeLineNames.h: -------------------------------------------------------------------------------- 1 | #ifndef SORT_PEDIGREE_LINE_NAMES_HEADER_GUARD 2 | #define SORT_PEDIGREE_LINE_NAMES_HEADER_GUARD 3 | #include 4 | #include 5 | #include 6 | struct pedigreeLineStruct 7 | { 8 | public: 9 | pedigreeLineStruct(std::string lineName, int index) 10 | : lineName(lineName), index(index) 11 | {} 12 | bool operator<(const pedigreeLineStruct& other) const 13 | { 14 | return lineName < other.lineName; 15 | } 16 | std::string lineName; 17 | int index; 18 | }; 19 | void sortPedigreeLineNames(Rcpp::CharacterVector pedigreeLineNames, std::vector& sortedPedigreeLineNames); 20 | #endif 21 | -------------------------------------------------------------------------------- /src/stripPedigree.h: -------------------------------------------------------------------------------- 1 | #ifndef STRIP_PEDIGREE_HEADER_GUARD_MPMAP2 2 | #define STRIP_PEDIGREE_HEADER_GUARD_MPMAP2 3 | #include 4 | #ifdef USE_BOOST 5 | SEXP stripPedigree(SEXP pedigree_sexp, SEXP finalLines_sexp); 6 | #endif 7 | #endif 8 | -------------------------------------------------------------------------------- /src/testDistortion.h: -------------------------------------------------------------------------------- 1 | #ifndef TEST_DISTORTION_HEADER_GUARD 2 | #define TEST_DISTORTION_HEADER_GUARD 3 | #include 4 | SEXP testDistortion(SEXP geneticData); 5 | #endif 6 | -------------------------------------------------------------------------------- /src/transformForMPWGAIM.h: -------------------------------------------------------------------------------- 1 | #ifndef TRANSFORM_FOR_MPWGAIM_HEADER_GUARD 2 | #define TRANSFORM_FOR_MPWGAIM_HEADER_GUARD 3 | #include 4 | SEXP transformForMPWGAIM(SEXP geneticData); 5 | #endif 6 | -------------------------------------------------------------------------------- /src/transposeProbabilities.h: -------------------------------------------------------------------------------- 1 | #ifndef TRANSPOSE_PROBABILITIES_HEADER_GUARD_MPMAP2 2 | #define TRANSPOSE_PROBABILITIES_HEADER_GUARD_MPMAP2 3 | #include 4 | SEXP transposeProbabilities(SEXP geneticData); 5 | #endif 6 | -------------------------------------------------------------------------------- /src/unitTypes.h: -------------------------------------------------------------------------------- 1 | #ifndef UNIT_TYPES_HEADER_GUARD 2 | #define UNIT_TYPES_HEADER_GUARD 3 | template struct Unique 4 | { 5 | V value; 6 | Unique(const V& value = V()) 7 | :value(value) 8 | {} 9 | operator V() const 10 | { 11 | return value; 12 | } 13 | }; 14 | 15 | //The marker pattern ID struct represents a unique identifier, assigned to a particular marker encoding. 16 | struct markerPatternID_imp; 17 | typedef Unique markerPatternID; 18 | 19 | //The funnel encoding struct represents a particular funnel, encoded as a bitfield 20 | struct funnelEncoding_imp; 21 | typedef Unique funnelEncoding; 22 | 23 | //The funnel ID struct representse a unique identifier, assigned to a particular funnel encoding 24 | struct funnelID_imp; 25 | typedef Unique funnelID; 26 | #endif 27 | 28 | -------------------------------------------------------------------------------- /src/viterbi.h: -------------------------------------------------------------------------------- 1 | #ifndef VITERBI_HEADER_GUARD 2 | #define VITERBI_HEADER_GUARD 3 | template struct viterbiAlgorithm; 4 | #include "impossibleDataException.h" 5 | #include "viterbiInfiniteSelfing.h" 6 | #include "viterbiFiniteSelfing.h" 7 | #endif 8 | -------------------------------------------------------------------------------- /src/warnings.cpp: -------------------------------------------------------------------------------- 1 | #include "warnings.h" 2 | std::string hetWarning = "Input data had heterozygotes but was analysed assuming infinite selfing. All heterozygotes were ignored."; 3 | -------------------------------------------------------------------------------- /src/warnings.h: -------------------------------------------------------------------------------- 1 | #ifndef WARNINGS_HEADER_GUARD 2 | #define WARNINGS_HEADER_GUARD 3 | #include 4 | //Warning for the case where there are hets, but we're assuming infinite selfing 5 | extern std::string hetWarning; 6 | #endif 7 | -------------------------------------------------------------------------------- /tests/slow/test-arsaRaw.R: -------------------------------------------------------------------------------- 1 | context("Test multithreading of arsaRaw") 2 | if(class(try(.Call("omp_set_num_threads", 1, PACKAGE="mpMap2"), silent=TRUE)) != "try-error") 3 | { 4 | test_that("Test that correct ordering is generated for an F2 population", 5 | { 6 | f2Pedigree <- f2Pedigree(1000) 7 | map <- qtl::sim.map(len = 100, n.mar = 101, anchor.tel=TRUE, include.x=FALSE, eq.spacing=TRUE) 8 | cross <- simulateMPCross(map=map, pedigree=f2Pedigree, mapFunction = haldane) 9 | cross <- subset(cross, markers = sample(1:101)) 10 | rf <- estimateRF(cross) 11 | grouped <- formGroups(rf, groups = 1, method = "average", clusterBy = "theta") 12 | 13 | .Call("omp_set_num_threads", 1, PACKAGE="mpMap2") 14 | orderedSingleThreaded <- orderCross(grouped) 15 | .Call("omp_set_num_threads", 16, PACKAGE="mpMap2") 16 | orderedMultiThreaded <- orderCross(grouped) 17 | 18 | correlationMultiThreaded <- cor(match(names(map[[1]]), markers(orderedMultiThreaded)), 1:101) 19 | correlationSingleThreaded <- cor(match(names(map[[1]]), markers(orderedSingleThreaded)), 1:101) 20 | expect_equal(abs(correlationMultiThreaded), 1, tolerance = 1e-1) 21 | expect_equal(abs(correlationSingleThreaded), 1, tolerance = 1e-1) 22 | .Call("omp_set_num_threads", 1, PACKAGE="mpMap2") 23 | }) 24 | } 25 | -------------------------------------------------------------------------------- /tests/slow/test-eightParentPedigreeRandomFunnels.R: -------------------------------------------------------------------------------- 1 | context("eightParentPedigreeRandomFunnels") 2 | 3 | test_that("Check that the C and R versions are identical", 4 | { 5 | parameters <- expand.grid(selfingGenerations = 0:3, intercrossingGenerations = 0:3, nSeeds = 1:3) 6 | seed <- 1 7 | apply(parameters, 1, function(x) 8 | { 9 | set.seed(seed) 10 | pedigreeR <- mpMap2:::eightParentPedigreeRandomFunnelsPrototype(selfingGenerations = x["selfingGenerations"], intercrossingGenerations = x["intercrossingGenerations"], initialPopulationSize = 20, nSeeds = x["nSeeds"]) 11 | set.seed(seed) 12 | pedigreeC <- eightParentPedigreeRandomFunnels(selfingGenerations = x["selfingGenerations"], intercrossingGenerations = x["intercrossingGenerations"], initialPopulationSize = 20, nSeeds = x["nSeeds"]) 13 | expect_identical(pedigreeR, pedigreeC) 14 | seed <<- seed + 1 15 | }) 16 | }) 17 | 18 | test_that("Correct number of lines are generated with zero generations of selfing", 19 | { 20 | pedigree <- eightParentPedigreeRandomFunnels(initialPopulationSize = 10, selfingGenerations = 0, intercrossingGenerations = 0) 21 | map <- qtl::sim.map(len = 1, n.mar = 2, anchor.tel = TRUE, include.x=FALSE, eq.spacing=TRUE) 22 | cross <- simulateMPCross(pedigree = pedigree, map = map, mapFunction = haldane, seed =1) 23 | expect_equal(nLines(cross), 10) 24 | }) 25 | -------------------------------------------------------------------------------- /tests/slow/test-estimateRf16Parent.R: -------------------------------------------------------------------------------- 1 | context("estimateRf 16-parent tests") 2 | getMap <- function(distance) 3 | { 4 | map <- list("chr1" = c("a" = 0, "b" = distance)) 5 | class(map)<- "map" 6 | return(map) 7 | } 8 | distances <- c(1, 5, 10, 20, 50) 9 | 10 | test_that("Numerically accurate for randomly chosen funnels", 11 | { 12 | for(intercrossingGenerations in 0:1) 13 | { 14 | for(selfingGenerations in 0:1) 15 | { 16 | pedigree <- sixteenParentPedigreeRandomFunnels(initialPopulationSize=2000, selfingGenerations = selfingGenerations, intercrossingGenerations = intercrossingGenerations, nSeeds = 1) 17 | pedigree@selfing <- "finite" 18 | for(distance in distances) 19 | { 20 | map <- getMap(distance) 21 | cross <- simulateMPCross(map=map, pedigree=pedigree, mapFunction = haldane) 22 | cross2 <- cross + fixedNumberOfFounderAlleles(8) 23 | #Ignore the warning about residual hetrozygosity 24 | capture.output(rf <- estimateRF(cross2, recombValues = c(haldaneToRf(distance), (0:100)/200), keepLod = FALSE, keepLkhd=FALSE)) 25 | expect_equal(rfToHaldane(rf@rf@theta[1,2]), distance, tolerance=0.05) 26 | expect_identical(rf@rf@theta[1,2], rf@rf@theta[2,1]) 27 | expect_identical(rf@rf@theta[1,1], 0) 28 | expect_identical(rf@rf@theta[2,2], 0) 29 | } 30 | } 31 | } 32 | }) 33 | rm(getMap, distances) 34 | -------------------------------------------------------------------------------- /tests/slow/test-estimateRf4Parent.R: -------------------------------------------------------------------------------- 1 | context("estimateRf 4-parent tests") 2 | getMap <- function(distance) 3 | { 4 | map <- list("chr1" = c("a" = 0, "b" = distance)) 5 | class(map)<- "map" 6 | return(map) 7 | } 8 | distances <- c(1, 5, 10, 20, 50) 9 | 10 | test_that("Numerically accurate for a single marker", 11 | { 12 | testFunction <- function(pedigree) 13 | { 14 | for(distance in distances) 15 | { 16 | map <- getMap(distance) 17 | cross <- simulateMPCross(map=map, pedigree=pedigree, mapFunction = haldane) 18 | rf <- estimateRF(cross, recombValues = c(haldaneToRf(distance), (0:100)/200), keepLod = TRUE, keepLkhd=TRUE) 19 | expect_equal(rfToHaldane(rf@rf@theta[1,2]), distance, tolerance=0.015) 20 | expect_identical(rf@rf@theta[1,2], rf@rf@theta[2,1]) 21 | expect_identical(rf@rf@theta[1,1], 0) 22 | expect_identical(rf@rf@theta[2,2], 0) 23 | } 24 | } 25 | for(intercrossingGenerations in 0:1) 26 | { 27 | for(selfingGenerations in 0:1) 28 | { 29 | pedigreeSingleFunnel <- fourParentPedigreeSingleFunnel(initialPopulationSize=50000, selfingGenerations = selfingGenerations, nSeeds = 1, intercrossingGenerations = intercrossingGenerations) 30 | pedigreeSingleFunnel@selfing <- "finite" 31 | testFunction(pedigreeSingleFunnel) 32 | 33 | pedigreeRandomFunnels <- fourParentPedigreeRandomFunnels(initialPopulationSize=50000, selfingGenerations = selfingGenerations, intercrossingGenerations = intercrossingGenerations, nSeeds = 1) 34 | pedigreeRandomFunnels@selfing <- "finite" 35 | testFunction(pedigreeRandomFunnels) 36 | 37 | } 38 | } 39 | 40 | }) 41 | rm(getMap, distances) 42 | -------------------------------------------------------------------------------- /tests/slow/test-estimateRf8Parent.R: -------------------------------------------------------------------------------- 1 | context("estimateRf 8-parent tests") 2 | getMap <- function(distance) 3 | { 4 | map <- list("chr1" = c("a" = 0, "b" = distance)) 5 | class(map)<- "map" 6 | return(map) 7 | } 8 | distances <- c(1, 5, 10, 20, 50) 9 | 10 | test_that("Numerically accurate with randomly chosen funnels", 11 | { 12 | testFunc <- function(pedigree) 13 | { 14 | for(distance in distances) 15 | { 16 | map <- getMap(distance) 17 | cross <- simulateMPCross(map=map, pedigree=pedigree, mapFunction = haldane) 18 | #Ignore the warning about residual heterozygosity 19 | capture.output(rf <- estimateRF(cross, recombValues = c(haldaneToRf(distance), (0:100)/200), keepLod = TRUE, keepLkhd=TRUE)) 20 | expect_equal(rfToHaldane(rf@rf@theta[1,2]), distance, tolerance=0.02) 21 | expect_identical(rf@rf@theta[1,2], rf@rf@theta[2,1]) 22 | expect_identical(rf@rf@theta[1,1], 0) 23 | expect_identical(rf@rf@theta[2,2], 0) 24 | } 25 | } 26 | for(intercrossingGenerations in 0:1) 27 | { 28 | for(selfingGenerations in 0:1) 29 | { 30 | pedigree <- eightParentPedigreeRandomFunnels(initialPopulationSize=100000, selfingGenerations = selfingGenerations, intercrossingGenerations = intercrossingGenerations, nSeeds = 1) 31 | pedigree@selfing <- "finite" 32 | testFunc(pedigree) 33 | pedigree <- eightParentPedigreeSingleFunnel(initialPopulationSize=100000, selfingGenerations = selfingGenerations, intercrossingGenerations = intercrossingGenerations, nSeeds = 1) 34 | pedigree@selfing <- "finite" 35 | testFunc(pedigree) 36 | } 37 | } 38 | }) 39 | rm(getMap, distances) 40 | -------------------------------------------------------------------------------- /tests/slow/test-estimateRfBackcross.R: -------------------------------------------------------------------------------- 1 | context("Test recombination fraction estimation for backcross pedigree") 2 | test_that("Test that estimation of recombination fractions is accurate", 3 | { 4 | distances <- c(1, 5, 10, 20, 50) 5 | pedigree <- backcrossPedigree(100000) 6 | for(distance in distances) 7 | { 8 | map <- sim.map(len = distance, n.mar = 2, anchor.tel=TRUE, include.x=FALSE, eq.spacing=TRUE) 9 | cross <- simulateMPCross(map = map, pedigree = pedigree, mapFunction = haldane) 10 | rf <- estimateRF(cross, recombValues = c(haldaneToRf(distance), seq(0, 0.5, length.out = 200))) 11 | expect_equal(rfToHaldane(rf@rf@theta[1,2]), distance, tolerance = 0.03) 12 | } 13 | }) 14 | -------------------------------------------------------------------------------- /tests/slow/test-estimateRfSingle16Parent.R: -------------------------------------------------------------------------------- 1 | context("estimateRF vs estimateRFSingle, 16-parent tests") 2 | 3 | test_that("Using randomly chosen funnels", 4 | { 5 | distances <- c(1, 5, 10, 20, 50) 6 | for(intercrossingGenerations in 0:1) 7 | { 8 | pedigree <- sixteenParentPedigreeRandomFunnels(initialPopulationSize=100, selfingGenerations = 3, intercrossingGenerations = intercrossingGenerations, nSeeds = 1) 9 | pedigree@selfing <- "finite" 10 | for(distance in distances) 11 | { 12 | map <- list("chr1" = c("a" = 0, "b" = distance)) 13 | class(map)<- "map" 14 | cross <- simulateMPCross(map=map, pedigree=pedigree, mapFunction = haldane) 15 | cross2 <- cross + removeHets() 16 | #Ignore the warning about residual hetrozygosity 17 | capture.output(rfSingle <- estimateRFSingleDesign(cross2, recombValues = c(haldaneToRf(distance), (0:100)/200), keepLod = TRUE, keepLkhd=TRUE)) 18 | capture.output(rf <- estimateRF(cross2, recombValues = c(haldaneToRf(distance), (0:100)/200), keepLod = TRUE, keepLkhd=TRUE)) 19 | expect_identical(rfSingle, rf) 20 | expect_identical(rf@rf@theta[1,2], rf@rf@theta[2,1]) 21 | expect_identical(rf@rf@theta[1,1], 0) 22 | expect_identical(rf@rf@theta[2,2], 0) 23 | } 24 | } 25 | }) 26 | -------------------------------------------------------------------------------- /tests/slow/test-openmp.R: -------------------------------------------------------------------------------- 1 | context("Test openmp support") 2 | test_that("Check that we have the same results for an f2, with and without openmp ", 3 | { 4 | f2Pedigree <- f2Pedigree(10) 5 | map <- sim.map(len = 100, n.mar = 4000, anchor.tel=TRUE, include.x=FALSE, eq.spacing=TRUE) 6 | cross <- simulateMPCross(map=map, pedigree=f2Pedigree, mapFunction = haldane) 7 | 8 | .Call("omp_set_num_threads", 1, PACKAGE="mpMap2") 9 | rf <- estimateRF(cross, gbLimit = 1) 10 | .Call("omp_set_num_threads", 4, PACKAGE="mpMap2") 11 | rf2 <- estimateRF(cross, gbLimit = 1) 12 | expect_identical(rf, rf2) 13 | 14 | f2Pedigree <- f2Pedigree(100) 15 | map <- sim.map(len = 100, n.mar = 400, anchor.tel=TRUE, include.x=FALSE, eq.spacing=TRUE) 16 | cross <- simulateMPCross(map=map, pedigree=f2Pedigree, mapFunction = haldane) 17 | 18 | .Call("omp_set_num_threads", 1, PACKAGE="mpMap2") 19 | rf <- estimateRF(cross, gbLimit = 1) 20 | .Call("omp_set_num_threads", 4, PACKAGE="mpMap2") 21 | rf2 <- estimateRF(cross, gbLimit = 1) 22 | expect_identical(rf, rf2) 23 | 24 | }) 25 | -------------------------------------------------------------------------------- /tests/testthat.R: -------------------------------------------------------------------------------- 1 | library(testthat) 2 | library(mpMap2) 3 | 4 | try(omp_set_num_threads(1), silent = TRUE) 5 | test_check("mpMap2") 6 | -------------------------------------------------------------------------------- /tests/testthat/test-addMpcross.R: -------------------------------------------------------------------------------- 1 | context("Test addition of mpcross objects") 2 | 3 | test_that("Cannot combine object with itself", 4 | { 5 | map <- qtl::sim.map(len = 100, n.mar = 11, anchor.tel=TRUE, include.x=FALSE, eq.spacing=TRUE) 6 | f2Pedigree <- f2Pedigree(10) 7 | cross <- simulateMPCross(map=map, pedigree=f2Pedigree, mapFunction = haldane) 8 | expect_that(cross+cross, throws_error()) 9 | }) 10 | -------------------------------------------------------------------------------- /tests/testthat/test-backcrossPedigree.R: -------------------------------------------------------------------------------- 1 | context("Test backcross pedigree") 2 | test_that("Test that genetic data is as expected", 3 | { 4 | map <- qtl::sim.map(len = 500, n.mar = 11, anchor.tel=TRUE, include.x=FALSE, eq.spacing=TRUE) 5 | pedigree <- backcrossPedigree(1000) 6 | cross <- simulateMPCross(map = map, pedigree = pedigree, mapFunction = haldane) 7 | proportions <- table(cross@geneticData[[1]]@finals)/ length(cross@geneticData[[1]]@finals) 8 | #Expect that there are only two genotypes 9 | expect_identical(length(proportions), 2L) 10 | #Expect that proportions are close to half. 11 | expect_lt(abs(proportions[1] - 0.5), 0.04) 12 | expect_lt(abs(proportions[2] - 0.5), 0.04) 13 | }) 14 | -------------------------------------------------------------------------------- /tests/testthat/test-changeMarkerPosition.R: -------------------------------------------------------------------------------- 1 | context("changeMarkerPosition") 2 | 3 | test_that("Checking that code to change marker positions works", 4 | { 5 | map <- qtl::sim.map(len = c(100, 100), n.mar = 11, anchor.tel = TRUE, include.x=FALSE, eq.spacing=TRUE) 6 | pedigree <- f2Pedigree(500) 7 | cross <- simulateMPCross(map=map, pedigree=pedigree, mapFunction = haldane) 8 | mapped <- new("mpcrossMapped", cross, map = map) 9 | 10 | altered <- changeMarkerPosition(mapped, marker = "D1M2", newChromosome = "2", newPosition = 0.5) 11 | expect_true(validObject(altered, complete=TRUE)) 12 | expect_identical(markers(altered), c("D1M1", paste0("D1M", 3:11), "D2M1", "D1M2", paste0("D2M", 2:11))) 13 | 14 | altered <- changeMarkerPosition(mapped, marker = "D2M2", newChromosome = "1", newPosition = 0.5) 15 | expect_true(validObject(altered, complete=TRUE)) 16 | expect_identical(markers(altered), c("D1M1", "D2M2", paste0("D1M", 2:11), "D2M1", paste0("D2M", 3:11))) 17 | }) 18 | -------------------------------------------------------------------------------- /tests/testthat/test-combineKeepRF.R: -------------------------------------------------------------------------------- 1 | context("combineKeepRF") 2 | 3 | test_that("Test that combineKeepRF works", 4 | { 5 | pedigree <- fourParentPedigreeSingleFunnel(initialPopulationSize = 100, selfingGenerations = 1, intercrossingGenerations = 0) 6 | pedigree@selfing <- "finite" 7 | map <- qtl::sim.map(len = 100, n.mar = 11, anchor.tel = TRUE, include.x = FALSE, eq.spacing = TRUE) 8 | cross <- simulateMPCross(map = map, pedigree = pedigree, mapFunction = "haldane", seed = 1) + multiparentSNP(keepHets = TRUE) 9 | rf <- estimateRF(cross) 10 | 11 | rf1 <- subset(rf, markers = 1:5) 12 | rf2 <- subset(rf, markers = 6:11) 13 | combined <- combineKeepRF(rf1, rf2, verbose = FALSE) 14 | expect_identical(rf, combined) 15 | 16 | rf1 <- subset(rf, markers = 1:10) 17 | rf2 <- subset(rf, markers = 11) 18 | combined <- combineKeepRF(rf1, rf2, verbose = FALSE) 19 | expect_identical(rf, combined) 20 | }) 21 | -------------------------------------------------------------------------------- /tests/testthat/test-countValuesToEstimate.R: -------------------------------------------------------------------------------- 1 | context("countValuesToEstimate") 2 | countValuesToEstimate <- function(markerRows, markerColumns) 3 | { 4 | .Call("countValuesToEstimate", markerRows, markerColumns, PACKAGE="mpMap2") 5 | } 6 | 7 | test_that("Checking that countValuesToEstimate works for rectangular regions", 8 | { 9 | expect_equal(countValuesToEstimate(1,1:10), 10) 10 | expect_equal(countValuesToEstimate(1:2,2:10), 18) 11 | expect_equal(countValuesToEstimate(1:3,3:10), 24) 12 | }) 13 | test_that("Checking that countValuesToEstimate works for triangular regions", 14 | { 15 | expect_equal(countValuesToEstimate(1:10,1:10), 55) 16 | expect_equal(countValuesToEstimate(2:10,2:10), 45) 17 | expect_equal(countValuesToEstimate(1:9,1:2), 3) 18 | }) 19 | test_that("Checking that countValuesToEstimate works for regions that start with a rectangular region", 20 | { 21 | expect_equal(countValuesToEstimate(1:10,9:10), 19) 22 | expect_equal(countValuesToEstimate(1:10,8:10), 27) 23 | expect_equal(countValuesToEstimate(1:3,2:4), 8) 24 | }) 25 | test_that("Checking that countValuesToEstimate works for regions that have a rectangular region on the right", 26 | { 27 | expect_equal(countValuesToEstimate(1:2,1:10), 19) 28 | expect_equal(countValuesToEstimate(1:3,1:10), 27) 29 | }) 30 | rm(countValuesToEstimate) 31 | -------------------------------------------------------------------------------- /tests/testthat/test-detailedPedigree.R: -------------------------------------------------------------------------------- 1 | context("detailedPedigree") 2 | 3 | test_that("Test use of mother / father names as input to detailedPedigree", 4 | { 5 | lineNames <- c("founder1", "founder2", "child1", "child2") 6 | pedigree <- detailedPedigree(lineNames = c("founder1", "founder2", "child1", "child2"), mother = c("", "", "founder1", "child1"), father = c("", "", "founder2", "child1"), initial = c("founder1", "founder2"), observed = "child2", selfing = "finite") 7 | expect_identical(pedigree@initial, 1:2) 8 | expect_identical(pedigree@observed, c(FALSE, FALSE, FALSE, TRUE)) 9 | expect_identical(pedigree@lineNames, lineNames) 10 | expect_identical(pedigree@mother, c(0L, 0L, 1L, 3L)) 11 | expect_identical(pedigree@father, c(0L, 0L, 2L, 3L)) 12 | }) 13 | test_that("Test use of mother / father indices as input to detailedPedigree", 14 | { 15 | lineNames <- c("founder1", "founder2", "child1", "child2") 16 | pedigree <- detailedPedigree(lineNames = c("founder1", "founder2", "child1", "child2"), mother = c(0, 0, 1, 3), father = c(0, 0, 2, 3), initial = 1:2, observed = 4, selfing = "finite") 17 | expect_identical(pedigree@initial, 1:2) 18 | expect_identical(pedigree@observed, c(FALSE, FALSE, FALSE, TRUE)) 19 | expect_identical(pedigree@lineNames, lineNames) 20 | expect_identical(pedigree@mother, c(0L, 0L, 1L, 3L)) 21 | expect_identical(pedigree@father, c(0L, 0L, 2L, 3L)) 22 | }) 23 | -------------------------------------------------------------------------------- /tests/testthat/test-dspMatrix.R: -------------------------------------------------------------------------------- 1 | context("dspMatrix") 2 | test_that("Checking that C assignment call works correctly", 3 | { 4 | #First with a constant value of 100 5 | dsp <- new("dspMatrix", x = as.numeric(1:10), Dim = c(4L,4L)) 6 | .Call("assignDspMatrixFromEstimateRF", dsp, 1, 1, 100) 7 | expect_equal(dsp@x[1], 100) 8 | 9 | dsp <- new("dspMatrix", x = as.numeric(1:10), Dim = c(4L,4L)) 10 | .Call("assignDspMatrixFromEstimateRF", dsp, 1:2, 1:2, rep(100, 3)) 11 | expect_equal(sum(dsp@x == 100), 3) 12 | expect_equal(dsp@x[1:3], c(100,100,100)) 13 | 14 | dsp <- new("dspMatrix", x = as.numeric(1:10), Dim = c(4L,4L)) 15 | .Call("assignDspMatrixFromEstimateRF", dsp, 2:3, 2:3, rep(100, 3)) 16 | expect_equal(sum(dsp@x == 100), 3) 17 | expect_equal(dsp@x[c(3,5,6)], c(100,100,100)) 18 | 19 | dsp <- new("dspMatrix", x = as.numeric(1:10), Dim = c(4L,4L)) 20 | .Call("assignDspMatrixFromEstimateRF", dsp, 2, 2, 100) 21 | expect_equal(dsp@x[3], 100) 22 | 23 | dsp <- new("dspMatrix", x = as.numeric(1:10), Dim = c(4L,4L)) 24 | .Call("assignDspMatrixFromEstimateRF", dsp, 1:3, 1:3, rep(100, 6)) 25 | expect_equal(sum(dsp@x == 100), 6) 26 | expect_equal(dsp@x[1:6], rep(100, 6)) 27 | 28 | dsp <- new("dspMatrix", x = as.numeric(1:10), Dim = c(4L,4L)) 29 | .Call("assignDspMatrixFromEstimateRF", dsp, 1:2, 3:4, rep(100, 4)) 30 | expect_equal(sum(dsp@x == 100), 4) 31 | expect_equal(dsp@x[c(4,5,7,8)], rep(100, 4)) 32 | 33 | #Now with different values 34 | dsp <- new("dspMatrix", x = as.numeric(1:10), Dim = c(4L,4L)) 35 | .Call("assignDspMatrixFromEstimateRF", dsp, 1:2, 3:4, c(100, 101, 102, 103)) 36 | expect_equal(sum(dsp@x > 99), 4) 37 | expect_equal(dsp@x[c(4,5,7,8)], c(100, 101, 102, 103)) 38 | }) 39 | -------------------------------------------------------------------------------- /tests/testthat/test-eightParentPedigreeImproperFunnels.R: -------------------------------------------------------------------------------- 1 | context("eightParentPedigreeImproperFunnels") 2 | 3 | test_that("Check that the C and R versions are identical", 4 | { 5 | parameters <- expand.grid(selfingGenerations = 0:3, nSeeds = 1:3) 6 | seed <- 1 7 | apply(parameters, 1, function(x) 8 | { 9 | set.seed(seed) 10 | pedigreeR <- mpMap2:::eightParentPedigreeImproperFunnelsPrototype(selfingGenerations = x["selfingGenerations"], initialPopulationSize = 20, nSeeds = x["nSeeds"]) 11 | set.seed(seed) 12 | pedigreeC <- eightParentPedigreeImproperFunnels(selfingGenerations = x["selfingGenerations"],initialPopulationSize = 20, nSeeds = x["nSeeds"]) 13 | expect_identical(pedigreeR, pedigreeC) 14 | seed <<- seed + 1 15 | }) 16 | }) 17 | -------------------------------------------------------------------------------- /tests/testthat/test-eightParentPedigreeSingleFunnel.R: -------------------------------------------------------------------------------- 1 | context("eightParentPedigreeSingleFunnel") 2 | 3 | test_that("Check that the C and R versions are identical", 4 | { 5 | parameters <- expand.grid(selfingGenerations = 0:3, intercrossingGenerations = 0:3, nSeeds = 1:3) 6 | seed <- 1 7 | apply(parameters, 1, function(x) 8 | { 9 | set.seed(seed) 10 | pedigreeR <- mpMap2:::eightParentPedigreeSingleFunnelPrototype(selfingGenerations = x["selfingGenerations"], intercrossingGenerations = x["intercrossingGenerations"], initialPopulationSize = 20, nSeeds = x["nSeeds"]) 11 | set.seed(seed) 12 | pedigreeC <- eightParentPedigreeSingleFunnel(selfingGenerations = x["selfingGenerations"], intercrossingGenerations = x["intercrossingGenerations"], initialPopulationSize = 20, nSeeds = x["nSeeds"]) 13 | expect_identical(pedigreeR, pedigreeC) 14 | seed <<- seed + 1 15 | }) 16 | }) 17 | -------------------------------------------------------------------------------- /tests/testthat/test-estimateMap.R: -------------------------------------------------------------------------------- 1 | context("Test estimateMap") 2 | test_that("Check that argument maxMarkers works correctly", 3 | { 4 | f2Pedigree <- f2Pedigree(1000) 5 | map <- qtl::sim.map(len = rep(100, 1), n.mar = rep(101, 1), anchor.tel=TRUE, include.x=FALSE, eq.spacing=TRUE) 6 | cross <- simulateMPCross(map=map, pedigree=f2Pedigree, mapFunction = haldane) 7 | rf <- estimateRF(cross) 8 | grouped <- formGroups(rf, groups = 1, method = "average", clusterBy = "theta") 9 | estimated.map1 <- estimateMap(grouped, maxOffset = 4, maxMarkers = 60) 10 | estimated.map2 <- estimateMap(grouped, maxOffset = 4, maxMarkers = 40) 11 | estimated.map3 <- estimateMap(grouped, maxOffset = 4, maxMarkers = 80) 12 | estimated.map4 <- estimateMap(grouped, maxOffset = 4, maxMarkers = 1000) 13 | 14 | expect_equal(estimated.map1, estimated.map2, tolerance = 0.02) 15 | expect_equal(estimated.map1, estimated.map3, tolerance = 0.02) 16 | expect_equal(estimated.map1, estimated.map4, tolerance = 0.02) 17 | 18 | expect_identical(names(estimated.map1[[1]]), markers(cross)) 19 | expect_identical(names(estimated.map2[[1]]), markers(cross)) 20 | expect_identical(names(estimated.map3[[1]]), markers(cross)) 21 | expect_identical(names(estimated.map4[[1]]), markers(cross)) 22 | }) 23 | 24 | -------------------------------------------------------------------------------- /tests/testthat/test-expand.R: -------------------------------------------------------------------------------- 1 | context("expand") 2 | pedigree <- f2Pedigree(10) 3 | map <- qtl::sim.map(len = 100, n.mar = 10, anchor.tel=TRUE, include.x=FALSE, eq.spacing=TRUE) 4 | cross <- simulateMPCross(map=map, pedigree=pedigree, mapFunction = haldane) 5 | rf <- estimateRF(cross, keepLod = TRUE, keepLkhd=TRUE) 6 | 7 | test_that("Can expand to same marker set (without a warning)", 8 | { 9 | expect_warning(expand(rf, newMarkers = markers(rf)), NA) 10 | 11 | lg <- formGroups(rf, groups = 1) 12 | expect_warning(expand(lg, newMarkers = markers(lg)), NA) 13 | }) 14 | test_that("Function warns when discarding recombination data", 15 | { 16 | newMarkers <- c(markers(rf), "extraMarker") 17 | 18 | expect_that(expand(rf, newMarkers = newMarkers), gives_warning("recombination data will be lost")) 19 | 20 | lg <- formGroups(rf, groups = 1) 21 | expect_that(expand(lg, newMarkers = newMarkers), gives_warning("recombination and linkage group data will be lost")) 22 | }) 23 | 24 | test_that("Function warns when discarding linkage group data", 25 | { 26 | newMarkers <- c(markers(rf), "extraMarker") 27 | lg <- formGroups(rf, groups = 1) 28 | expect_that(expand(lg, newMarkers = newMarkers), gives_warning("linkage group data will be lost")) 29 | }) 30 | 31 | test_that("New markers must contain old markers", 32 | { 33 | newMarkers <- c("extraMarker", "extraMarker2") 34 | expect_that(expand(rf, newMarkers = newMarkers), throws_error()) 35 | 36 | lg <- formGroups(rf, groups = 1) 37 | expect_that(expand(lg, newMarkers = newMarkers), throws_error()) 38 | }) 39 | rm(pedigree, map, cross, rf) 40 | -------------------------------------------------------------------------------- /tests/testthat/test-fourParentPedigreeRandomFunnels.R: -------------------------------------------------------------------------------- 1 | context("fourParentPedigreeRandomFunnels") 2 | 3 | test_that("Check that the C and R versions are identical", 4 | { 5 | parameters <- expand.grid(selfingGenerations = 0:3, intercrossingGenerations = 0:3, nSeeds = 1:3) 6 | seed <- 1 7 | apply(parameters, 1, function(x) 8 | { 9 | set.seed(seed) 10 | pedigreeR <- mpMap2:::fourParentPedigreeRandomFunnelsPrototype(selfingGenerations = x["selfingGenerations"], intercrossingGenerations = x["intercrossingGenerations"], initialPopulationSize = 20, nSeeds = x["nSeeds"]) 11 | set.seed(seed) 12 | pedigreeC <- fourParentPedigreeRandomFunnels(selfingGenerations = x["selfingGenerations"], intercrossingGenerations = x["intercrossingGenerations"], initialPopulationSize = 20, nSeeds = x["nSeeds"]) 13 | expect_equal(pedigreeR, pedigreeC) 14 | seed <<- seed + 1 15 | }) 16 | }) 17 | test_that("Input nSeeds must be positive", 18 | { 19 | expect_that(fourParentPedigreeRandomFunnels(initialPopulationSize = 100, selfingGenerations = 5, intercrossingGenerations = 0, nSeeds = 0), throws_error("positive integer")) 20 | }) 21 | -------------------------------------------------------------------------------- /tests/testthat/test-fourParentPedigreeSingleFunnel.R: -------------------------------------------------------------------------------- 1 | context("fourParentPedigreeSingleFunnel") 2 | 3 | test_that("Check that the C and R versions are identical", 4 | { 5 | parameters <- expand.grid(selfingGenerations = 0:3, intercrossingGenerations = 0:3, nSeeds = 1:3) 6 | seed <- 1 7 | apply(parameters, 1, function(x) 8 | { 9 | set.seed(seed) 10 | pedigreeR <- mpMap2:::fourParentPedigreeSingleFunnelPrototype(selfingGenerations = x["selfingGenerations"], intercrossingGenerations = x["intercrossingGenerations"], initialPopulationSize = 20, nSeeds = x["nSeeds"]) 11 | set.seed(seed) 12 | pedigreeC <- fourParentPedigreeSingleFunnel(selfingGenerations = x["selfingGenerations"], intercrossingGenerations = x["intercrossingGenerations"], initialPopulationSize = 20, nSeeds = x["nSeeds"]) 13 | expect_equal(pedigreeR, pedigreeC) 14 | seed <<- seed + 1 15 | }) 16 | }) 17 | test_that("Input nSeeds must be positive", 18 | { 19 | expect_that(fourParentPedigreeSingleFunnel(initialPopulationSize = 100, selfingGenerations = 5, intercrossingGenerations = 0, nSeeds = 0), throws_error("positive integer")) 20 | }) 21 | -------------------------------------------------------------------------------- /tests/testthat/test-generateGenotypes.R: -------------------------------------------------------------------------------- 1 | context("generateGenotypes") 2 | test_that("Reject out of range recombination fractions", 3 | { 4 | adjacentRecombination <- seq(0, 0.5, by = 0.01) 5 | markerNames <- as.character(1:(length(adjacentRecombination)+1)) 6 | pedigree <- fourParentPedigreeRandomFunnels(initialPopulationSize = 10, selfingGenerations = 1, intercrossingGenerations = 0) 7 | genotypes <- .Call("generateGenotypes", adjacentRecombination, markerNames, pedigree, PACKAGE="mpMap2") 8 | 9 | markerNames <- as.character(1:(length(adjacentRecombination))) 10 | expect_error(genotypes <- .Call("generateGenotypes", adjacentRecombination, markerNames, pedigree, PACKAGE="mpMap2")) 11 | 12 | adjacentRecombination <- seq(-0.1, 0.5, by = 0.01) 13 | expect_error(genotypes <- .Call("generateGenotypes", adjacentRecombination, markerNames, pedigree, PACKAGE="mpMap2"), "All recombination fractions must be between 0 and 0.5", class = "std::runtime_error") 14 | 15 | adjacentRecombination <- seq(0, 0.6, by = 0.01) 16 | expect_error(genotypes <- .Call("generateGenotypes", adjacentRecombination, markerNames, pedigree, PACKAGE="mpMap2"), "All recombination fractions must be between 0 and 0.5", class = "std::runtime_error") 17 | }) 18 | -------------------------------------------------------------------------------- /tests/testthat/test-generateIntervalMidPoints.R: -------------------------------------------------------------------------------- 1 | context("Test generateIntervalMidPoints") 2 | 3 | test_that("Test generateIntervalMidPoints", 4 | { 5 | map <- qtl::sim.map(len = c(100, 100), n.mar = 11, anchor.tel=TRUE, include.x=FALSE, eq.spacing=TRUE) 6 | map[[1]] <- c("Extra1" = 0, map[[1]][1:5], "Extra2" = 40, map[[1]][6:11], "Extra3" = 100) 7 | map[[2]] <- c("Extra4" = 0, map[[2]][1:5], "Extra5" = 40, map[[2]][6:11], "Extra6" = 100) 8 | f2Pedigree <- f2Pedigree(10) 9 | cross <- simulateMPCross(map=map, pedigree=f2Pedigree, mapFunction = haldane) 10 | cross <- new("mpcrossMapped", cross, map = map) 11 | newPositions <- generateIntervalMidPoints(cross) 12 | expect_identical(names(newPositions[[1]]), paste0("Chr1Interval", 1:length(newPositions[[1]]))) 13 | expect_equal(newPositions[[1]], seq(5, 95, 10), check.attributes = FALSE) 14 | expect_identical(names(newPositions[[2]]), paste0("Chr2Interval", 1:length(newPositions[[2]]))) 15 | expect_equal(newPositions[[2]], seq(5, 95, 10), check.attributes = FALSE) 16 | }) 17 | -------------------------------------------------------------------------------- /tests/testthat/test-getChromosomes.R: -------------------------------------------------------------------------------- 1 | context("getChromosomes") 2 | 3 | test_that("Checking that code to get chromosomes works", 4 | { 5 | map <- qtl::sim.map(len = c(100, 100), n.mar = 101, anchor.tel = TRUE, include.x=FALSE, eq.spacing=TRUE) 6 | pedigree <- f2Pedigree(500) 7 | cross <- simulateMPCross(map=map, pedigree=pedigree, mapFunction = haldane) 8 | mapped <- new("mpcrossMapped", cross, map = map) 9 | 10 | expect_identical(getChromosomes(mapped, c("D1M1", "D1M10", "D2M1", "D2M10")), c("D1M1" = "1", "D1M10" = "1", "D2M1" = "2", "D2M10" = "2")) 11 | }) 12 | -------------------------------------------------------------------------------- /tests/testthat/test-getPositions.R: -------------------------------------------------------------------------------- 1 | context("getPositions") 2 | 3 | test_that("Checking that code to get marker positions works", 4 | { 5 | map <- qtl::sim.map(len = c(100, 100), n.mar = 101, anchor.tel = TRUE, include.x=FALSE, eq.spacing=TRUE) 6 | pedigree <- f2Pedigree(500) 7 | cross <- simulateMPCross(map=map, pedigree=pedigree, mapFunction = haldane) 8 | mapped <- new("mpcrossMapped", cross, map = map) 9 | 10 | expect_identical(getPositions(mapped, c("D1M1", "D1M10", "D2M1", "D2M10")), c("D1M1" = 0, "D1M10" = 9, "D2M1" = 0, "D2M10" = 9)) 11 | }) 12 | -------------------------------------------------------------------------------- /tests/testthat/test-hets.R: -------------------------------------------------------------------------------- 1 | context("Test use of hets, when only *one* is informative for hets") 2 | 3 | test_that("Test imputation", 4 | { 5 | map <- qtl::sim.map(len = 5, anchor.tel = TRUE, include.x = FALSE, eq.spacing = TRUE, n.mar = 21) 6 | pedigree <- eightParentPedigreeSingleFunnel(initialPopulationSize = 100, selfingGenerations = 1, nSeeds = 1, intercrossingGenerations = 0) 7 | pedigree@selfing <- "finite" 8 | cross <- simulateMPCross(map = map, pedigree = pedigree, mapFunction = haldane, seed = 2) 9 | 10 | cross2 <- cross + multiparentSNP(keepHets = FALSE) 11 | cross2@geneticData[[1]]@finals[,11] <- cross@geneticData[[1]]@finals[,11] 12 | cross2@geneticData[[1]]@founders[,11] <- cross@geneticData[[1]]@founders[,11] 13 | cross2@geneticData[[1]]@hetData[[11]] <- cross@geneticData[[1]]@hetData[[11]] 14 | validObject(cross2, complete=TRUE) 15 | 16 | mapped <- new("mpcrossMapped", cross2, map = map) 17 | imputed <- imputeFounders(mapped) 18 | 19 | t <- table(imputed@geneticData[[1]]@imputed@data) 20 | expect_gt(sum(t[as.integer(names(t)) > 8]), length(imputed@geneticData[[1]]@imputed@data)/4) 21 | }) 22 | -------------------------------------------------------------------------------- /tests/testthat/test-imputeFounders2ParentInfiniteNoErrors.R: -------------------------------------------------------------------------------- 1 | context("Founder imputation, two parents, infinite selfing, no errors") 2 | test_that("Test zero generations of intercrossing", 3 | { 4 | testFunc <- function(map) 5 | { 6 | pedigree <- rilPedigree(500, selfingGenerations = 10) 7 | cross <- simulateMPCross(map=map, pedigree=pedigree, mapFunction = haldane) 8 | mapped <- new("mpcrossMapped", cross, map = map) 9 | suppressWarnings(result <- imputeFounders(mapped, errorProb = 0)) 10 | 11 | #Hetrozygotes will be discarded in imputation, which means that the imputed version won't be EXACTLY the same as the original data 12 | naIndices <- result@geneticData[[1]]@finals == 3 13 | result@geneticData[[1]]@finals[naIndices] <- NA 14 | result@geneticData[[1]]@imputed@data[naIndices] <- NA 15 | expect_identical(result@geneticData[[1]]@imputed@data, result@geneticData[[1]]@finals) 16 | 17 | #Dominance doesn't really make a difference, because it's assumed inbred 18 | cross <- cross + biparentalDominant() 19 | mapped <- new("mpcrossMapped", cross, map = map) 20 | result <- imputeFounders(mapped, errorProb = 0) 21 | tmp <- table(result@geneticData[[1]]@imputed@data, result@geneticData[[1]]@finals) 22 | expect_true(sum(diag(tmp)) / sum(tmp) > 0.99) 23 | 24 | expect_true(all(result@geneticData[[1]]@imputed@errors == 0)) 25 | } 26 | map <- qtl::sim.map(len = 100, n.mar = 101, anchor.tel = TRUE, include.x=FALSE, eq.spacing=TRUE) 27 | testFunc(map) 28 | map <- qtl::sim.map(len = c(100, 100), n.mar = 101, anchor.tel = TRUE, include.x=FALSE, eq.spacing=TRUE) 29 | testFunc(map) 30 | }) 31 | -------------------------------------------------------------------------------- /tests/testthat/test-imputeFoundersImproper.R: -------------------------------------------------------------------------------- 1 | context("Founder imputation isn't implemented for improper funnels (funnels with repeated founders)") 2 | test_that("Eight parent design", 3 | { 4 | testFunc <- function(pedigree, map) 5 | { 6 | cross <- simulateMPCross(map=map, pedigree=pedigree, mapFunction = haldane) 7 | mapped <- new("mpcrossMapped", cross, map = map) 8 | expect_error(result <- imputeFounders(mapped, errorProb = 0.1)) 9 | expect_error(result <- computeGenotypeProbabilities(mapped, errorProb = 0.1)) 10 | } 11 | map1 <- qtl::sim.map(len = 100, n.mar = 201, anchor.tel = TRUE, include.x=FALSE, eq.spacing=TRUE) 12 | map2 <- qtl::sim.map(len = c(100, 100), n.mar = 201, anchor.tel = TRUE, include.x=FALSE, eq.spacing=TRUE) 13 | maps <- list(map1, map2) 14 | 15 | pedigree1 <- eightParentPedigreeImproperFunnels(initialPopulationSize = 500, selfingGenerations = 10, nSeeds = 1) 16 | pedigree1@selfing <- "infinite" 17 | pedigree2 <- eightParentPedigreeImproperFunnels(initialPopulationSize = 500, selfingGenerations = 10, nSeeds = 1) 18 | pedigree2@selfing <- "infinite" 19 | pedigree3 <- eightParentPedigreeImproperFunnels(initialPopulationSize = 500, selfingGenerations = 5, nSeeds = 1) 20 | pedigree3@selfing <- "finite" 21 | pedigree4 <- eightParentPedigreeImproperFunnels(initialPopulationSize = 500, selfingGenerations = 5, nSeeds = 1) 22 | pedigree4@selfing <- "finite" 23 | 24 | pedigrees <- list(pedigree1, pedigree2, pedigree3, pedigree4) 25 | for(map in maps) 26 | { 27 | for(pedigree in pedigrees) 28 | { 29 | testFunc(pedigree, map) 30 | } 31 | } 32 | }) 33 | -------------------------------------------------------------------------------- /tests/testthat/test-mpcross.R: -------------------------------------------------------------------------------- 1 | context("Test mpcross function") 2 | test_that("Test that mpcross works without inputting a value for hetData", 3 | { 4 | rilPedigree <- rilPedigree(100, selfingGenerations = 8) 5 | map <- qtl::sim.map(len = 100, n.mar = 11, anchor.tel=TRUE, include.x=FALSE, eq.spacing=TRUE) 6 | cross <- simulateMPCross(map=map, pedigree=rilPedigree, mapFunction = haldane) 7 | 8 | expect_error(cross1 <- mpMap2::mpcross(founders = founders(cross), finals = finals(cross), pedigree = rilPedigree)) 9 | expect_warning(cross1 <- mpMap2::mpcross(founders = founders(cross), finals = finals(cross), pedigree = rilPedigree, fixCodingErrors = TRUE)) 10 | expect_warning(cross2 <- mpMap2::mpcross(founders = founders(cross), finals = finals(cross), pedigree = rilPedigree, hetData = infiniteSelfing, fixCodingErrors=TRUE)) 11 | expect_identical(cross1, cross2) 12 | }) 13 | test_that("Test that mpcross works with hetData = infiniteSelfing", 14 | { 15 | rilPedigree <- rilPedigree(100, selfingGenerations = 8) 16 | map <- qtl::sim.map(len = 100, n.mar = 11, anchor.tel=TRUE, include.x=FALSE, eq.spacing=TRUE) 17 | cross <- simulateMPCross(map=map, pedigree=rilPedigree, mapFunction = haldane) 18 | 19 | #No need for fixCodingErrors here 20 | expect_error(cross2 <- mpMap2::mpcross(founders = founders(cross), finals = finals(cross), pedigree = rilPedigree, hetData = hetsForSNPMarkers), NA) 21 | }) 22 | -------------------------------------------------------------------------------- /tests/testthat/test-mpcrossRFValidation.R: -------------------------------------------------------------------------------- 1 | context("mpcrossRF validation") 2 | 3 | test_that("Slot rf must have the right number of markers", 4 | { 5 | pedigree <- twoParentPedigree(initialPopulationSize=100, selfingGenerations=0, nSeeds=3, intercrossingGenerations=1) 6 | pedigree@selfing <- "finite" 7 | map1 <- qtl::sim.map(len = rep(100, 1), n.mar = 12, anchor.tel = T, include.x=FALSE, sex.sp=FALSE, eq.spacing=T) 8 | cross1 <- simulateMPCross(map = map1, pedigree=pedigree, mapFunction = haldaneToRf, seed=1) 9 | rf1 <- estimateRF(cross1) 10 | 11 | map2 <- qtl::sim.map(len = rep(100, 1), n.mar = 100, anchor.tel = T, include.x=FALSE, sex.sp=FALSE, eq.spacing=T) 12 | cross2 <- simulateMPCross(map = map2, pedigree=pedigree, mapFunction = haldaneToRf, seed=1) 13 | rf2 <- estimateRF(cross2) 14 | 15 | 16 | tmp1 <- rf1@rf 17 | tmp2 <- rf2@rf 18 | rf1@rf <- tmp2 19 | rf2@rf <- tmp1 20 | expect_that(validObject(rf1, complete=TRUE), throws_error()) 21 | expect_that(validObject(rf2, complete=TRUE), throws_error()) 22 | }) 23 | -------------------------------------------------------------------------------- /tests/testthat/test-plot.R: -------------------------------------------------------------------------------- 1 | context("Test plot function") 2 | 3 | test_that("Test that function plot gives informative errors", 4 | { 5 | map <- qtl::sim.map(len = 5, anchor.tel = TRUE, include.x = FALSE, eq.spacing = TRUE, n.mar = 21) 6 | pedigree <- eightParentPedigreeSingleFunnel(initialPopulationSize = 10, selfingGenerations = 1, nSeeds = 1, intercrossingGenerations = 0) 7 | pedigree@selfing <- "infinite" 8 | cross <- simulateMPCross(map = map, pedigree = pedigree, mapFunction = haldane, seed = 2) + removeHets() 9 | crossMapped <- new("mpcrossMapped", cross, map = map) 10 | probabilities <- computeGenotypeProbabilities(crossMapped) 11 | imputed <- imputeFounders(crossMapped) 12 | 13 | expect_error(plot(crossMapped), "Function plot is not defined for an object of class \"mpcross\"") 14 | expect_error(plot(cross), "Function plot is not defined for an object of class \"mpcross\"") 15 | expect_error(plot(cross@geneticData[[1]]), "Function plot is not defined for an object of class \"geneticData\"") 16 | expect_error(plot(crossMapped@geneticData[[1]]), "Function plot is not defined for an object of class \"geneticData\"") 17 | expect_error(plot(probabilities@geneticData[[1]]@probabilities), "Function plot is not defined for an object of class \"probabilities\"") 18 | expect_error(plot(imputed@geneticData[[1]]@imputed), "Function plot is not defined for an object of class \"imputed\"") 19 | }) 20 | -------------------------------------------------------------------------------- /tests/testthat/test-simulateMPCross.R: -------------------------------------------------------------------------------- 1 | context("simulateMPCross") 2 | test_that("Can simulate a cross object with a single markers", 3 | { 4 | pedigree <- f2Pedigree(100) 5 | map <- qtl::sim.map(len = 100, n.mar = 1, anchor.tel=FALSE, include.x=FALSE, eq.spacing=TRUE) 6 | expect_error(cross <- simulateMPCross(map=map, pedigree=pedigree, mapFunction = haldane), NA) 7 | }) 8 | test_that("Map is reordered", 9 | { 10 | pedigree <- f2Pedigree(100) 11 | map <- qtl::sim.map(len = 100, n.mar = 101, anchor.tel=TRUE, include.x=FALSE, eq.spacing=TRUE) 12 | copiedMap <- map 13 | copiedMap[[1]] <- copiedMap[[1]][sample(1:101)] 14 | cross <- simulateMPCross(map=map, pedigree=pedigree, mapFunction = haldane) 15 | expect_identical(markers(cross), names(map[[1]])) 16 | }) 17 | -------------------------------------------------------------------------------- /tests/testthat/test-singleLocusProbabilities.R: -------------------------------------------------------------------------------- 1 | context("Test single locus probabilities") 2 | 3 | test_that("Test that probabilities sum to 1", 4 | { 5 | for(nFounders in c(2, 4, 8)) 6 | { 7 | indices <- matrix(0, nrow = 0, ncol = 2) 8 | multiples <- c() 9 | for(i in 1:nFounders) 10 | { 11 | for(j in 1:i) 12 | { 13 | multiple <- 1 14 | if(i != j) multiple <- multiple * 2 15 | indices <- rbind(indices, c(i, j)) 16 | multiples <- c(multiples, multiple) 17 | } 18 | } 19 | for(selfingGenerations in c(0:1, Inf)) 20 | { 21 | for(nFunnels in 1:2) 22 | { 23 | for(intercrossingGenerations in 0:1) 24 | { 25 | probabilities <- mpMap2:::singleLocusProbabilities(nFounders = nFounders, nFunnels = nFunnels, intercrossingGenerations = intercrossingGenerations, selfingGenerations = selfingGenerations, infiniteSelfing = selfingGenerations == Inf) 26 | #Check a specific symmetry - Essentially each het has two states, which contain half the probability. 27 | expect_equal(sum(probabilities[indices] * multiples), 1) 28 | expect_equal(sum(probabilities), 1) 29 | } 30 | } 31 | } 32 | } 33 | }) 34 | test_that("Test that F2 probabilities are correct", 35 | { 36 | probabilities <- mpMap2:::singleLocusProbabilities(nFounders = 2, nFunnels = 1, intercrossingGenerations = 0, selfingGenerations = 1, infiniteSelfing = FALSE) 37 | expected <- rep(0.25, 4) 38 | dim(expected) <- c(2, 2) 39 | expect_identical(probabilities, expected) 40 | }) 41 | -------------------------------------------------------------------------------- /tests/testthat/test-sixteenParentPedigreeRandomFunnels.R: -------------------------------------------------------------------------------- 1 | context("sixteenParentPedigreeRandomFunnels") 2 | 3 | test_that("Check that the C and R versions are identical", 4 | { 5 | parameters <- expand.grid(selfingGenerations = 0:2, nSeeds = 1:4, intercrossingGenerations = 0:3) 6 | seed <- 1 7 | apply(parameters, 1, function(x) 8 | { 9 | set.seed(seed) 10 | pedigreeR <- mpMap2:::sixteenParentPedigreeRandomFunnelsPrototype(selfingGenerations = x["selfingGenerations"], intercrossingGenerations = x["intercrossingGenerations"], initialPopulationSize = 20, nSeeds = x["nSeeds"]) 11 | set.seed(seed) 12 | pedigreeC <- sixteenParentPedigreeRandomFunnels(selfingGenerations = x["selfingGenerations"], intercrossingGenerations = x["intercrossingGenerations"], initialPopulationSize = 20, nSeeds = x["nSeeds"]) 13 | expect_identical(pedigreeR, pedigreeC) 14 | seed <<- seed + 1 15 | }) 16 | }) 17 | -------------------------------------------------------------------------------- /tests/testthat/test-subset.mpcrossLG.R: -------------------------------------------------------------------------------- 1 | context("Test subsetting of mpcrossLG objects") 2 | test_that("Subsetting of mpcrossLG objects by lines discards rf data, and warns about retaining linkage group data", 3 | { 4 | map <- qtl::sim.map(len = rep(100, 2), n.mar = rep(11, 2), anchor.tel=TRUE, include.x=FALSE, eq.spacing=TRUE) 5 | f2Pedigree <- f2Pedigree(500) 6 | cross <- simulateMPCross(map=map, pedigree=f2Pedigree, mapFunction = haldane) 7 | rf <- estimateRF(cross) 8 | grouped <- formGroups(rf, groups = 2, clusterBy = "theta", method = "average") 9 | 10 | warnings <- testthat::capture_warnings(subsetted <- subset(grouped, lines = rownames(finals(cross))[1:100])) 11 | expect_match(warnings, "Retaining linkage group data", all = FALSE) 12 | expect_match(warnings, "Discarding rf data", all = FALSE) 13 | 14 | expect_warning(subsetted <- subset(grouped, lines = rownames(finals(cross))[1:100]), "Discarding rf data") 15 | }) 16 | -------------------------------------------------------------------------------- /tests/testthat/test-subset.mpcrossRF.R: -------------------------------------------------------------------------------- 1 | context("Test subsetting of mpcrossRF objects") 2 | test_that("Subsetting of mpcrossRF object by lines discards rf data", 3 | { 4 | map <- qtl::sim.map(len = rep(100, 2), n.mar = rep(11, 2), anchor.tel=TRUE, include.x=FALSE, eq.spacing=TRUE) 5 | f2Pedigree <- f2Pedigree(500) 6 | cross <- simulateMPCross(map=map, pedigree=f2Pedigree, mapFunction = haldane) 7 | rf <- estimateRF(cross) 8 | expect_warning(subsetted <- subset(rf, lines = lineNames(cross)[1:10]), "Discarding rf") 9 | expect_equivalent(class(subsetted), "mpcross") 10 | }) 11 | -------------------------------------------------------------------------------- /tests/testthat/test-withoutLineWeights.R: -------------------------------------------------------------------------------- 1 | context("Test that lineWeights argument works") 2 | test_that("Checking that value of lineWeights option doesn't change results for f2", 3 | { 4 | map <- qtl::sim.map(len = 100, n.mar = 11, anchor.tel=TRUE, include.x=FALSE, eq.spacing=TRUE) 5 | f2Pedigree <- f2Pedigree(50) 6 | nReps <- 4 7 | for(i in 1:nReps) 8 | { 9 | cross <- simulateMPCross(map=map, pedigree=f2Pedigree, mapFunction = haldane) 10 | allOneLineWeights <- estimateRF(subset(cross, lines = 1:49), keepLod = TRUE, keepLkhd = TRUE) 11 | differentLineWeights <- estimateRF(cross, lineWeights = c(rep(1, 49), 0), keepLod = TRUE, keepLkhd = TRUE) 12 | expect_identical(allOneLineWeights@rf@theta, differentLineWeights@rf@theta) 13 | expect_equal(allOneLineWeights@rf@lod, differentLineWeights@rf@lod) 14 | expect_equal(allOneLineWeights@rf@lkhd, differentLineWeights@rf@lkhd) 15 | } 16 | }) 17 | -------------------------------------------------------------------------------- /vignettes/MAGIC4.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rohan-shah/mpMap2/c43bb51b348bdf6937e1b11298b9cdfe7a85e001/vignettes/MAGIC4.pdf -------------------------------------------------------------------------------- /vignettes/MAGIC8.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rohan-shah/mpMap2/c43bb51b348bdf6937e1b11298b9cdfe7a85e001/vignettes/MAGIC8.pdf -------------------------------------------------------------------------------- /vignettes/approximatelyFlatSingleFunnel00.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rohan-shah/mpMap2/c43bb51b348bdf6937e1b11298b9cdfe7a85e001/vignettes/approximatelyFlatSingleFunnel00.pdf -------------------------------------------------------------------------------- /vignettes/approximatelyFlatSingleFunnel01.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rohan-shah/mpMap2/c43bb51b348bdf6937e1b11298b9cdfe7a85e001/vignettes/approximatelyFlatSingleFunnel01.pdf -------------------------------------------------------------------------------- /vignettes/approximatelyFlatSingleFunnel10.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rohan-shah/mpMap2/c43bb51b348bdf6937e1b11298b9cdfe7a85e001/vignettes/approximatelyFlatSingleFunnel10.pdf -------------------------------------------------------------------------------- /vignettes/approximatelyFlatSingleFunnel11.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rohan-shah/mpMap2/c43bb51b348bdf6937e1b11298b9cdfe7a85e001/vignettes/approximatelyFlatSingleFunnel11.pdf -------------------------------------------------------------------------------- /vignettes/funnelsIllustration.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rohan-shah/mpMap2/c43bb51b348bdf6937e1b11298b9cdfe7a85e001/vignettes/funnelsIllustration.pdf -------------------------------------------------------------------------------- /vignettes/informativeSingleFunnel00.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rohan-shah/mpMap2/c43bb51b348bdf6937e1b11298b9cdfe7a85e001/vignettes/informativeSingleFunnel00.pdf -------------------------------------------------------------------------------- /vignettes/informativeSingleFunnel01.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rohan-shah/mpMap2/c43bb51b348bdf6937e1b11298b9cdfe7a85e001/vignettes/informativeSingleFunnel01.pdf -------------------------------------------------------------------------------- /vignettes/informativeSingleFunnel10.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rohan-shah/mpMap2/c43bb51b348bdf6937e1b11298b9cdfe7a85e001/vignettes/informativeSingleFunnel10.pdf -------------------------------------------------------------------------------- /vignettes/informativeSingleFunnel11.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rohan-shah/mpMap2/c43bb51b348bdf6937e1b11298b9cdfe7a85e001/vignettes/informativeSingleFunnel11.pdf -------------------------------------------------------------------------------- /vignettes/multipointApproximation.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rohan-shah/mpMap2/c43bb51b348bdf6937e1b11298b9cdfe7a85e001/vignettes/multipointApproximation.pdf -------------------------------------------------------------------------------- /vignettes/uninformativeSingleFunnel00.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rohan-shah/mpMap2/c43bb51b348bdf6937e1b11298b9cdfe7a85e001/vignettes/uninformativeSingleFunnel00.pdf -------------------------------------------------------------------------------- /vignettes/uninformativeSingleFunnel01.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rohan-shah/mpMap2/c43bb51b348bdf6937e1b11298b9cdfe7a85e001/vignettes/uninformativeSingleFunnel01.pdf -------------------------------------------------------------------------------- /vignettes/uninformativeSingleFunnel10.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rohan-shah/mpMap2/c43bb51b348bdf6937e1b11298b9cdfe7a85e001/vignettes/uninformativeSingleFunnel10.pdf -------------------------------------------------------------------------------- /vignettes/uninformativeSingleFunnel11.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rohan-shah/mpMap2/c43bb51b348bdf6937e1b11298b9cdfe7a85e001/vignettes/uninformativeSingleFunnel11.pdf --------------------------------------------------------------------------------