makeRandomGS: makeRandomGS

Description Usage Arguments Value Author(s) See Also Examples

Description

This function creates a random gene set of approximately the same composition (same number of genes with the same number of SNPs) as the specified gene set. As part of a gene set (pathway) analysis, this procedure can be used to calculate a null distribution of association statistics for each pathway being tested.

Usage

1
makeRandomGS(geneSetComp, geneBins)

Arguments

geneSetComp

A table providing the number of genes of each size in the gene set, as created with the function getGeneSetComposition.

geneBins

A list containing gene bins and bin boundaries, as created with the function makeGeneBins.

Value

Returns a vector of gene IDs randomly selected to approximately match the composition of the specified gene set.

Author(s)

Michael Mooney <mooneymi@ohsu.edu>

See Also

makeGeneBins, getGeneSetComposition

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# This example uses the GRASS algorithm implemented in the SNPath package to calculate association statistics

## Not run: 
library(SNPath)
library(snow)
# Create a SNOW cluster for parallel processing
cl <- makeCluster(c("localhost","localhost"), type = "SOCK")
## End(Not run)

data(sampleGSA)

# Get gene sizes, and bin genes by size
snpCounts = getGeneSizes(snpMap)
geneBins = makeGeneBins(snpCounts, 25)
  
# Get the composition of the target pathway
gsComp = getGeneSetComposition(snpCounts, pathways[[1]])

# Create random pathways (gene sets) that approximately match the composition of the target pathway
numPerms = 100
x = lapply(c(1:numPerms), function(x){gsComp})
names(x) = c(1:numPerms)
randomPathways = lapply(x, function(y){makeRandomGS(y, geneBins=geneBins)})

## Not run: 
# Calculate association p-values for each random gene set (see SNPath documentation)
randPathPvals = grass(cl=cl, snp.info=snp.info, gene.info=gene.info, gene.set=randomPathways, y=y, gene.def="abs", dist=1000, nominal.p=T) 
stopCluster(cl)

# Assuming the p-value of the target pathway has already been calculated, 
# the permutation p-value is calculated as the proportion of random pathways 
# with a p-value less than the p-value of the target pathway

permPval = (sum(randPathPvals < targetPathPval)+1)/(numPerms+1)
## End(Not run)

mooneymi/gsaPermute documentation built on May 23, 2019, 6:11 a.m.