## create two state HMM with t distributions
state.names <- c("one","two")
transition <- c(0.1, 0.1)
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, 500)
## make up some genomic probe coordinates
pos <- data.frame(chromosome = rep("chr1", times = 500),
position = seq(1, 18000, length = 500))
## calculate posterior probability for state "one"
post <- posterior(obs, model, log=FALSE)
## get sequence of individually most likely states
state.seq <- apply(post, 2, which.max)
state.seq <- states(model)[state.seq]
## find regions attributed to state "one"
reg.pos <- region.position(state.seq, region="one")
## remove short and unlikely regions
reg.pos2 <- remove.short(reg.pos, post, pos, min.length = 200,
min.score = 0.8)
Run the code above in your browser using DataLab