SKAT_one_window: Run SKAT, optionally obtaining permuted p-values or empirical...

View source: R/SKAT_one_window.R

SKAT_one_windowR Documentation

Run SKAT, optionally obtaining permuted p-values or empirical p-value, and organize results into a vector to be added to dataframe of results

Description

Run SKAT, optionally obtaining permuted p-values or empirical p-value, and organize results into a vector to be added to dataframe of results

Usage

SKAT_one_window(
  this_position,
  Z,
  scaffold_ID,
  null_model,
  n_permutations,
  resampling = FALSE,
  return_all_p_vals = FALSE,
  missing_cutoff = 0.15,
  ...
)

Arguments

this_position

Integer indicating the center of a given SNP window (in base pairs)

Z

Matrix with row for each genotype in the SNP dataset, columns for each SNP in the SNP window of interest, and numeric values of 0, 1, 2 indicating number of alternative alleles for each SNP in each genotype (or NA for indels or missing data)

scaffold_ID

Integer indicating the chromosome or scaffold of interest

null_model

Object generated by SKAT_Null_Model

n_permutations

Integer indicating the number of permutations used to calculate empirical p-values

resampling

If TRUE, will call calculate_SKAT_empirical_p to calculate an empirical p-value or obtain a vector of permuted p-values. If FALSE, will pass NA in place of an empirical p-value

return_all_p_vals

If 'TRUE', will return a vector of all permuted p-values (useful for when not all permutations can fit into memory available for a single thread); if 'FALSE', will calculate and return the empirical p-value

missing_cutoff

A numeric threshold representing the minimum desired missing rate; missing rate is defined for each SNP as the proportion of genotypes missing data for the given SNP. Imputation to mean is performed , either by 'pre_allocate' or 'SKAT' itself, for all remaining missing values

...

Additional parameters passed on to SKAT

Value

If not returning all permuted p-values (as indicated by 'return_all_p_vals', the output will be a vector of length 4, containing 'scaffold_ID', 'this_position', the model p-value, and finally the empirical p-value (if applicable; otherwise NA). If returning all p-values, the length of the output vector will be two (for SNP scaffold and window center position) plus the number of permutations

Examples

data("small_pre_allocated_windows")
sample_null_model <- SKAT::SKAT_Null_Model(
  small_phenodata ~ 1 + as.matrix(small_covariates), out_type="C",
  n.Resampling = 1000)

SKAT_one_window(
  this_position = small_pre_allocated_windows[[1]][[1]],
  Z = small_pre_allocated_windows[[1]][[2]],
  scaffold_ID = small_pre_allocated_windows[[1]][[3]],
  n_permutations = 1000,
  null_model = sample_null_model,
  resampling = TRUE,
  return_all_p = FALSE)

naglemi/mtmcskat documentation built on Aug. 23, 2023, 5:35 p.m.