py3plex.algorithms.hedwig.core package¶
Submodules¶
py3plex.algorithms.hedwig.core.converters module¶
-
py3plex.algorithms.hedwig.core.converters.
convert_mapping_to_rdf
(input_mapping_file, extract_subnode_info=False, split_node_by=':', keep_index=1, layer_type='uniprotkb', annotation_mapping_file='test.gaf', go_identifier='GO:', prepend_string=None)¶
-
py3plex.algorithms.hedwig.core.converters.
obo2n3
(obofile, n3out, gaf_file)¶
py3plex.algorithms.hedwig.core.example module¶
Example-related classes.
@author: anze.vavpetic@ijs.si
py3plex.algorithms.hedwig.core.helpers module¶
Helper functions.
@author: anze.vavpetic@ijs.si
-
py3plex.algorithms.hedwig.core.helpers.
anonymous_uri
(uri)¶
-
py3plex.algorithms.hedwig.core.helpers.
avg
(x)¶
-
py3plex.algorithms.hedwig.core.helpers.
std
(x)¶
-
py3plex.algorithms.hedwig.core.helpers.
user_defined
(uri)¶ Is this resource user defined?
py3plex.algorithms.hedwig.core.kb module¶
Knowledge-base class.
@author: anze.vavpetic@ijs.si
-
class
py3plex.algorithms.hedwig.core.kb.
ExperimentKB
(triplets, score_fun, instances_as_leaves=True)¶ Bases:
object
The knowledge base for one specific experiment.
-
add_sub_class
(sub, obj)¶ Adds the resource ‘sub’ as a subclass of ‘obj’.
-
bits_to_indices
(bits)¶ Converts the bitset to a set of indices.
-
get_domains
(predicate)¶ Returns the bitsets for input and outputexamples of the binary predicate ‘predicate’.
-
get_empty_domain
()¶ Returns a bitset covering no examples.
-
get_examples
()¶ Returns all examples for this experiment.
-
get_full_domain
()¶ Returns a bitset covering all examples.
-
get_members
(predicate, bit=True)¶ Returns the examples for this predicate, either as a bitset or a set of ids.
-
get_reverse_members
(predicate, bit=True)¶ Returns the examples for this predicate, either as a bitset or a set of ids.
-
get_root
()¶ Root predicate, which covers all examples.
-
get_score
(ex_idx)¶ Returns the score for example id ‘ex_idx’.
-
get_subclasses
(predicate, producer_pred=None)¶ Returns a list of subclasses (as predicate objects) for ‘predicate’.
-
indices_to_bits
(indices)¶ Converts the indices to a bitset.
-
is_discrete_target
()¶
-
n_examples
()¶ Returns the number of examples.
-
n_members
(predicate)¶
-
super_classes
(pred)¶ Returns all super classes of pred (with transitivity).
-
py3plex.algorithms.hedwig.core.load module¶
Reading input data.
@author: anze.vavpetic@ijs.si
-
py3plex.algorithms.hedwig.core.load.
build_uri
(class_string)¶ Checks if the string is a proper URI, if not it builds an URI with the generic namespace.
-
py3plex.algorithms.hedwig.core.load.
csv
(hierarchy_files, data)¶ Loads a simple hierarchy of features and data in csv format.
-
py3plex.algorithms.hedwig.core.load.
csv_parse_data
(g, data_file)¶ Assumes the following csv format:
example_uri_or_label; attr_uri_1; attr_uri_2; …; attr_uri_n http://example.org/uri_1; 0/1; 0/1; 0/1; 0/1; … http://example.org/uri_2; 0/1; 0/1; 0/1; 0/1; … …
Alternatively attribute values can be URIs themselves.
-
py3plex.algorithms.hedwig.core.load.
csv_parse_hierarchy
(g, path)¶ Assumes a hierarchy file of the following format:
class_1<tab>superclass_1_1; superclass_1_2; …; superclass_1_n class_2<tab>superclass_2_1; superclass_2_2; …; superclass_2_n … class_m<tab>superclass_m_1; superclass_m_2; …; superclass_m_n
-
py3plex.algorithms.hedwig.core.load.
load_graph
(ontology_list, data, def_format='n3', cache=True)¶
-
py3plex.algorithms.hedwig.core.load.
rdf
(paths, def_format='n3')¶ Loads the ontology into an rdf graph.
py3plex.algorithms.hedwig.core.predicate module¶
Predicate-related classes.
@author: anze.vavpetic@ijs.si
-
class
py3plex.algorithms.hedwig.core.predicate.
BinaryPredicate
(label, pairs, kb, producer_pred=None)¶ Bases:
py3plex.algorithms.hedwig.core.predicate.Predicate
A binary predicate.
-
class
py3plex.algorithms.hedwig.core.predicate.
Predicate
(label, kb, producer_pred)¶ Bases:
object
Represents a predicate as a member of a certain rule.
-
i
= -1¶
-
-
class
py3plex.algorithms.hedwig.core.predicate.
UnaryPredicate
(label, members, kb, producer_pred=None, custom_var_name=None, negated=False)¶ Bases:
py3plex.algorithms.hedwig.core.predicate.Predicate
A unary predicate.
py3plex.algorithms.hedwig.core.rule module¶
The rule class.
@author: anze.vavpetic@ijs.si
-
class
py3plex.algorithms.hedwig.core.rule.
Rule
(kb, predicates=[], target=None)¶ Bases:
object
Represents a rule, along with its description, examples and statistics.
-
clone
()¶ Returns a clone of this rule. The predicates themselves are NOT cloned.
-
clone_append
(predicate_label, producer_pred, bin=False)¶ Returns a copy of this rule where ‘predicate_label’ is appended to the rule.
-
clone_negate
(target_pred)¶ Returns a copy of this rule where ‘taget_pred’ is negated.
-
clone_swap_with_subclass
(target_pred, child_pred_label)¶ Returns a copy of this rule where ‘target_pred’ is swapped for ‘child_pred_label’.
-
examples
(positive_only=False)¶ Returns the covered examples.
-
property
positives
¶
-
precision
()¶
-
rule_report
(show_uris=False, latex=False)¶ Rule as string with some statistics.
-
static
ruleset_examples_json
(rules_per_target, show_uris=False)¶
-
static
ruleset_report
(rules, show_uris=False, latex=False, human=<function Rule.<lambda>>)¶
-
similarity
(rule)¶ Calculates the similarity between this rule and ‘rule’.
-
size
()¶ Returns the number of conjunts.
-
static
to_json
(rules_per_target, show_uris=False)¶
-
py3plex.algorithms.hedwig.core.settings module¶
Global settings file.
@author: anze.vavpetic@ijs.si
-
class
py3plex.algorithms.hedwig.core.settings.
Defaults
¶ Bases:
object
-
ADJUST
= 'fwer'¶
-
ALPHA
= 0.05¶
-
BEAM_SIZE
= 20¶
-
COVERED
= None¶
-
DEPTH
= 5¶
-
FDR_Q
= 0.05¶
-
FORMAT
= 'n3'¶
-
LEARNER
= 'heuristic'¶
-
LEAVES
= False¶
-
MODE
= 'subgroups'¶
-
NEGATIONS
= False¶
-
NO_CACHE
= False¶
-
OPTIMAL_SUBCLASS
= False¶
-
OUTPUT
= None¶
-
SCORE
= 'lift'¶
-
SUPPORT
= 0.1¶
-
TARGET
= None¶
-
URIS
= False¶
-
VERBOSE
= False¶
-
py3plex.algorithms.hedwig.core.term_parsers module¶
-
py3plex.algorithms.hedwig.core.term_parsers.
parse_gaf_file
(gaf_mappings, whole_list_counts=False)¶
-
py3plex.algorithms.hedwig.core.term_parsers.
read_termlist
(terms)¶
-
py3plex.algorithms.hedwig.core.term_parsers.
read_topology_mappings
(mapping)¶
-
py3plex.algorithms.hedwig.core.term_parsers.
read_uniprot_GO
(filename, verbose=True)¶
Module contents¶
-
class
py3plex.algorithms.hedwig.core.
Example
(id, label, score, annotations=[], weights={})¶ Bases:
object
Represents an example with its score, label, id and annotations.
-
ClassLabeled
= 'class'¶
-
Ranked
= 'ranked'¶
-
-
class
py3plex.algorithms.hedwig.core.
UnaryPredicate
(label, members, kb, producer_pred=None, custom_var_name=None, negated=False)¶ Bases:
py3plex.algorithms.hedwig.core.predicate.Predicate
A unary predicate.
-
class
py3plex.algorithms.hedwig.core.
BinaryPredicate
(label, pairs, kb, producer_pred=None)¶ Bases:
py3plex.algorithms.hedwig.core.predicate.Predicate
A binary predicate.
-
class
py3plex.algorithms.hedwig.core.
Rule
(kb, predicates=[], target=None)¶ Bases:
object
Represents a rule, along with its description, examples and statistics.
-
clone
()¶ Returns a clone of this rule. The predicates themselves are NOT cloned.
-
clone_append
(predicate_label, producer_pred, bin=False)¶ Returns a copy of this rule where ‘predicate_label’ is appended to the rule.
-
clone_negate
(target_pred)¶ Returns a copy of this rule where ‘taget_pred’ is negated.
-
clone_swap_with_subclass
(target_pred, child_pred_label)¶ Returns a copy of this rule where ‘target_pred’ is swapped for ‘child_pred_label’.
-
examples
(positive_only=False)¶ Returns the covered examples.
-
property
positives
¶
-
precision
()¶
-
rule_report
(show_uris=False, latex=False)¶ Rule as string with some statistics.
-
static
ruleset_examples_json
(rules_per_target, show_uris=False)¶
-
static
ruleset_report
(rules, show_uris=False, latex=False, human=<function Rule.<lambda>>)¶
-
similarity
(rule)¶ Calculates the similarity between this rule and ‘rule’.
-
size
()¶ Returns the number of conjunts.
-
static
to_json
(rules_per_target, show_uris=False)¶
-
-
class
py3plex.algorithms.hedwig.core.
ExperimentKB
(triplets, score_fun, instances_as_leaves=True)¶ Bases:
object
The knowledge base for one specific experiment.
-
add_sub_class
(sub, obj)¶ Adds the resource ‘sub’ as a subclass of ‘obj’.
-
bits_to_indices
(bits)¶ Converts the bitset to a set of indices.
-
get_domains
(predicate)¶ Returns the bitsets for input and outputexamples of the binary predicate ‘predicate’.
-
get_empty_domain
()¶ Returns a bitset covering no examples.
-
get_examples
()¶ Returns all examples for this experiment.
-
get_full_domain
()¶ Returns a bitset covering all examples.
-
get_members
(predicate, bit=True)¶ Returns the examples for this predicate, either as a bitset or a set of ids.
-
get_reverse_members
(predicate, bit=True)¶ Returns the examples for this predicate, either as a bitset or a set of ids.
-
get_root
()¶ Root predicate, which covers all examples.
-
get_score
(ex_idx)¶ Returns the score for example id ‘ex_idx’.
-
get_subclasses
(predicate, producer_pred=None)¶ Returns a list of subclasses (as predicate objects) for ‘predicate’.
-
indices_to_bits
(indices)¶ Converts the indices to a bitset.
-
is_discrete_target
()¶
-
n_examples
()¶ Returns the number of examples.
-
n_members
(predicate)¶
-
super_classes
(pred)¶ Returns all super classes of pred (with transitivity).
-
-
py3plex.algorithms.hedwig.core.
convert_mapping_to_rdf
(input_mapping_file, extract_subnode_info=False, split_node_by=':', keep_index=1, layer_type='uniprotkb', annotation_mapping_file='test.gaf', go_identifier='GO:', prepend_string=None)¶