liveBook · Manning

Neosemantics

As explained in Knowledge Graphs and LLMs in Action

Neosemantics is a Neo4j plugin for importing, exporting, and working with RDF and other semantic-web data.

Neosemantics connects RDF and semantic-web vocabularies with Neo4j’s labeled-property-graph model, enabling ontology data to be imported, normalized, queried, and used for basic inference. section 3.2

A practical ontology-ingestion pipeline includes:

  • Create the Neo4j database, then add uniqueness constraints and indexes for resource, phenotype, and disease identifiers. section 3.3.1
  • Initialize graph configuration, ignore vocabulary namespaces when required, and convert imported relationship types to Neo4j naming conventions. section 3.3.1
  • Import an RDF/XML ontology, enrich resource nodes with domain labels and identifiers, and load annotation data as disease-to-phenotype relationships. section 3.3.1 section 7.6.4
  • Apply inference over subclass hierarchies to retrieve disease associations that are implicit rather than directly connected. section 3.5
Listing 3.15 Configuring the Neosemantics plugin
CALL n10s.graphconfig.init();
CALL n10s.graphconfig.set({ handleVocabUris: "IGNORE" });
CALL n10s.graphconfig.set({ applyNeo4jNaming: True });

Inspect the Cypher configuration that initializes Neosemantics and controls vocabulary URI handling and relationship naming. section 3.3.1

Listing 3.28 Finding phenotypic features related to the abnormality subclasses
MATCH (cat:HpoPhenotype {label: "Abnormality of the endocrine system"})   #1
CALL n10s.inference.nodesInCategory(cat, { 
  inCatRel: "HAS_PHENOTYPIC_FEATURE", 
  subCatRel: "SUBCLASSOF"})   #2
YIELD node as dis
WHERE dis.label IN [
  "Congenital atransferrinemia",
  "Deafness, autosomal recessive 4, with enlarged vestibular aqueduct",
  "Diabetes mellitus, transient neonatal, 1",
  "Edema, familial idiopathic, prepubertal",
  "Familial dysalbuminemic hyperthyroxinemia"
]    #3
MATCH (dis)-[:HAS_PHENOTYPIC_FEATURE]->(phe:HpoPhenotype)   #4
RETURN dis.label as disease, collect(DISTINCT phe.label) as features
ORDER BY size(features) ASC, disease

Inspect the inference procedure that expands a phenotypic category through subclass relationships and returns associated disease features. section 3.5

How Knowledge Graphs and LLMs in Action covers it

How deep it goes
Shows configuration, importing, indexing, enrichment, annotation loading, and basic subclass inference, without developing advanced RDF semantics.
Examples
Uses the HPO ontology, disease annotations, phenotype labels, RDF/XML imports, and endocrine-system subclass queries.
What it assumes
Assumes familiarity with Neo4j, Cypher, graph modeling, and ontology hierarchies while demonstrating the ingestion sequence concretely.
What you can do after
Build it from scratch by importing RDF/XML into Neo4j, preparing graph structures, linking annotations, and querying inferred biomedical relationships.
How it connects
Connects RDF, OWL, RDFS, SKOS, Neo4j, Cypher, labeled-property graphs, ontologies, and semantic inference.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Knowledge Graphs and LLMs in Action. The section links point to the parts of the book it draws on.