This repository contains an R package for implementing Hidden Markov tree prior.
To install the HMTree package first you need to install devtools,roxygen2 and Rcpp
install.packages("devtools")
install.packages("Rcpp")
library("devtools")
library("Rcpp")
install_github("shimlab/HMTree")
To simulate data under either Poisson or Normal model, you can run 'simu.curves' to simulated data. To get help:
library(HMTree)
?simu.curves
For example, you can simulate 10 curve of length 1024 under Poisson model or Normal model using:
curve.length = 1024
model.mode = 'Poisson'
num.samples=10
set.seed(666)
res.pois = simu.curves(curve.length=curve.length, model.mode=model.mode, num.samples=num.samples)
curve.length = 1024
model.mode = 'Normal'
num.samples=10
normal.sigma=0.5
set.seed(666)
res.normal = simu.curves(curve.length=curve.length, model.mode=model.mode, num.samples=num.samples, normal.sigma=normal.sigma)
Or you can use you own data, by using "HMTree.parameter" function to generate your own data object: Note: in user input data matrix, number of rows should be the number of samples and number of column should be the length.
mydata.normal<-res.normal$data
mydata.poisson<-res.poisson$data
HMTree.parameter(mydata.normal,"Normal")
HMTree.parameter(mydata,"Poisson")
Next step is denoise. For one dimensional data, either Normal or Poisson, you can run 'HMTree.denoise_1D'. To get help:
?HMTree.denoise_1D
For example, after simulating data, you can get denoised objects by:
res.denoised.pois<-HMTree.denoise_1D(res.pois)
res.denoised.normal<-HMTree.denoise_1D(res.normal)
Meaning of each object: alpha_vec wavelet_coef denoised_wavelet_coef denoised param_signa_sqr param_marginal_probs param_transition_probs post_probs post_trans_probs
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.