R/monarch_edge_weight_encodings.R
monarch_edge_weight_encodings.Rd
This function returns a list of default encoding schemes used to compute edge weights in Monarch knowledge graph visualizations and analyses. Each encoding represents how specific edge attributes contribute to the overall edge weight. Users can inspect these defaults and override them with custom encoding logic if needed.
monarch_edge_weight_encodings()
A list of encodings for various edge attributes:
A named list assigning weights based on knowledge assertion levels:
"knowledge_assertion"
: 1
(full weight for direct assertions)
"logical_entailment"
: 1
(full weight for inferred relationships)
"not_provided"
: 0
(no weight when knowledge level is unspecified)
A named list mapping Human Phenotype Ontology (HPO) frequency terms to numeric weights:
"HP:0040281"
: 1
("Very frequent")
"HP:0040282"
: 0.75
("Frequent")
"HP:0040283"
: 0.5
("Occasional")
"HP:0040284"
: 0.25
("Very rare")
A named list representing negation status:
TRUE
: -1
(negated relationships decrease the weight)
FALSE
: 0
(non-negated relationships have no penalty)
NULL
. Placeholder for total counts; can be overridden with custom logic.
An empty numeric vector. Placeholder for quotient-based weight calculations.
NULL
. Placeholder for count-based weight computations.
NULL
. Placeholder for percentage-based weight computations.
NULL
. Placeholder for evidence-based weight computations.
NULL
. Placeholder for onset qualifiers, which can influence weights.
A function that computes the weight based on the number of unique publications:
Takes a vector of publication IDs and returns the count of unique IDs.
# View the default edge weight encodings
monarch_edge_weight_encodings()
#> $knowledge_level
#> $knowledge_level$knowledge_assertion
#> [1] 1
#>
#> $knowledge_level$logical_entailment
#> [1] 1
#>
#> $knowledge_level$not_provided
#> [1] 0
#>
#>
#> $frequency_qualifier
#> $frequency_qualifier$`HP:0040281`
#> [1] 1
#>
#> $frequency_qualifier$`HP:0040282`
#> [1] 0.75
#>
#> $frequency_qualifier$`HP:0040283`
#> [1] 0.5
#>
#> $frequency_qualifier$`HP:0040284`
#> [1] 0.25
#>
#>
#> $negated
#> $negated$`TRUE`
#> [1] -1
#>
#> $negated$`FALSE`
#> [1] 0
#>
#>
#> $has_total
#> NULL
#>
#> $has_quotient
#> numeric(0)
#>
#> $has_count
#> NULL
#>
#> $has_percentage
#> NULL
#>
#> $has_evidence
#> NULL
#>
#> $onset_qualifier
#> NULL
#>
#> $publications
#> function (x)
#> {
#> length(unique(x))
#> }
#> <bytecode: 0x55f57003cb50>
#> <environment: 0x55f55ddcbb78>
#>
# Override the encoding to assign more weight to logical entailments
encodings <- monarch_edge_weight_encodings()
encodings$knowledge_level$logical_entailment <- 0.5
# Modify the negation encoding to reduce penalty for negated relationships
encodings$negated[["TRUE"]] <- -0.5