makeCpGgenes: Cluster

View source: R/makeCpGranges.R

makeCpGgenesR Documentation

Cluster

Description

Cluster CpGs together in genes based on annotation

Usage

makeCpGgenes(observations, chr, pos, gene, minCpG = 2)

Arguments

observations

Vector of corresponding observed T-value for each CpG, must be ordered in the same way as chr and pos

chr

Vector of chromosome location for each CpG

pos

Vector giving base pair position for each CpG If unsorted, use order(chr,pos) to sort the genomic positions within each chromosome.

gene

A vector asigning each probe to a gene.

minCpG

Minimum number of CpGs allowed in each region to be considered. Default is set to at least 2 CpGs within each region.

Value

The suplied observations ordered into into a list, with one entry for each CpG region.

Examples

data(DMRScan.methylationData) ## Load methylation data from chromosome 22
data(DMRScan.phenotypes) ## Load phenotype (end-point for methylation data)

## Test for an association between phenotype and Methylation
testStatistics <- apply(DMRScan.methylationData,1,function(x,y)
 summary(glm(y ~ x, family = binomial(link = "logit")))$coefficients[2,3],
  y = DMRScan.phenotypes)

## Set chromosomal position to each test-statistic
pos <- data.frame(matrix(as.integer(unlist(strsplit(names(testStatistics),
 split="chr|[.]"))), ncol = 3, byrow = TRUE))[,-1]

## Set clustering features 
minCpG   <- 3  ## Minimum number of CpGs in a tested cluster
gene     <- sample(paste("Gene",1:100,sep=""), 
                           length(testStatistics),replace=TRUE)
regions  <- makeCpGgenes(observations = testStatistics, 
                         chr = pos[,1], pos = pos[,2], 
                         gene = gene, minCpG = minCpG)


christpa/DMRScan documentation built on Nov. 16, 2024, 9:36 a.m.