Skip to content

Commit

Permalink
v0.40
Browse files Browse the repository at this point in the history
  • Loading branch information
jendelman committed Jan 23, 2024
1 parent 2f061fa commit 6853b89
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 24 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: polyBreedR
Title: Genomics-assisted breeding for polyploids (and diploids)
Version: 0.39
Version: 0.40
Author: Jeffrey B. Endelman
Maintainer: Jeffrey Endelman <[email protected]>
Description: Genomics-assisted breeding for polyploids (and diploids)
Expand Down
3 changes: 3 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Changes in 0.40
* OFP20 option in madc

Changes in 0.39
* Changed impute_PO to impute_LA to allow for other methods eventually (MAPpoly)

Expand Down
2 changes: 1 addition & 1 deletion R/impute_LA.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#' @export

impute_LA <- function(ped.file, high.file, low.file, low.format="GT",
out.file, n.thread=1) {
out.file) {

stopifnot(low.format %in% c("GT","AD"))

Expand Down
40 changes: 31 additions & 9 deletions R/madc.R
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
#' Multi-Allelic Haplotype Counts from DArTag
#' Multi-Allelic Haplotype Counts for potato DArTag
#'
#' Multi-Allelic Haplotype Counts from the DArTag MADC (Missing Allele Discovery Count) file
#' Multi-Allelic Haplotype Counts for potato DArTag
#'
#' Due to multi-allelism, for some trait markers a correct interpretation is not possible using the collapsed counts file; the MADC file is needed. Currently, the only marker implemented is CDF1 for potato DArTag. The CDF1 marker detects the 2C, 2T, and 4 alleles, and all other haplotypes are treated as allele 1. Allele 3 is not detected by the assay.
#' Due to multi-allelism, for some trait markers a correct interpretation is not possible using the collapsed counts file; the MADC (Missing Allele Discovery Count) file is needed.
#'
#' "CDF1" uses marker CDF1.4_chr05_4488021 to detect the 2C, 2T, and 4 alleles; all other haplotypes are treated as allele 1. Allele 3 is not detected by the assay.
#'
#' "OFP20" relies on three markers. Marker OFP20_M6_CDS_994 detects OFP20.1 as Alt and most other haplotypes as Ref, but some alleles appear to be NULL. Marker OFP20_M6_CDS_171 detects allele 2 as Alt and alleles 3 and 7 as Ref; other alleles are NULL. Marker OFP20_M6_CDS_24 detects allele 8 as Ref and most other alleles as Alt. Given the high allelic diversity at this locus, this function may not work in all germplasm groups.
#'
#' @param madc.file MADC filename
#' @param marker Name of marker ("CDF1" is only option so far)
#' @param marker Name of marker ("CDF1","OFP20")
#'
#' @return matrix of haplotype counts
#' @export
#' @importFrom data.table fread

madc <- function(madc.file, marker="CDF1") {
madc <- function(madc.file, marker) {

data <- fread(madc.file,skip=7)
tmp <- as.matrix(data[,17:ncol(data)])
id <- colnames(tmp)
n <- length(id)

if (toupper(marker)=="CDF1") {
data <- fread(madc.file,skip=7)
tmp <- as.matrix(data[,17:ncol(data)])
id <- colnames(tmp)
n <- length(id)
counts <- matrix(0,ncol=4,nrow=n,
dimnames=list(id,c("CDF1.1","CDF1.2T","CDF1.2C","CDF1.4")))
k <- which(data$AlleleID=="CDF1.4_chr05_4488021|Ref")
Expand Down Expand Up @@ -53,4 +58,21 @@ madc <- function(madc.file, marker="CDF1") {

return(counts)
}

if (toupper(marker)=="OFP20") {
x <- c("OFP20_M6_CDS_994|Ref","OFP20_M6_CDS_994|Alt","OFP20_M6_CDS_24|Ref","OFP20_M6_CDS_24|Alt","OFP20_M6_CDS_171|RefMatch","OFP20_M6_CDS_171|AltMatch")
ix <- match(x,data$AlleleID)
data2 <- t(tmp[ix,])
dimnames(data2) <- list(colnames(tmp),data$AlleleID[ix])
AF1 <- round(data2[,2]/apply(data2[,1:2],1,sum),2)
AF8 <- round(data2[,3]/apply(data2[,3:4],1,sum),2)
data3 <- data.frame(id=rownames(data2),
AF1=AF1,
AF8=AF8,
AD2=data2[,6],
'AD3&7'=data2[,5],check.names=F)
#AD8=data2[,1])
rownames(data3) <- NULL
return(data3)
}
}
Binary file modified docs/polyBreedR_Manual.pdf
Binary file not shown.
9 changes: 1 addition & 8 deletions man/impute_LA.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 9 additions & 5 deletions man/madc.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6853b89

Please sign in to comment.