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")
library("HMTree")

Running HMTree

For example, you can simulate 1 curve of length 1024 under Poisson model or Normal model using:

curve.length = 1024
model.mode = 'Poisson'
num.samples=1
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=1
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)

After simulating data, you can get denoised objects by:

denoised.normal<-HMTree.denoise_1D(res.normal)
denoised.pois<-HMTree.denoise_1D(res.pois)

Load output data from Or's code:

local.path<-"/Users/haosicheng/Desktop/"
path<-paste0(local.path,"HMTree/docs/output")
#Normal
path_normal_wavelet_coef<-paste0(path,"/hmt_1024_normal.wavelets_coef.txt")
normal_wavelet_coef <- read.table(path_normal_wavelet_coef,col.names = 1, quote="\"", comment.char="")

path_normal_denoised_wavelt_coef<-paste0(path,"/hmt_1024_normal_denoised.wavelets_coef.txt")
normal_denoised_wavelet_coef <- read.table(path_normal_denoised_wavelt_coef,col.names = 1, quote="\"", comment.char="")

path_normal_denoised<-paste0(path,"/hmt_1024_normal_denoised.txt")
normal_denoised <- read.table(path_normal_denoised,col.names = 1, quote="\"", comment.char="")
#Poisson
path_pois_wavelet_coef<-paste0(path,"/pois_1024.wavelets_coef.txt")
pois_wavelet_coef<-read.table(path_pois_wavelet_coef,col.names = 1, quote="\"", comment.char="")

path_pois_denoised_wavelt_coef<-paste0(path,"/pois_1024_denoised.wavelets_coef.txt")
pois_denoised_wavelet_coef <- read.table(path_pois_denoised_wavelt_coef,col.names = 1, quote="\"", comment.char="")

path_pois_denoised<-paste0(path,"/pois_1024_denoised.txt")
pois_denoised <- read.table(path_pois_denoised,col.names = 1, quote="\"", comment.char="")

Compare:

#Normal
normal.output<-denoised.normal
diff.normal.wavelet.coef<-(normal.output$wavelet_coef-normal_wavelet_coef)/normal_wavelet_coef
summary(diff.normal.wavelet.coef)

diff.normal.denoised.wavelet.coef<-(normal.output$denoised_wavelet_coef-normal_denoised_wavelet_coef)/normal_denoised_wavelet_coef
summary(diff.normal.wavelet.coef)

diff.normal.denoised<-(normal.output$denoised-normal_denoised)/normal_denoised
summary(diff.normal.denoised)
#Poisson
pois.output<-denoised.pois
diff.pois.wavelet.coef<-(pois.output$wavelet_coef-pois_wavelet_coef)/pois_wavelet_coef
summary(diff.pois.wavelet.coef)

diff.pois.denoised.wavelet.coef<-(pois.output$denoised_wavelet_coef-pois_denoised_wavelet_coef)/pois_denoised_wavelet_coef
summary(diff.pois.wavelet.coef)

diff.pois.denoised<-(pois.output$denoised-pois_denoised)/pois_denoised
summary(diff.pois.denoised)


shimlab/HMTree documentation built on May 29, 2019, 9:25 p.m.