Skip to content

Commit

Permalink
STAARpipeline v0.9.7
Browse files Browse the repository at this point in the history
  • Loading branch information
xihaoli committed May 19, 2024
1 parent 65adc9d commit 4df08b4
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 60 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name: R-CMD-check

jobs:
R-CMD-check:
runs-on: macOS-latest
runs-on: macOS-13
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Package: STAARpipeline
Type: Package
Title: STAARpipeline for Analyzing Whole-Genome/Whole-Exome Sequencing Data
Version: 0.9.7
Date: 2023-11-09
Date: 2024-05-19
Author: Xihao Li [aut, cre], Zilin Li [aut, cre], Sheila M. Gaynor [aut], Han Chen [aut]
Maintainer: Xihao Li <[email protected]>, Zilin Li <[email protected]>
Description: An R package for performing STAARpipeline in analyzing whole-genome/whole-exome sequencing data.
Expand Down
15 changes: 1 addition & 14 deletions R/Individual_Analysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,13 @@ Individual_Analysis <- function(chr,start_loc,end_loc,genofile,obj_nullmodel,mac
}

## residuals and cov
residuals.phenotype <- as.vector(obj_nullmodel$scaled.residuals)
if(SPA_p_filter)
{
### dense GRM
if(!obj_nullmodel$sparse_kins)
{
P <- obj_nullmodel$P
P_scalar <- sqrt(dim(P)[1])
P <- P*P_scalar

residuals.phenotype <- as.vector(obj_nullmodel$scaled.residuals)
residuals.phenotype <- residuals.phenotype*sqrt(P_scalar)
}

### sparse GRM
Expand All @@ -75,12 +71,7 @@ Individual_Analysis <- function(chr,start_loc,end_loc,genofile,obj_nullmodel,mac
Sigma_i <- obj_nullmodel$Sigma_i
Sigma_iX <- as.matrix(obj_nullmodel$Sigma_iX)
cov <- obj_nullmodel$cov

residuals.phenotype <- as.vector(obj_nullmodel$scaled.residuals)
}
}else
{
residuals.phenotype <- as.vector(obj_nullmodel$scaled.residuals)
}

## SPA
Expand Down Expand Up @@ -110,10 +101,6 @@ Individual_Analysis <- function(chr,start_loc,end_loc,genofile,obj_nullmodel,mac
if(!obj_nullmodel$sparse_kins)
{
P <- obj_nullmodel$P
P_scalar <- sqrt(dim(P)[1])
P <- P*P_scalar

residuals.phenotype <- residuals.phenotype*sqrt(P_scalar)
}

### sparse GRM
Expand Down
27 changes: 3 additions & 24 deletions R/Individual_Analysis_cond.R
Original file line number Diff line number Diff line change
Expand Up @@ -218,24 +218,7 @@ Individual_Analysis_cond <- function(chr,individual_results,genofile,obj_nullmod
if(!obj_nullmodel$sparse_kins)
{
P <- obj_nullmodel$P
P_scalar <- sqrt(dim(P)[1])
P <- P*P_scalar

residuals.phenotype <- obj_nullmodel$scaled.residuals
residuals.phenotype <- residuals.phenotype*sqrt(P_scalar)

if(method_cond == "optimal"){
residuals.phenotype.fit <- lm(residuals.phenotype~genotype_adj+obj_nullmodel$X-1)
}else{
residuals.phenotype.fit <- lm(residuals.phenotype~genotype_adj)
}

residuals.phenotype <- as.vector(residuals.phenotype.fit$residuals)
X_adj <- model.matrix(residuals.phenotype.fit)
if(n_pheno > 1)
{
X_adj <- as.matrix(Diagonal(n = n_pheno) %x% X_adj)
}
PX_adj <- P%*%X_adj
P_cond <- P - X_adj%*%solve(t(X_adj)%*%X_adj)%*%t(PX_adj) -
PX_adj%*%solve(t(X_adj)%*%X_adj)%*%t(X_adj) +
Expand All @@ -255,28 +238,24 @@ Individual_Analysis_cond <- function(chr,individual_results,genofile,obj_nullmod
}
}else
{
residuals.phenotype <- as.vector(obj_nullmodel$scaled.residuals)
### sparse GRM
if(obj_nullmodel$sparse_kins)
{
if(n_pheno == 1)
{
Score_test <- Individual_Score_Test(as.matrix(Geno[,k],ncol=1), Sigma_i, Sigma_iX, cov, obj_nullmodel$scaled.residuals)
Score_test <- Individual_Score_Test(as.matrix(Geno[,k],ncol=1), Sigma_i, Sigma_iX, cov, residuals.phenotype)
}
else
{
Score_test <- Individual_Score_Test_multi(as.matrix(Diagonal(n = n_pheno) %x% Geno[,k]), Sigma_i, Sigma_iX, cov, obj_nullmodel$scaled.residuals, n_pheno)
Score_test <- Individual_Score_Test_multi(as.matrix(Diagonal(n = n_pheno) %x% Geno[,k]), Sigma_i, Sigma_iX, cov, residuals.phenotype, n_pheno)
}
pvalue_cond_log10 <- c(pvalue_cond_log10,Score_test$pvalue_log/log(10))
}
### dense GRM
if(!obj_nullmodel$sparse_kins)
{
P <- obj_nullmodel$P
P_scalar <- sqrt(dim(P)[1])
P <- P*P_scalar

residuals.phenotype <- as.vector(obj_nullmodel$scaled.residuals)
residuals.phenotype <- residuals.phenotype*sqrt(P_scalar)

if(n_pheno == 1)
{
Expand Down
16 changes: 1 addition & 15 deletions R/Individual_Analysis_cond_spa.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
#' The \code{Individual_Analysis_cond_spa} function takes in chromosome, starting location, ending location,
#' the object of opened annotated GDS file, and the object from fitting the null model to analyze the association between an
#' imbalanced case-control phenotype and each individual variant in a genetic region by using score test.
#' For multiple phenotype analysis (\code{obj_nullmodel$n.pheno > 1}),
#' the results correspond to multi-trait score test p-values by leveraging
#' the correlation structure between multiple phenotypes.
#' @param chr chromosome.
#' @param individual_results the data frame of (significant) individual variants for conditional analysis using score test.
#' The first 4 columns should correspond to chromosome (CHR), position (POS), reference allele (REF), and alternative allele (ALT).
Expand Down Expand Up @@ -44,17 +41,13 @@ Individual_Analysis_cond_spa <- function(chr,individual_results,genofile,obj_nul
samplesize <- length(phenotype.id)

## residuals and cov
residuals.phenotype <- as.vector(obj_nullmodel$scaled.residuals)
if(SPA_p_filter)
{
### dense GRM
if(!obj_nullmodel$sparse_kins)
{
P <- obj_nullmodel$P
P_scalar <- sqrt(dim(P)[1])
P <- P*P_scalar

residuals.phenotype <- as.vector(obj_nullmodel$scaled.residuals)
residuals.phenotype <- residuals.phenotype*sqrt(P_scalar)
}

### sparse GRM
Expand All @@ -63,15 +56,9 @@ Individual_Analysis_cond_spa <- function(chr,individual_results,genofile,obj_nul
Sigma_i <- obj_nullmodel$Sigma_i
Sigma_iX <- as.matrix(obj_nullmodel$Sigma_iX)
cov <- obj_nullmodel$cov

residuals.phenotype <- as.vector(obj_nullmodel$scaled.residuals)
}
}else
{
residuals.phenotype <- as.vector(obj_nullmodel$scaled.residuals)
}


## SPA
muhat <- obj_nullmodel$fitted.values

Expand All @@ -92,7 +79,6 @@ Individual_Analysis_cond_spa <- function(chr,individual_results,genofile,obj_nul
XXWX_inv <- obj_nullmodel$XXWX_inv
}


## get SNV id
filter <- seqGetData(genofile, QC_label)
if(variant_type=="variant")
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
[![R build status](https://github.com/xihaoli/STAARpipeline/workflows/R-CMD-check/badge.svg)](https://github.com/xihaoli/STAARpipeline/actions)
[![Build Status](https://travis-ci.com/xihaoli/STAARpipeline.svg?branch=main)](https://app.travis-ci.com/github/xihaoli/STAARpipeline)
[![Build status](https://ci.appveyor.com/api/projects/status/ltr225p13idh2934/branch/main?svg=true)](https://ci.appveyor.com/project/xihaoli/staarpipeline/branch/main)
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)

Expand Down Expand Up @@ -32,7 +31,7 @@ Please see the <a href="docs/STAARpipeline_manual.pdf">**STAARpipeline** user ma
## Data Availability
The whole-genome functional annotation data assembled from a variety of sources and the precomputed annotation principal components are available at the [Functional Annotation of Variant - Online Resource (FAVOR)](https://favor.genohub.org) site and [FAVOR Essential Database](https://doi.org/10.7910/DVN/1VGTJI).
## Version
The current version is 0.9.7 (February 16, 2024).
The current version is 0.9.7 (May 19, 2024).
## Citation
If you use **STAARpipeline** and **STAARpipelineSummary** for your work, please cite:

Expand Down
Binary file modified docs/STAARpipeline_manual.pdf
Binary file not shown.
3 changes: 0 additions & 3 deletions man/Individual_Analysis_cond_spa.Rd

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

0 comments on commit 4df08b4

Please sign in to comment.