R/check_geno.R

Defines functions check_geno

Documented in check_geno

#' Check to see if the any markers in the supplied
#' genotype matrix is one of the covariates.
#'
#' @param genotype The vector of genotype values for
#' a single marker
#' @param covar_table The table of covariates
#' 
#' @return covariates indices that match the genotype
#' @keywords internal
#'
check_geno <- function(genotype, covar_table){
  
  if(is.null(covar_table)){
    return(NULL)
  }
  
  covar_which <- NULL
  geno <- as.vector(genotype[,1])
  for(i in 1:ncol(covar_table)){
    
    if(identical(as.vector(covar_table[,i]), geno)){
      covar_which <- c(covar_which, i)
    }
  }
  
  return(covar_which)
}

Try the cape package in your browser

Any scripts or data that you put into this service are public.

cape documentation built on Feb. 10, 2021, 5:06 p.m.