Skip to content

Commit

Permalink
Fixed spelling, other bugs found using R CMD check
Browse files Browse the repository at this point in the history
  • Loading branch information
rohan-shah committed Mar 24, 2016
1 parent c9a5ad0 commit c6fb28e
Show file tree
Hide file tree
Showing 24 changed files with 71 additions and 57 deletions.
9 changes: 7 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ Depends:
igraph,
Rcpp,
fastcluster,
pryr
pryr,
nnls
Imports:
ggplot2,
Matrix
Matrix,
methods
LinkingTo: Rcpp
Collate:
'Rcpp_exceptions.R'
Expand All @@ -34,6 +36,7 @@ Collate:
'mpcross-class.R'
'biparentalDominant.R'
'combineGenotypes.R'
'compressedProbabilities.R'
'detailedPedigree-class.R'
'eightWayPedigreeRandomFunnels.R'
'eightWayPedigreeSingleFunnel.R'
Expand All @@ -42,6 +45,7 @@ Collate:
'expand.R'
'f2Pedigree.R'
'finals.R'
'fixedNumberOfFounderAlleles.R'
'formGroups.R'
'founders.R'
'fourParentPedigreeRandomFunnels.R'
Expand All @@ -50,6 +54,7 @@ Collate:
'hetData.R'
'impute.R'
'imputeFounders.R'
'jitterMap.R'
'mapFunctions.R'
'markers.R'
'mpcross.R'
Expand Down
6 changes: 4 additions & 2 deletions DESCRIPTION.in
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ Depends:
methods,
igraph,
fastcluster,
pryr
pryr,
nnls
Imports:
ggplot2,
Matrix
Matrix,
methods
2 changes: 1 addition & 1 deletion R/biparentalDominant.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ setClass("biparentalDominant", contains="NULL")
#' cross <- simulateMPCross(map = map, pedigree = f2Pedigree, mapFunction = haldane, seed = 1)
#' founders(cross)
#' finals(cross)[1:10,]
#' The heterozygotes are initially coded as 3
#' #The heterozygotes are initially coded as 3
#' hetData(cross)[[1]]
#' #Make all markers dominant
#' dominantCross <- cross + biparentalDominant()
Expand Down
6 changes: 6 additions & 0 deletions R/detailedPedigree-class.R
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ NULL
.detailedPedigree <- setClass("detailedPedigree", contains = "pedigree", slots = list(initial = "integer", observed = "logical"), validity = checkDetailedPedigree)
#' @export
#' @describeIn detailedPedigree-class Construct object of class detailedPedigree
#' @param lineNames The names assigned to the lines
#' @param mother The female parent of this line
#' @param father The male parent of this line
#' @param initial The indices of the founder lines in the pedigree
#' @param observed A logical vector determining which lines are observed in the final population
#' @param selfing Value determining whether or not subsequent analysis of populations generated from this pedigree should assume infinite generations of selfing. Possible values are \code{"finite"} and \code{"infinite"}.
detailedPedigree <- function(lineNames, mother, father, initial, observed, selfing)
{
mother <- as.integer(mother)
Expand Down
2 changes: 0 additions & 2 deletions R/estimateMap.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ estimateMap <- function(mpcrossLG, mapFunction = rfToHaldane, maxOffset = 1)
b <- rfData[indices]
#Values of 0.5 result in infinite estimated distance, which doesn't really work.
b[b == 0.5] <- 0.49
if (!requireNamespace("nnls", quietly=TRUE))
stop("nnls needed for computemap to work. Please install it.\n", call.=FALSE)
result <- nnls::nnls(d, mapFunction(b))
map[[as.character(group)]] <- c(0, cumsum(result$x[which(indices[,1] == indices[,2]+1)]))
names(map[[as.character(group)]]) <- rfData@markers
Expand Down
2 changes: 1 addition & 1 deletion R/mpcross.R
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ setMethod(f = "+", signature = c("mpcrossRF", "mpcross"), definition = function(
stop("Internal error: Markers should have been combined as two blocks")
}
marker2Range <- range(match(markers(e2), markers(combined)))
extraRFData <- estimateRFInternal(object = combined, recombValues = e1@rf@r, lineWeights = rep(1, nLines(e2)), marker1Range = marker1Range, marker2Range = marker2Range, keepLod = keepLod, keepLkhd = keepLkhd, gbLimit = e1@rf@gbLimit, verbose = list(verbose = FALSE, progressStyle = 1L))
extraRFData <- estimateRFInternal(object = combined, recombValues = e1@rf@r, lineWeights = rep(1, nLines(e2)), markerRows = marker1Range, markerColumns = marker2Range, keepLod = keepLod, keepLkhd = keepLkhd, gbLimit = e1@rf@gbLimit, verbose = list(verbose = FALSE, progressStyle = 1L))
stop("Need to check this section")
}
#If the markers are all the same, keep them in the same order
Expand Down
3 changes: 3 additions & 0 deletions R/roxygen.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
#' @import qtl
#' @import igraph
#' @import methods
#' @importFrom pryr address
#' @importFrom nnls nnls
#' @exportClass pedigreeGraph
#' @exportMethod subset
#' @exportMethod plot
#' @importClassesFrom Matrix index dspMatrix dppMatrix
#' @importFrom methods setClass
#' @useDynLib mpMap2
NULL
2 changes: 1 addition & 1 deletion src/estimateRFSpecificDesign.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ bool toInternalArgs(estimateRFSpecificDesignArgs&& args, rfhaps_internal_args& i
{
try
{
Rcpp::Rcout << "Input data had hetrozygotes but was analysed assuming infinite selfing. " << std::endl << " All hetrozygotes were ignored." << std::endl;
Rcpp::Rcout << "Input data had heterozygotes but was analysed assuming infinite selfing. " << std::endl << " All hetrozygotes were ignored." << std::endl;
}
catch(...)
{}
Expand Down
2 changes: 1 addition & 1 deletion src/estimateRFSpecificDesign.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ bool estimateRFSpecificDesign(rfhaps_internal_args& internal_args, unsigned long
* 3. Check that the data is consistent with the input funnels.
* 4. Recode the founders and finals data in a normalised form, also working out the maximum number of alleles per marker, across the dataset
* 5. Assign a unique value to each marker pattern and funnel.
* 6. In the case of infinite generations of selfing, replace hetrozygote values with NA.
* 6. In the case of infinite generations of selfing, replace heterozygote values with NA.
* @param args Input arguments
* @param internalArgs preprocessed arguments
* @return A boolean value, with true indicating success. False indicates an error.
Expand Down
30 changes: 15 additions & 15 deletions src/imputeFounders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "funnelHaplotypeToMarker.hpp"
#include "viterbi.hpp"
#include "recodeHetsAsNA.h"
template<int nFounders, bool infiniteSelfing> void imputedFoundersInternal2(Rcpp::IntegerMatrix founders, Rcpp::IntegerMatrix finals, Rcpp::S4 pedigree, Rcpp::List hetData, Rcpp::List map, Rcpp::IntegerMatrix results, double homozygoteMissingProb, double hetrozygoteMissingProb, Rcpp::IntegerMatrix key)
template<int nFounders, bool infiniteSelfing> void imputedFoundersInternal2(Rcpp::IntegerMatrix founders, Rcpp::IntegerMatrix finals, Rcpp::S4 pedigree, Rcpp::List hetData, Rcpp::List map, Rcpp::IntegerMatrix results, double homozygoteMissingProb, double heterozygoteMissingProb, Rcpp::IntegerMatrix key)
{
//Work out maximum number of markers per chromosome
int maxChromosomeMarkers = 0;
Expand Down Expand Up @@ -66,7 +66,7 @@ template<int nFounders, bool infiniteSelfing> void imputedFoundersInternal2(Rcpp
//Technically a warning could lead to an error if options(warn=2). This would be bad because it would break out of our code. This solution generates a c++ exception in that case, which we can then ignore.
try
{
warning("Input data had hetrozygotes but was analysed assuming infinite selfing. All hetrozygotes were ignored. \n");
warning("Input data had heterozygotes but was analysed assuming infinite selfing. All heterozygotes were ignored. \n");
}
catch(...)
{}
Expand Down Expand Up @@ -157,7 +157,7 @@ template<int nFounders, bool infiniteSelfing> void imputedFoundersInternal2(Rcpp
viterbi.results = results;
viterbi.key = key;
viterbi.homozygoteMissingProb = homozygoteMissingProb;
viterbi.hetrozygoteMissingProb = hetrozygoteMissingProb;
viterbi.heterozygoteMissingProb = heterozygoteMissingProb;
viterbi.intercrossingSingleLociHaplotypeProbabilities = &intercrossingSingleLociHaplotypeProbabilities;
viterbi.funnelSingleLociHaplotypeProbabilities = &funnelSingleLociHaplotypeProbabilities;

Expand Down Expand Up @@ -188,18 +188,18 @@ template<int nFounders, bool infiniteSelfing> void imputedFoundersInternal2(Rcpp
cumulativeMarkerCounter += (int)positions.size();
}
}
template<int nFounders> void imputedFoundersInternal1(Rcpp::IntegerMatrix founders, Rcpp::IntegerMatrix finals, Rcpp::S4 pedigree, Rcpp::List hetData, Rcpp::List map, Rcpp::IntegerMatrix results, bool infiniteSelfing, double homozygoteMissingProb, double hetrozygoteMissingProb, Rcpp::IntegerMatrix key)
template<int nFounders> void imputedFoundersInternal1(Rcpp::IntegerMatrix founders, Rcpp::IntegerMatrix finals, Rcpp::S4 pedigree, Rcpp::List hetData, Rcpp::List map, Rcpp::IntegerMatrix results, bool infiniteSelfing, double homozygoteMissingProb, double heterozygoteMissingProb, Rcpp::IntegerMatrix key)
{
if(infiniteSelfing)
{
imputedFoundersInternal2<nFounders, true>(founders, finals, pedigree, hetData, map, results, homozygoteMissingProb, hetrozygoteMissingProb, key);
imputedFoundersInternal2<nFounders, true>(founders, finals, pedigree, hetData, map, results, homozygoteMissingProb, heterozygoteMissingProb, key);
}
else
{
imputedFoundersInternal2<nFounders, false>(founders, finals, pedigree, hetData, map, results, homozygoteMissingProb, hetrozygoteMissingProb, key);
imputedFoundersInternal2<nFounders, false>(founders, finals, pedigree, hetData, map, results, homozygoteMissingProb, heterozygoteMissingProb, key);
}
}
SEXP imputeFounders(SEXP geneticData_sexp, SEXP map_sexp, SEXP homozygoteMissingProb_sexp, SEXP hetrozygoteMissingProb_sexp)
SEXP imputeFounders(SEXP geneticData_sexp, SEXP map_sexp, SEXP homozygoteMissingProb_sexp, SEXP heterozygoteMissingProb_sexp)
{
BEGIN_RCPP
Rcpp::S4 geneticData;
Expand Down Expand Up @@ -296,16 +296,16 @@ BEGIN_RCPP
}
if(homozygoteMissingProb < 0 || homozygoteMissingProb > 1) throw std::runtime_error("Input homozygoteMissingProb must be a number between 0 and 1");

double hetrozygoteMissingProb;
double heterozygoteMissingProb;
try
{
hetrozygoteMissingProb = Rcpp::as<double>(hetrozygoteMissingProb_sexp);
heterozygoteMissingProb = Rcpp::as<double>(heterozygoteMissingProb_sexp);
}
catch(...)
{
throw std::runtime_error("Input hetrozygoteMissingProb must be a number between 0 and 1");
throw std::runtime_error("Input heterozygoteMissingProb must be a number between 0 and 1");
}
if(hetrozygoteMissingProb < 0 || hetrozygoteMissingProb > 1) throw std::runtime_error("Input hetrozygoteMissingProb must be a number between 0 and 1");
if(heterozygoteMissingProb < 0 || heterozygoteMissingProb > 1) throw std::runtime_error("Input heterozygoteMissingProb must be a number between 0 and 1");

std::vector<std::string> foundersMarkers = Rcpp::as<std::vector<std::string> >(Rcpp::colnames(founders));
std::vector<std::string> finalsMarkers = Rcpp::as<std::vector<std::string> >(Rcpp::colnames(finals));
Expand Down Expand Up @@ -378,19 +378,19 @@ BEGIN_RCPP
{
if(nFounders == 2)
{
imputedFoundersInternal1<2>(founders, finals, pedigree, hetData, map, results, infiniteSelfing, homozygoteMissingProb, hetrozygoteMissingProb, key);
imputedFoundersInternal1<2>(founders, finals, pedigree, hetData, map, results, infiniteSelfing, homozygoteMissingProb, heterozygoteMissingProb, key);
}
else if(nFounders == 4)
{
imputedFoundersInternal1<4>(founders, finals, pedigree, hetData, map, results, infiniteSelfing, homozygoteMissingProb, hetrozygoteMissingProb, key);
imputedFoundersInternal1<4>(founders, finals, pedigree, hetData, map, results, infiniteSelfing, homozygoteMissingProb, heterozygoteMissingProb, key);
}
else if(nFounders == 8)
{
imputedFoundersInternal1<8>(founders, finals, pedigree, hetData, map, results, infiniteSelfing, homozygoteMissingProb, hetrozygoteMissingProb, key);
imputedFoundersInternal1<8>(founders, finals, pedigree, hetData, map, results, infiniteSelfing, homozygoteMissingProb, heterozygoteMissingProb, key);
}
else if(nFounders == 16)
{
imputedFoundersInternal1<16>(founders, finals, pedigree, hetData, map, results, infiniteSelfing, homozygoteMissingProb, hetrozygoteMissingProb, key);
imputedFoundersInternal1<16>(founders, finals, pedigree, hetData, map, results, infiniteSelfing, homozygoteMissingProb, heterozygoteMissingProb, key);
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/probabilities16.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ template<> struct probabilityData<16>
public:
/*See Karl Bromans paper on intermediate generations. This mask converts allele encodings (0 - 2) into indices into
the array of 4 different probabilities. In terms of indices,
Zero = homozygote, One = other homozygote, Two = hetrozygote
Zero = homozygote, One = other homozygote, Two = heterozygote
In terms of values, see Table one of the paper. Zero = first equation of table, one = second equation, etc. Note that
we combine equations 4 and 5 into a single state.
*/
Expand Down
8 changes: 4 additions & 4 deletions src/probabilities2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ template<> void genotypeProbabilitiesNoIntercross<2, false>(std::array<double, 5
prob[0] = (1/(2*(1 + 2*r))) -std::pow(0.5, selfingGenerations+2)*(2 - quadraticPower + oneMinusTwoRPower*(1 - 2 *r)/ ( 1 + 2*r));
//Different homozygotes at both
prob[1] = (r/(1 + 2*r)) -std::pow(0.5, selfingGenerations+2)*(2 - quadraticPower - oneMinusTwoRPower*(1 - 2 *r)/ ( 1 + 2*r));
//One homozygote, one hetrozygote
//One homozygote, one heterozygote
prob[2] = std::pow(0.5, selfingGenerations+1) * (1 - quadraticPower);
//Two hetrozygotes. We don't distinguish between the two different hetrozygote combinations
//Two heterozygotes. We don't distinguish between the two different heterozygote combinations
prob[3] = std::pow(0.5, selfingGenerations) * quadraticPower;
//But we might want to allow us to get back to the seperate probabilities in code that calls this function, so compute the probability for state 4 by itself.
prob[4] = std::pow(0.5, selfingGenerations-1) * (quadraticPower - oneMinusTwoRPower);

//The hetrozygotes will be counted twice, so divide by two (or four if there are two hetrozygotes).
//The heterozygotes will be counted twice, so divide by two (or four if there are two heterozygotes).
prob[2] /= 2;
prob[3] /= 4;
prob[4] /= 4;
Expand Down Expand Up @@ -86,7 +86,7 @@ template<> void genotypeProbabilitiesWithIntercross<2, false>(std::array<double,
0.25*(-2*powOneMinus2R*powOneMinusR
+ (oneMinusRSquared + oneMinusTwoRSquared*powOneMinusRSquared)*quadraticPower
)/(8*pow2*oneMinusRSquared);
//We don't distinguish between the two hetrozygote combinations
//We don't distinguish between the two heterozygote combinations
prob[3] += prob[4];
}
template<> void singleLocusGenotypeProbabilitiesNoIntercross<2, true>(array2<2>&data, int selfingGenerations, std::size_t nFunnels)
Expand Down
2 changes: 1 addition & 1 deletion src/probabilities2.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ template<> struct probabilityData<2>
public:
/*See Karl Bromans paper on intermediate generations. This mask converts allele encodings (0 - 2) into indices into
the array of 4 different probabilities. In terms of indices,
Zero = homozygote, One = other homozygote, Two = hetrozygote
Zero = homozygote, One = other homozygote, Two = heterozygote
In terms of values, see Table one of the paper. Zero = first equation of table, one = second equation, etc. Note that
we combine equations 4 and 5 into a single state.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/probabilities4.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ template<> struct probabilityData<4>
public:
/*See Karl Bromans paper on intermediate generations. This mask converts allele encodings (0 - 2) into indices into
the array of 4 different probabilities. In terms of indices,
Zero = homozygote, One = other homozygote, Two = hetrozygote
Zero = homozygote, One = other homozygote, Two = heterozygote
In terms of values, see Table one of the paper. Zero = first equation of table, one = second equation, etc. Note that
we combine equations 4 and 5 into a single state.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/probabilities8.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ template<> struct probabilityData<8>
public:
/*See Karl Bromans paper on intermediate generations. This mask converts allele encodings (0 - 2) into indices into
the array of 4 different probabilities. In terms of indices,
Zero = homozygote, One = other homozygote, Two = hetrozygote
Zero = homozygote, One = other homozygote, Two = heterozygote
In terms of values, see Table one of the paper. Zero = first equation of table, one = second equation, etc. Note that
we combine equations 4 and 5 into a single state.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/recodeFoundersFinalsHets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void recodeFoundersFinalsHets(recodeDataStruct& inputs)
recodedCurrentMarkerHetData(i, 2) = recodedCurrentMarkerHetData(i, 0);
}
}
//The homozygotes get translated as-is, the hetrozygotes are given sequential labels afterwards.
//The homozygotes get translated as-is, the heterozygotes are given sequential labels afterwards.
std::sort(hetValues.begin(), hetValues.end());
hetValues.erase(std::unique(hetValues.begin(), hetValues.end()), hetValues.end());
inputs.maxAlleles = std::max(inputs.maxAlleles, (unsigned int)(nFounderAlleles + hetValues.size()));
Expand Down
Loading

0 comments on commit c6fb28e

Please sign in to comment.