From 023708e7cb93319b722e474825e978f4d8fd8f17 Mon Sep 17 00:00:00 2001 From: Qiong Yang Date: Mon, 2 Dec 2024 21:09:55 -0500 Subject: [PATCH] modify the function to add an imputed option and field of imputed dosage for admixDataList that contains SeqVarIterator --- GENESIS | 1 + R/admixMap.R | 15 +++++++++++---- man/admixMap.Rd | 5 ++++- 3 files changed, 16 insertions(+), 5 deletions(-) create mode 160000 GENESIS diff --git a/GENESIS b/GENESIS new file mode 160000 index 0000000..dd2a91b --- /dev/null +++ b/GENESIS @@ -0,0 +1 @@ +Subproject commit dd2a91b06fe7361fd399f9df2d9dc0430b118f9b diff --git a/R/admixMap.R b/R/admixMap.R index 7c46ccd..ce4ad0a 100644 --- a/R/admixMap.R +++ b/R/admixMap.R @@ -1,6 +1,7 @@ admixMap <- function(admixDataList, null.model, - male.diploid=TRUE, genome.build=c("hg19", "hg38"), + male.diploid=TRUE, genome.build=c("hg19", "hg38"),imputed=FALSE, + dosage.field="DS", BPPARAM=bpparam(), verbose=TRUE){ # if admixDataList is one file, convert to a list @@ -15,7 +16,7 @@ admixMap <- function(admixDataList, if(is.null(names(admixDataList))){ names(admixDataList) <- paste("Anc",1:v,sep="") } - + # get sample index if (is(admixDataList[[1]], "GenotypeIterator")) { sample.index <- lapply(admixDataList, .sampleIndexNullModel, null.model) @@ -30,6 +31,10 @@ admixMap <- function(admixDataList, } n.samp <- length(sample.index) + # if admixDataList contain GenotypeIterator, imputed=TRUE will be ignored + if (is(admixDataList[[1]], "GenotypeIterator") && imputed=TRUE) + print("admixDataList contain GenotypeIterator, imputed=TRUE is ignored") + # get sex for calculating allele freq sex <- validateSex(admixDataList[[1]])[sample.index] @@ -81,8 +86,10 @@ admixMap <- function(admixDataList, if (is(admixDataList[[1]], "GenotypeIterator")) { local[,,i] <- getGenotypeSelection(admixDataList[[i]], scan=sample.index, order="selection", transpose=TRUE, use.names=FALSE, drop=FALSE) } else { - # local[,,i] <- refDosage(admixDataList[[i]], use.names=FALSE)[sample.index,,drop=FALSE] - local[,,i] <- imputedDosage(admixDataList[[i]], use.names=FALSE)[sample.index,,drop=FALSE] + if(imputed=FALSE){ + local[,,i] <- refDosage(admixDataList[[i]], use.names=FALSE)[sample.index,,drop=FALSE] + }else + local[,,i] <- imputedDosage(admixDataList[[i]], use.names=FALSE,dosage.field="DS")[sample.index,,drop=FALSE] } } diff --git a/man/admixMap.Rd b/man/admixMap.Rd index aa177f0..8917fb7 100644 --- a/man/admixMap.Rd +++ b/man/admixMap.Rd @@ -7,7 +7,8 @@ Run admixture analyses } \usage{ admixMap(admixDataList, null.model, male.diploid=TRUE, - genome.build=c("hg19", "hg38"), + genome.build=c("hg19", "hg38"),imputed=FALSE, + dosage.field="DS", BPPARAM=bpparam(), verbose=TRUE) } @@ -16,6 +17,8 @@ admixMap(admixDataList, null.model, male.diploid=TRUE, \item{null.model}{A null model object returned by \code{\link{fitNullModel}}.} \item{male.diploid}{Logical for whether males on sex chromosomes are coded as diploid. Default is `male.diploid=TRUE`, meaning sex chromosome genotypes for males have values 0/2. If the input object codes males as 0/1 on sex chromosomes, set `male.diploid=FALSE`.} \item{genome.build}{A character sting indicating genome build; used to identify pseudoautosomal regions on the X and Y chromosomes. These regions are not treated as sex chromosomes when calculating allele frequencies.} + \item{imputed}{Logical indicator of whether to read dosages from the field specified in `dosage.field`,containing imputed dosages instead of counting the number of ref alleles. Only relevant when admixDataList contains \code{\link{SeqVarIterator}}, i.e. ignored when admixDataList contains \code{\link{GenotypeIterator}} } + \item{dosage.field}{The name of the dosage field in the GDS object (will be prepended with "annotation/format"). Default is dosage.field='DS'.} \item{BPPARAM}{A \code{\link{BiocParallelParam}} object to process blocks of variants in parallel. If not provided, the default back-end returned by \code{\link{bpparam}} will be used.} \item{verbose}{Logical indicator of whether updates from the function should be printed to the console; the default is TRUE.} }