From b9d4a9899990a1fa5f64243c938884daa53e06e4 Mon Sep 17 00:00:00 2001 From: WD Date: Mon, 19 Aug 2024 12:49:14 +0200 Subject: [PATCH] adding some cleaning --- DESCRIPTION | 2 +- NAMESPACE | 1 - R/ELBO.R | 20 ++++++++++---------- R/operation_on_susiF_obj.R | 3 +-- R/plot_functions.R | 6 ++++++ R/susiF.R | 11 ++++++++++- R/susiF_workhorse.R | 2 +- man/fsusie_plots.Rd | 6 +++++- man/susiF.Rd | 2 +- man/update_lfsr.Rd | 2 -- man/which_dummy_cs.Rd | 2 +- 11 files changed, 36 insertions(+), 21 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 90fe741..408e188 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -31,6 +31,6 @@ Suggests: testthat (>= 3.0.0) License: BSD_3_clause + file LICENSE NeedsCompilation: yes -RoxygenNote: 7.3.1 +RoxygenNote: 7.3.2 ByteCompile: yes VignetteBuilder: knitr diff --git a/NAMESPACE b/NAMESPACE index fd2bcab..c7c1c48 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,7 +1,6 @@ # Generated by roxygen2: do not edit by hand S3method(Eloglik,susiF) -S3method(Eloglik,susiF_ss) S3method(HMM_regression,susiF) S3method(L_mixsq,mixture_normal) S3method(L_mixsq,mixture_normal_per_scale) diff --git a/R/ELBO.R b/R/ELBO.R index 9c3ea85..c5be142 100644 --- a/R/ELBO.R +++ b/R/ELBO.R @@ -146,9 +146,9 @@ loglik_SFR_post.susiF <- function (obj, l, Y, X, ...) # #' @param Y Matrix of outcomes # -#' @param X Matrix of covariates +#' @param X Matrix of covariates #' -#' @param data list of data for susif_ss +#' @param \dots Other arguments. # #' @return Expected log likelihood #' @export @@ -170,14 +170,14 @@ Eloglik.susiF = function (obj,Y ,X, ...) { return(-(n*t/2) * log(2*pi*obj$sigma2) - (1/(2*obj$sigma2)) * get_ER2( obj, Y, X)) } -#' @export -#' @keywords internal -Eloglik.susiF_ss = function (obj,data,...) { - n <- data$N - t <- ncol(data$Bhat) - - return(-(n*t/2) * log(2*pi*obj$sigma2) - (1/(2*obj$sigma2)) * get_ER2( obj,data)) -} +# @export +# @keywords internal +#Eloglik.susiF_ss = function (obj,data,...) { +# n <- data$N +# t <- ncol(data$Bhat) +# +# return(-(n*t/2) * log(2*pi*obj$sigma2) - (1/(2*obj$sigma2)) * get_ER2( obj,data)) +#} #' @title Get objective function from data and susiF object # diff --git a/R/operation_on_susiF_obj.R b/R/operation_on_susiF_obj.R index bcc488d..05a7b04 100644 --- a/R/operation_on_susiF_obj.R +++ b/R/operation_on_susiF_obj.R @@ -1883,7 +1883,6 @@ update_lBF.susiF <- function (obj,l, lBF,...) # #' @param Shat matrix pxJ standard error, Shat[j,t] corresponds to standard error of the regression coefficient of Y[,t] on X[,j] # -#'@param alpha vector of length p, containing the updated log Bayes factors #'@param indx_lst list generated by gen_wavelet_indx for the given level of resolution #'@return susiF object #'@export @@ -2070,7 +2069,7 @@ update_residual_variance.susiF <- function( obj,sigma2,...) #' @param obj a susif object defined by init_susiF_obj function #' @param min_purity minimal purity within a CS #' @param X matrix of covariates -#' @param max_crit remove cs base on max absolute correlation instead of min absolute correlation, usefull in the +#' @param median_crit remove cs base on max absolute correlation instead of min absolute correlation, usefull in the # #' @return a list of index corresponding the the dummy effect # diff --git a/R/plot_functions.R b/R/plot_functions.R index ef6fb9b..947ce99 100644 --- a/R/plot_functions.R +++ b/R/plot_functions.R @@ -24,6 +24,12 @@ plot_colors <- c("black", "dodgerblue2", "green4", "#6A3D9A", "#FF7F00", #' #' @param pip_only logical, if TRUE only ouput the PIP plot #' +#' @param show_outing_grid logical, if TRUE show grid +#' +#' @param pip_only logical, if TRUE show pip only +#' +#' @param show_affected_region logical, if TRUE show affected regions +#' #' @param font_size Passed as the \dQuote{ont_size} argument to #' \code{\link[cowplot]{theme_cowplot}}. #' diff --git a/R/susiF.R b/R/susiF.R index 73b3626..947d5ca 100644 --- a/R/susiF.R +++ b/R/susiF.R @@ -219,7 +219,7 @@ #' #'out <- susiF(Y,X,L=2 , prior = 'mixture_normal_per_scale') #' -#'plot_susiF(out, cred.band = TRUE) +#'plot_susiF(out) #' #' #' @@ -326,6 +326,15 @@ susiF <- function(Y, X, L = 2, if(!cal_obj){ tol <-10^-3 } + if(L>ncol(X)){ + L <-ncol(X) + } + + if(L_start>ncol(X)){ + L_start <-ncol(X) + } + + if(L_start >L) { L_start <- L diff --git a/R/susiF_workhorse.R b/R/susiF_workhorse.R index 48b9160..38e1715 100644 --- a/R/susiF_workhorse.R +++ b/R/susiF_workhorse.R @@ -67,7 +67,7 @@ susiF.workhorse <- function(obj, cor_small=FALSE, is.pois=FALSE, e = 0.001){ - +#browser() G_prior <- get_G_prior(obj ) Y_f <- cbind( W$D,W$C) update_Y <- Y_f diff --git a/man/fsusie_plots.Rd b/man/fsusie_plots.Rd index a3a1c1a..dbca79d 100644 --- a/man/fsusie_plots.Rd +++ b/man/fsusie_plots.Rd @@ -61,6 +61,10 @@ two plots.} \item{cred_band}{logical. If \code{TRUE}, plot credible bands if the fSuSiE model was fitted with wavelet regression.} +\item{show_affected_region}{logical, if TRUE show affected regions} + +\item{show_outing_grid}{logical, if TRUE show grid} + \item{lfsr_curve}{Logical. If \code{TRUE}, plot estimated lfsr of the effect at each base pair if obj fitted with HMM regression. This has no effect unless the \code{\link{susiF}} option @@ -83,7 +87,7 @@ has no effect unless the \code{\link{susiF}} option \item{x}{Output of the susiF function.} -\item{pip_only}{logical, if TRUE only ouput the PIP plot} +\item{pip_only}{logical, if TRUE show pip only} \item{show_affected_region.}{If \code{show_affected_region = TRUE}, the regions in which the credible bands cross zero are also shown.} diff --git a/man/susiF.Rd b/man/susiF.Rd index 4661176..5b2fde5 100644 --- a/man/susiF.Rd +++ b/man/susiF.Rd @@ -253,7 +253,7 @@ X <- G out <- susiF(Y,X,L=2 , prior = 'mixture_normal_per_scale') -plot_susiF(out, cred.band = TRUE) +plot_susiF(out) diff --git a/man/update_lfsr.Rd b/man/update_lfsr.Rd index 61112ab..c0dbcf7 100644 --- a/man/update_lfsr.Rd +++ b/man/update_lfsr.Rd @@ -19,8 +19,6 @@ update_lfsr(obj, l, Bhat, Shat, indx_lst, ...) \item{Shat}{matrix pxJ standard error, Shat[j,t] corresponds to standard error of the regression coefficient of Y[,t] on X[,j]} \item{indx_lst}{list generated by gen_wavelet_indx for the given level of resolution} - -\item{alpha}{vector of length p, containing the updated log Bayes factors} } \value{ susiF object diff --git a/man/which_dummy_cs.Rd b/man/which_dummy_cs.Rd index 9d69a5b..e26cbc2 100644 --- a/man/which_dummy_cs.Rd +++ b/man/which_dummy_cs.Rd @@ -16,7 +16,7 @@ which_dummy_cs(obj, min_purity = 0.5, X, median_crit = FALSE, ...) \item{X}{matrix of covariates} -\item{max_crit}{remove cs base on max absolute correlation instead of min absolute correlation, usefull in the} +\item{median_crit}{remove cs base on max absolute correlation instead of min absolute correlation, usefull in the} } \value{ a list of index corresponding the the dummy effect