Skip to content

Commit

Permalink
STAAR v0.9.7.2
Browse files Browse the repository at this point in the history
  • Loading branch information
xihaoli committed Nov 14, 2024
1 parent c9717bd commit 88016ac
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
9 changes: 8 additions & 1 deletion R/Indiv_Score_Test_Region.R
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand All @@ -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!")
Expand All @@ -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)
Expand Down
7 changes: 7 additions & 0 deletions R/Indiv_Score_Test_Region_cond.R
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 5 additions & 1 deletion man/Indiv_Score_Test_Region.Rd

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

4 changes: 4 additions & 0 deletions man/Indiv_Score_Test_Region_cond.Rd

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

0 comments on commit 88016ac

Please sign in to comment.