R/relative_association_functions.R
build_relative_associations.Rd
Takes as input a raw association network and normalizes it to
relative-associations. Every edge's strength is transformed by dividing by
the average strength of each of the variables it connects. E.g. if edge a-b
has strength 1
and a
's average association is 0.5
and b
's average
association is 0.75
that means this edge has a higher than normal weight
for both nodes and its normalized strength is 1/((0.5 + 0.75)/2) = 1.6
.
build_relative_associations( association_pairs, strength_col = "strength", rank_based = FALSE, impute_missing, return_imputed_pairs = TRUE )
association_pairs | dataframe with columns |
---|---|
rank_based | Should the relative strength be calculated using ranks?
Here instead of using the raw values of strength, the ranking of edges is
used with the max "strength" being the number of edges. Set to |
impute_missing | If not all possible pairs are present in
|
return_imputed_pairs | If pairs were imputed to calculate averages, should those imputed pairs also be returned? |
A new association pairs dataframe (with columns a
, b
, and
strength
) where strength
is transformed to relative strength.
If there are missing pairs - I.e. not all n*(n-1)/2
combinations of
variables are represented - the function will throw a warning fill in the
missing values with the minimum seen association strength.
The following options are available using the impute_missing
argument:
"minimum"
: The lowest seen strenght is assumed to be the value for all missing pairs (same
as default but no warning is given).
"zero"
: Value of 0
is substituted. This option only makes sense if your association is
naturally lower bounded at 0
.
"ignore"
: Here no action is taken and the averages are just used as is. Since it is likely this missingness is not at random it's likely the best option is an imputation of some sort.