R/emeth.R

Defines functions emeth

Documented in emeth

emeth <-
function(Y,eta,mu,aber,V, init = 'default', family = 'laplace',
                  nu = 0, maxiter = 50, verbose = FALSE){
    if(init == 'default'){
      initlist = deconv.init(Y,eta,mu,aber)
    } 
    else{
      initlist = init
    }
    weight = initlist$weight
    pi_a_init = initlist$pi_a_init
    rho_init = initlist$rho_init
    nu0_init = initlist$nu0_init
    sigma_c_init = initlist$sigma_c_init
    lambda_init = initlist$lambda_init
    
    if(family == 'laplace'){
      result = deconvEM_laplace(Y,eta,mu,aber,V,weight = weight,pi_a_init,rho_init,nu0_init,
                        sigma_c_init,lambda_init,nu=nu, maxiter = maxiter, verbose = verbose)
    }
    else if(family == 'normal'){
      result = deconvEM(Y,eta,mu,aber,V,weight = weight,pi_a_init,rho_init,nu0_init,
                        sigma_c_init,lambda_init,nu=nu, maxiter = maxiter, verbose = verbose)
    }
    else{
      stop("Must specify the family from laplace or normal!")
    }
    
    if(median(result$pi_a > 0.5)){
      warning("median proportion of aberrant probes is large, suggesting inappropriate references\n")
    }
    
    return(result)
    
}
Hanyuz1996/EMeth documentation built on Dec. 31, 2020, 12:59 p.m.