Skip to content

Commit

Permalink
Rename ori abreviates into ort
Browse files Browse the repository at this point in the history
  • Loading branch information
franck-simon committed Aug 27, 2024
1 parent a28eb70 commit 39fe0bb
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 73 deletions.
38 changes: 19 additions & 19 deletions R/miic.R
Original file line number Diff line number Diff line change
Expand Up @@ -178,30 +178,30 @@
#' 3-point information of unshielded triples and, in temporal mode, using time.
#' If set to FALSE, the orientation step is not performed.
#'
#' @param ori_proba_ratio [a floating point between 0 and 1, optional,
#' @param ort_proba_ratio [a floating point between 0 and 1, optional,
#' 1 by default]
#'
#' The threshold when deducing the type of an edge tip (head/tail)
#' from the probability of orientation.
#' For a given edge tip, denote by p the probability of it being a head,
#' the orientation is accepted if (1 - p) / p < \emph{ori_proba_ratio}.
#' the orientation is accepted if (1 - p) / p < \emph{ort_proba_ratio}.
#' 0 means reject all orientations, 1 means accept all orientations.
#'
#' @param ori_consensus_ratio [a floating point between 0 and 1, optional,
#' @param ort_consensus_ratio [a floating point between 0 and 1, optional,
#' NULL by default]
#' Used to determine if orientations correspond to genuine causal edges
#' and, when consistency is activated, to deduce the orientations in
#' the consensus graph.\cr
#' Oriented edges will be marked as genuine causal when:
#' \eqn{ (1 - p_{head}) / p_{head} < } \emph{ori_consensus_ratio}
#' and \eqn{ p_{tail} / (1 - p_{tail}) < } \emph{ori_consensus_ratio}.\cr
#' When consistency is activated, \emph{ori_consensus_ratio} is used as
#' \eqn{ (1 - p_{head}) / p_{head} < } \emph{ort_consensus_ratio}
#' and \eqn{ p_{tail} / (1 - p_{tail}) < } \emph{ort_consensus_ratio}.\cr
#' When consistency is activated, \emph{ort_consensus_ratio} is used as
#' threshold when deducing the type of an consensus edge tip (head/tail)
#' from the average probability of orientations over the cycle of graphs.
#' For a given edge tip, denote by p the average probability of it being a head,
#' the orientation is accepted if (1 - p) / p < \emph{ori_consensus_ratio}.\cr
#' If not supplied, the \emph{ori_consensus_ratio} will be initialized with
#' the \emph{ori_proba_ratio} value.
#' the orientation is accepted if (1 - p) / p < \emph{ort_consensus_ratio}.\cr
#' If not supplied, the \emph{ort_consensus_ratio} will be initialized with
#' the \emph{ort_proba_ratio} value.
#'
#' @param propagation [a boolean value, optional, FALSE by default]
#'
Expand Down Expand Up @@ -449,11 +449,11 @@
#' arrow tips of an edge, based on the probabilities given in the columns
#' \emph{p_y2x} and \emph{p_x2y}. TRUE: when the edges is directed
#' and both the head and the tail are set with high probabilities
#' (adjustable with the \emph{ori_consensus_ratio} parameter),
#' (adjustable with the \emph{ort_consensus_ratio} parameter),
#' FALSE otherwise or NA if the edge is not retained.
#' More formally, an oriented edge is marked as genuine causal when
#' \eqn{ (1 - p_{head}) / p_{head} < } \emph{ori_consensus_ratio}
#' and \eqn{ p_{tail} / (1 - p_{tail}) < } \emph{ori_consensus_ratio}.\cr
#' \eqn{ (1 - p_{head}) / p_{head} < } \emph{ort_consensus_ratio}
#' and \eqn{ p_{tail} / (1 - p_{tail}) < } \emph{ort_consensus_ratio}.\cr
#' A directed edge not marked as genuine causal indicates that only
#' the head is set with high probability, while the tail probability
#' is not extreme enough to be either head or tail. In this case,
Expand All @@ -465,7 +465,7 @@
#' consistency is not activated or, when consistency is on,
#' if there is only one graph returned (no cycle).
#' When computed, indicates the consensus orientation of the edge
#' determined from the consensus skeleton and the \emph{ori_consensus_ratio}
#' determined from the consensus skeleton and the \emph{ort_consensus_ratio}
#' threshold on averaged orientation probabilities over the cycle of graphs.
#' Possible values are 0: not connected, 1: not oriented, -2 or 2: oriented
#' and 6: bi-directional (latent variable).}
Expand Down Expand Up @@ -700,8 +700,8 @@ miic <- function(input_data,
n_threads = 1,
cplx = "nml",
orientation = TRUE,
ori_proba_ratio = 1,
ori_consensus_ratio = NULL,
ort_proba_ratio = 1,
ort_consensus_ratio = NULL,
propagation = FALSE,
latent = "orientation",
n_eff = -1,
Expand Down Expand Up @@ -737,8 +737,8 @@ miic <- function(input_data,
n_threads = n_threads,
cplx = cplx,
orientation = orientation,
ori_proba_ratio = ori_proba_ratio,
ori_consensus_ratio = ori_consensus_ratio,
ort_proba_ratio = ort_proba_ratio,
ort_consensus_ratio = ort_consensus_ratio,
propagation = propagation,
latent = latent,
n_eff = n_eff,
Expand Down Expand Up @@ -836,7 +836,7 @@ miic <- function(input_data,
black_box = black_box,
n_shuffles = params$n_shuffles,
orientation = params$orientation,
ori_proba_ratio = params$ori_proba_ratio,
ort_proba_ratio = params$ort_proba_ratio,
propagation = params$propagation,
conf_threshold = params$conf_threshold,
verbose = params$verbose,
Expand Down Expand Up @@ -865,7 +865,7 @@ miic <- function(input_data,
true_edges = true_edges,
state_order = state_order,
consensus_threshold = params$consensus_threshold,
ori_consensus_ratio = params$ori_consensus_ratio,
ort_consensus_ratio = params$ort_consensus_ratio,
latent = (params$latent != "no"),
propagation = params$propagation)

Expand Down
6 changes: 3 additions & 3 deletions R/miic.reconstruct.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ miic.reconstruct <- function(input_data = NULL,
latent = "orientation",
n_shuffles = 0,
orientation = TRUE,
ori_proba_ratio = 1,
ort_proba_ratio = 1,
propagation = FALSE,
conf_threshold = 0,
verbose = FALSE,
Expand Down Expand Up @@ -72,7 +72,7 @@ miic.reconstruct <- function(input_data = NULL,
"n_threads" = n_threads,
"no_init_eta" = FALSE,
"orientation" = orientation,
"ori_proba_ratio" = ori_proba_ratio,
"ort_proba_ratio" = ort_proba_ratio,
"propagation" = propagation,
"test_mar" = test_mar,
"mode" = mode,
Expand Down Expand Up @@ -175,7 +175,7 @@ miic.reconstruct <- function(input_data = NULL,

res$time <- stats::setNames(
as.numeric(time),
c("init", "iter", "cut", "ori", "cpp")
c("init", "iter", "cut", "ort", "cpp")
)

# create the data frame of the structures after orientation
Expand Down
26 changes: 13 additions & 13 deletions R/miic.utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,7 @@ test_param_wrong_float <- function (value, min=NA, max=NA)
# Returns: a list with all the parameters, eventually modified or initialized
#-------------------------------------------------------------------------------
check_parameters <- function (input_data, n_threads, cplx,
orientation, ori_proba_ratio, ori_consensus_ratio, propagation, latent,
orientation, ort_proba_ratio, ort_consensus_ratio, propagation, latent,
n_eff, n_shuffles, conf_threshold, sample_weights, test_mar,
consistent, max_iteration, consensus_threshold,
mode, negative_info, verbose) {
Expand All @@ -1050,28 +1050,28 @@ check_parameters <- function (input_data, n_threads, cplx,
list_ret$cplx = check_param_string (cplx, "complexity", c("nml", "mdl"))
list_ret$orientation = check_param_logical (orientation, "orientation", TRUE)

if ( test_param_wrong_float (ori_proba_ratio, min=0, max=1) )
if ( test_param_wrong_float (ort_proba_ratio, min=0, max=1) )
{
miic_warning ("parameters", "supplied value ", ori_proba_ratio,
" for the orientation probabilty ratio parameter is invalid.",
miic_warning ("parameters", "supplied value ", ort_proba_ratio,
" for the orientation probability ratio parameter is invalid.",
" It must be a floating point between 0 and 1.",
" The default value (1) will be used.")
ori_proba_ratio = 1
ort_proba_ratio = 1
}
list_ret$ori_proba_ratio = ori_proba_ratio
list_ret$ort_proba_ratio = ort_proba_ratio

if ( is.null (ori_consensus_ratio) )
ori_consensus_ratio = list_ret$ori_proba_ratio
else if ( test_param_wrong_float (ori_consensus_ratio, min=0, max=1) )
if ( is.null (ort_consensus_ratio) )
ort_consensus_ratio = list_ret$ort_proba_ratio
else if ( test_param_wrong_float (ort_consensus_ratio, min=0, max=1) )
{
miic_warning ("parameters", "supplied value ", ori_consensus_ratio,
miic_warning ("parameters", "supplied value ", ort_consensus_ratio,
" for the orientation concensus ratio parameter is invalid.",
" It must be a floating point between 0 and 1.",
" The default value (same as orientation probabilty ratio: ",
ori_proba_ratio, ") will be used.")
ori_consensus_ratio = list_ret$ori_proba_ratio
ort_proba_ratio, ") will be used.")
ort_consensus_ratio = list_ret$ort_proba_ratio
}
list_ret$ori_consensus_ratio = ori_consensus_ratio
list_ret$ort_consensus_ratio = ort_consensus_ratio

list_ret$propagation = check_param_logical (propagation, "propagation", FALSE)
list_ret$latent = check_param_string (latent, "latent", MIIC_VALID_LATENT)
Expand Down
28 changes: 14 additions & 14 deletions R/parseResults.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# - state_order: the state order data frame used, optional, NULL by default.
# - consensus_threshold: a float, optional, 0.8 by default. Used when
# consistency is activated to construct the consensus graph skeleton.
# - ori_consensus_ratio: a float, optional, 0.1 by default. Used to determine
# - ort_consensus_ratio: a float, optional, 0.1 by default. Used to determine
# if oriented edges are genuine causal and, when consistency is activated,
# to determine the consensus graph orientations.
# - latent: a boolean, optional, TRUE by default. Indicates if latent
Expand Down Expand Up @@ -76,7 +76,7 @@
#-------------------------------------------------------------------------------
summarizeResults = function (observations, results,
true_edges = NULL, state_order = NULL,
consensus_threshold = 0.8, ori_consensus_ratio = 0.1,
consensus_threshold = 0.8, ort_consensus_ratio = 0.1,
latent = TRUE, propagation = FALSE)
{
# Keep only edges remaining and edges removed using conditioning
Expand Down Expand Up @@ -296,25 +296,25 @@ summarizeResults = function (observations, results,
ratio_x2y <- (1 - proba_x2y) / proba_x2y
ratio_y2x <- (1 - proba_y2x) / proba_y2x

if ( (ratio_x2y < ori_consensus_ratio)
&& (ratio_y2x < ori_consensus_ratio) )
if ( (ratio_x2y < ort_consensus_ratio)
&& (ratio_y2x < ort_consensus_ratio) )
summary[i, "ort_consensus"] <- 6
else if ( (ratio_x2y < ori_consensus_ratio)
&& (ratio_y2x >= ori_consensus_ratio) )
else if ( (ratio_x2y < ort_consensus_ratio)
&& (ratio_y2x >= ort_consensus_ratio) )
{
summary[i, "ort_consensus"] <- 2
if (1 / ratio_y2x < ori_consensus_ratio && causality_deducible)
if (1 / ratio_y2x < ort_consensus_ratio && causality_deducible)
{
summary[i, "is_causal_consensus"] <- TRUE
if (row$ort_inferred == 2)
summary[i, "is_causal"] <- TRUE
}
}
else if ( (ratio_y2x < ori_consensus_ratio)
&& (ratio_x2y >= ori_consensus_ratio) )
else if ( (ratio_y2x < ort_consensus_ratio)
&& (ratio_x2y >= ort_consensus_ratio) )
{
summary[i, "ort_consensus"] <- -2
if (1 / ratio_x2y < ori_consensus_ratio && causality_deducible)
if (1 / ratio_x2y < ort_consensus_ratio && causality_deducible)
{
summary[i, "is_causal_consensus"] <- TRUE
if (row$ort_inferred == -2)
Expand Down Expand Up @@ -343,12 +343,12 @@ summarizeResults = function (observations, results,
ratio_x2y <- (1 - proba_x2y) / proba_x2y
ratio_y2x <- (1 - proba_y2x) / proba_y2x
if ( (row$ort_inferred == 2)
&& (ratio_x2y < ori_consensus_ratio)
&& (1 / ratio_y2x < ori_consensus_ratio) )
&& (ratio_x2y < ort_consensus_ratio)
&& (1 / ratio_y2x < ort_consensus_ratio) )
summary[i, "is_causal"] <- TRUE
if ( (row$ort_inferred == -2)
&& (ratio_y2x < ori_consensus_ratio)
&& (1 / ratio_x2y < ori_consensus_ratio) )
&& (ratio_y2x < ort_consensus_ratio)
&& (1 / ratio_x2y < ort_consensus_ratio) )
summary[i, "is_causal"] <- TRUE
}
}
Expand Down
2 changes: 1 addition & 1 deletion R/tmiic.plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ tmiic_compute_row_layout_layers <- function (tmiic_res)
#-------------------------------------------------------------------------------
# Internal function to precompute a layout suited for the display of raw and
# lagged graphs
# This function computes the layout using Sugiyama algorihtm to
# This function computes the layout using Sugiyama algorithm to
# minimize crossing edges
#
# param: tmiic_res, a tmiic objectreturned by the execution of miic
Expand Down
2 changes: 1 addition & 1 deletion R/tmiic.utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ tmiic_extract_trajectories <- function (input_data, check=T)
FUN=function (x) { return (x[1,1] != 1) } ) ) )
if (length (wrong_starts) > 0)
miic_warning ("check trajectories", length (wrong_starts),
" trajectorie(s) don't start with 1 as first time step value")
" trajectories don't start with 1 as first time step value")
max_nb_ts = max (unlist (lapply (list_ts, FUN=nrow) ) )
if (max_nb_ts == 1)
miic_error ("trajectories check",
Expand Down
30 changes: 15 additions & 15 deletions man/miic.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/environment.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ struct Environment {
vector<Node> nodes;
Grid2d<Edge> edges;
bool orientation = false;
double ori_proba_ratio = 1;
double ort_proba_ratio = 1;
bool propagation = false;
// Level of consistency required for the graph
// 0: no consistency requirement
Expand Down
8 changes: 4 additions & 4 deletions src/orientation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ namespace {

constexpr double kEpsI3 = 1.0e-10;

bool acceptProba(double proba, double ori_proba_ratio) {
return (1 - proba) / proba < ori_proba_ratio;
bool acceptProba(double proba, double ort_proba_ratio) {
return (1 - proba) / proba < ort_proba_ratio;
}

} // anonymous namespace
Expand All @@ -39,10 +39,10 @@ bool acceptProba(double proba, double ori_proba_ratio) {
// x2y: probability that there is an arrow from node x to y
void updateAdj(Environment& env, int x, int y, double y2x, double x2y) {
env.edges(x, y).proba_head = x2y;
if (acceptProba(x2y, env.ori_proba_ratio))
if (acceptProba(x2y, env.ort_proba_ratio))
env.edges(x, y).status = 2;
env.edges(y, x).proba_head = y2x;
if (acceptProba(y2x, env.ori_proba_ratio))
if (acceptProba(y2x, env.ort_proba_ratio))
env.edges(y, x).status = 2;
}

Expand Down
4 changes: 2 additions & 2 deletions src/r_cpp_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ void setEnvironmentFromR(const Rcpp::List& input_data,
if (arg_list.containsElementNamed("orientation"))
environment.orientation = as<bool>(arg_list["orientation"]);

if (arg_list.containsElementNamed("ori_proba_ratio"))
environment.ori_proba_ratio = as<double>(arg_list["ori_proba_ratio"]);
if (arg_list.containsElementNamed("ort_proba_ratio"))
environment.ort_proba_ratio = as<double>(arg_list["ort_proba_ratio"]);

if (arg_list.containsElementNamed("propagation"))
environment.propagation = as<bool>(arg_list["propagation"]);
Expand Down

0 comments on commit 39fe0bb

Please sign in to comment.