reg2gff: Converting Information about Enriched Regions into GFF Format

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/utils.R

Description

Creates a GFF formatted file with information about enriched regions.

Usage

1
2
3
reg2gff(regions, post, probe.pos, file = NULL, score.fun = mean, 
    source = "tHMM", feature.type = "posterior_prob", 
    class = "ChIP_region", name = "tHMM")

Arguments

regions

A matrix indicating enriched regions (see region.position).

post

A vector with posterior probabilities for each probe.

probe.pos

A data.frame with columns "chromosome" and "position" providing genomic coordinates for each probe.

file

Name of GFF file to create.

score.fun

Function used to calculate score of enriched regions.

source

Entry for ‘source’ field of GFF file.

feature.type

Entry for ‘feature’ field of GFF file.

class

Class of documented feature. This is used in the ‘attribute’ field together with name.

name

Name of documented feature. This is used in the ‘attribute’ field together with class.

Details

post should provide scores for each probe. These scores are then summarised for each region by applying score.fun to the probe scores in each region. The default for score.fun is mean but any function that accapts a single numeric vector as its argument and returns a scalar can be used.

Value

A GFF formated data.frame is returned invisibly. Usually this function is called for its side effect.

Author(s)

Peter Humburg

References

GFF specification: http://www.sanger.ac.uk/Software/formats/GFF/GFF_Spec.shtml

See Also

region.position

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
## create two state HMM with t distributions
state.names <- c("one","two")
transition <- c(0.1, 0.2)
location <- c(1, 2)
scale <- c(1, 1)
df <- c(4, 6)
model <- getHMM(list(a=transition, mu=location, sigma=scale, nu=df),
    state.names)

## obtain observation sequence from model
obs <- sampleSeq(model, 100)

## make up some genomic probe coordinates
pos <- data.frame(chromosome = rep("chr1", times = 100), 
    position = seq(1, 4000, length = 100))

## compute most likely state sequence for obs
vit.res <- viterbi(model, obs)

## find regions attributed to state "one"
reg.pos <- region.position(vit.res$stateSeq, region="one")

## calculate posterior probability for state "one"
post <- posterior(obs, model, log=FALSE)[1,]

## create gff annotations
gff <- reg2gff(reg.pos, post, pos)

humburg/tileHMM documentation built on May 17, 2019, 9:13 p.m.