diff --git a/R/Indiv_Score_Test_Region.R b/R/Indiv_Score_Test_Region.R index 894d7ab..0042ca2 100644 --- a/R/Indiv_Score_Test_Region.R +++ b/R/Indiv_Score_Test_Region.R @@ -13,6 +13,8 @@ #' defining rare variants (default = 0.01). #' @param rv_num_cutoff the cutoff of minimum number of variants of analyzing #' a given variant-set (default = 2). +#' @param rv_num_cutoff_max the cutoff of maximum number of variants of analyzing +#' a given variant-set (default = 1e+09). #' @return A data frame with p rows corresponding to the p genetic variants in the given variant-set #' and three columns: \code{Score} (the score test statistic), \code{SE} (the standard error associated #' with the score test statistic), and \code{pvalue} (the score test p-value). @@ -25,7 +27,8 @@ #' @export Indiv_Score_Test_Region <- function(genotype,obj_nullmodel, - rare_maf_cutoff=0.01,rv_num_cutoff=2){ + rare_maf_cutoff=0.01,rv_num_cutoff=2, + rv_num_cutoff_max=1e9){ if(class(genotype)[1] != "matrix" && !(!is.null(attr(class(genotype), "package")) && attr(class(genotype), "package") == "Matrix")){ stop("genotype is not a matrix!") @@ -50,6 +53,10 @@ Indiv_Score_Test_Region <- function(genotype,obj_nullmodel, rm(genotype,MAF) gc() + if(sum(RV_label) >= rv_num_cutoff_max){ + stop(paste0("Number of rare variant in the set is more than ",rv_num_cutoff_max,"!")) + } + if(sum(RV_label) >= rv_num_cutoff){ G <- as(Geno_rare,"dgCMatrix") rm(Geno_rare) diff --git a/R/Indiv_Score_Test_Region_cond.R b/R/Indiv_Score_Test_Region_cond.R index bba72a0..58585c1 100644 --- a/R/Indiv_Score_Test_Region_cond.R +++ b/R/Indiv_Score_Test_Region_cond.R @@ -19,6 +19,8 @@ #' defining rare variants (default = 0.01). #' @param rv_num_cutoff the cutoff of minimum number of variants of analyzing #' a given variant-set (default = 2). +#' @param rv_num_cutoff_max the cutoff of maximum number of variants of analyzing +#' a given variant-set (default = 1e+09). #' @param method_cond a character value indicating the method for conditional analysis. #' \code{optimal} refers to regressing residuals from the null model on \code{genotype_adj} #' as well as all covariates used in fitting the null model (fully adjusted) and taking the residuals; @@ -41,6 +43,7 @@ Indiv_Score_Test_Region_cond <- function(genotype,genotype_adj,obj_nullmodel, rare_maf_cutoff=0.01,rv_num_cutoff=2, + rv_num_cutoff_max=1e9, method_cond=c("optimal","naive")){ method_cond <- match.arg(method_cond) # evaluate choices @@ -75,6 +78,10 @@ Indiv_Score_Test_Region_cond <- function(genotype,genotype_adj,obj_nullmodel, rm(genotype,MAF) gc() + if(sum(RV_label) >= rv_num_cutoff_max){ + stop(paste0("Number of rare variant in the set is more than ",rv_num_cutoff_max,"!")) + } + if(sum(RV_label) >= rv_num_cutoff){ G <- as(Geno_rare,"dgCMatrix") rm(Geno_rare) diff --git a/man/Indiv_Score_Test_Region.Rd b/man/Indiv_Score_Test_Region.Rd index e2a86fe..c9d524f 100644 --- a/man/Indiv_Score_Test_Region.Rd +++ b/man/Indiv_Score_Test_Region.Rd @@ -8,7 +8,8 @@ Indiv_Score_Test_Region( genotype, obj_nullmodel, rare_maf_cutoff = 0.01, - rv_num_cutoff = 2 + rv_num_cutoff = 2, + rv_num_cutoff_max = 1e+09 ) } \arguments{ @@ -25,6 +26,9 @@ defining rare variants (default = 0.01).} \item{rv_num_cutoff}{the cutoff of minimum number of variants of analyzing a given variant-set (default = 2).} + +\item{rv_num_cutoff_max}{the cutoff of maximum number of variants of analyzing +a given variant-set (default = 1e+09).} } \value{ A data frame with p rows corresponding to the p genetic variants in the given variant-set diff --git a/man/Indiv_Score_Test_Region_cond.Rd b/man/Indiv_Score_Test_Region_cond.Rd index f7fcf63..63936c4 100644 --- a/man/Indiv_Score_Test_Region_cond.Rd +++ b/man/Indiv_Score_Test_Region_cond.Rd @@ -10,6 +10,7 @@ Indiv_Score_Test_Region_cond( obj_nullmodel, rare_maf_cutoff = 0.01, rv_num_cutoff = 2, + rv_num_cutoff_max = 1e+09, method_cond = c("optimal", "naive") ) } @@ -33,6 +34,9 @@ defining rare variants (default = 0.01).} \item{rv_num_cutoff}{the cutoff of minimum number of variants of analyzing a given variant-set (default = 2).} +\item{rv_num_cutoff_max}{the cutoff of maximum number of variants of analyzing +a given variant-set (default = 1e+09).} + \item{method_cond}{a character value indicating the method for conditional analysis. \code{optimal} refers to regressing residuals from the null model on \code{genotype_adj} as well as all covariates used in fitting the null model (fully adjusted) and taking the residuals;