R/RcppExports.R

Defines functions runElnet normalize genotypeMatrix repelnet elnet multiBed3sp multiBed3 countlines

Documented in countlines elnet genotypeMatrix multiBed3 multiBed3sp normalize repelnet runElnet

# Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393

#' Count number of lines in a text file
#' 
#' @param fileName Name of file
#' @keywords internal
#' 
countlines <- function(fileName) {
    .Call(`_ssCTPR_countlines`, fileName)
}

#' Multiply genotypeMatrix by a matrix
#' 
#' @param fileName location of bam file
#' @param N number of subjects 
#' @param P number of positions 
#' @param input the matrix
#' @param col_skip_pos which variants should we skip
#' @param col_skip which variants should we skip
#' @param keepbytes which bytes to keep
#' @param keepoffset what is the offset
#' @return an armadillo genotype matrix 
#' @keywords internal
#' 
multiBed3 <- function(fileName, N, P, input, col_skip_pos, col_skip, keepbytes, keepoffset, trace) {
    .Call(`_ssCTPR_multiBed3`, fileName, N, P, input, col_skip_pos, col_skip, keepbytes, keepoffset, trace)
}

#' Multiply genotypeMatrix by a matrix (sparse)
#' 
#' @param fileName location of bam file
#' @param N number of subjects 
#' @param P number of positions 
#' @param input the matrix
#' @param col_skip_pos which variants should we skip
#' @param col_skip which variants should we skip
#' @param keepbytes which bytes to keep
#' @param keepoffset what is the offset
#' @return an armadillo genotype matrix 
#' @keywords internal
#' 
multiBed3sp <- function(fileName, N, P, beta, nonzeros, colpos, ncol, col_skip_pos, col_skip, keepbytes, keepoffset, trace) {
    .Call(`_ssCTPR_multiBed3sp`, fileName, N, P, beta, nonzeros, colpos, ncol, col_skip_pos, col_skip, keepbytes, keepoffset, trace)
}

#' Performs elnet
#'
#' @param lambda1 lambda
#' @param lambda2 shrinkage parameter s
#' @param lambda_ct cross trait penalty
#' @param diag diag(X'X)
#' @param X genotype Matrix
#' @param r correlations
#' @param adj adjacency coefficients
#' @param thr threshold 
#' @param x beta coef
#' @param yhat A vector, X*x
#' @param trace if >1 displays the current iteration
#' @param maxiter maximal number of iterations
#' @return conv
#' @keywords internal
#' 
elnet <- function(lambda1, lambda2, lambda_ct, diag, X, r, adj, thr, x, yhat, trace, maxiter) {
    .Call(`_ssCTPR_elnet`, lambda1, lambda2, lambda_ct, diag, X, r, adj, thr, x, yhat, trace, maxiter)
}

#' performs elnet by blocks
#'
#' @param lambda1 lambda
#' @param lambda2 shrinkage parameter s
#' @param lambda_ct cross trait penalty
#' @param diag diag(X'X)
#' @param X genotype Matrix
#' @param r correlations
#' @param adj adjacency coefficients
#' @param thr threshold 
#' @param x beta coef
#' @param yhat A vector, X*x
#' @param trace if >1 displays the current iteration
#' @param maxiter maximal number of iterations
#' @param startvec start position for each block
#' @param endvec end position for each block
#' @return conv
#' @keywords internal
#'
repelnet <- function(lambda1, lambda2, lambda_ct, diag, X, r, adj, thr, x, yhat, trace, maxiter, startvec, endvec) {
    .Call(`_ssCTPR_repelnet`, lambda1, lambda2, lambda_ct, diag, X, r, adj, thr, x, yhat, trace, maxiter, startvec, endvec)
}

#' imports genotypeMatrix
#' 
#' @param fileName location of bam file
#' @param N number of subjects 
#' @param P number of positions 
#' @param col_skip_pos which variants should we skip
#' @param col_skip which variants should we skip
#' @param keepbytes which bytes to keep
#' @param keepoffset what is the offset
#' @return an armadillo genotype matrix 
#' @keywords internal
#' 
genotypeMatrix <- function(fileName, N, P, col_skip_pos, col_skip, keepbytes, keepoffset, fillmissing) {
    .Call(`_ssCTPR_genotypeMatrix`, fileName, N, P, col_skip_pos, col_skip, keepbytes, keepoffset, fillmissing)
}

#' normalize genotype matrix
#' 
#' @param genotypes a armadillo genotype matrix
#' @return standard deviation
#' @keywords internal
#' 
normalize <- function(genotypes) {
    .Call(`_ssCTPR_normalize`, genotypes)
}

#' Runs elnet with various parameters
#' 
#' @param lambda1 a vector of lambdas
#' @param shrink shrinkage parameter s
#' @param lambda_ct cross trait penalty parameter
#' @param fileName the file name of the reference panel
#' @param r a matrix of SNP-wise correlation with primary trait and/or beta estimates of secondary traits
#' @param adj a vector of SNP-wise adjacency coefficients between the primary and secondary traits
#' @param N number of individuals in the reference panel
#' @param P number of variants in reference file
#' @param col_skip_pos which variants should we skip
#' @param col_skip which variants should we skip
#' @param keepbytes required to read the PLINK file
#' @param keepoffset required to read the PLINK file
#' @param thr threshold
#' @param x a numeric vector of beta coefficients
#' @param trace if >1 verbose output
#' @param maxiter maximal number of iterations
#' @param startvec start position for each block
#' @param endvec end position for each block
#' @return a list of results
#' @keywords internal
#'  
runElnet <- function(lambda, shrink, lambda_ct, fileName, r, adj, N, P, col_skip_pos, col_skip, keepbytes, keepoffset, thr, x, trace, maxiter, startvec, endvec) {
    .Call(`_ssCTPR_runElnet`, lambda, shrink, lambda_ct, fileName, r, adj, N, P, col_skip_pos, col_skip, keepbytes, keepoffset, thr, x, trace, maxiter, startvec, endvec)
}

# Register entry points for exported C++ functions
methods::setLoadAction(function(ns) {
    .Call('_ssCTPR_RcppExport_registerCCallable', PACKAGE = 'ssCTPR')
})
yingxi-kaylee/ssCTPR documentation built on Nov. 14, 2021, 5:24 a.m.