M2BBS - IDH
From silico.biotoul.fr
m (→Données et scripts) |
m (→Neo4j) |
||
(40 intermediate revisions not shown) | |||
Line 1: | Line 1: | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
=Prise en main de la librairie R/Bioconductor R-STRINGdb= | =Prise en main de la librairie R/Bioconductor R-STRINGdb= | ||
Line 28: | Line 9: | ||
* Installer la librairie (si nécessaire) | * Installer la librairie (si nécessaire) | ||
* Retrouver l'espèce ''Escherichia coli'' K12 MG1655, quel est son identifiant taxonomique/STRINGdb ? | * Retrouver l'espèce ''Escherichia coli'' K12 MG1655, quel est son identifiant taxonomique/STRINGdb ? | ||
- | * Quelle est la différence entre STRINGdb core et STRINGdb periphery ? | + | * Quelle est la différence entre STRINGdb ''core'' et STRINGdb ''periphery'' ? |
* Télécharger tout le graphe pour ''E. coli'' K12 pour un seuil de 400. A quoi correspond ce seuil ? combien d'interactions obtenez-vous ? | * Télécharger tout le graphe pour ''E. coli'' K12 pour un seuil de 400. A quoi correspond ce seuil ? combien d'interactions obtenez-vous ? | ||
* Afficher le sous graphe pour les groupe de gènes <tt>ALAS ARGS ASNS ASPS CYSS GLTX GLYQ GLYS HISS ILES</tt>. A quoi correspond la p-valeur affichée ? | * Afficher le sous graphe pour les groupe de gènes <tt>ALAS ARGS ASNS ASPS CYSS GLTX GLYQ GLYS HISS ILES</tt>. A quoi correspond la p-valeur affichée ? | ||
* Télécharger les annotations associées à chaque sommet. | * Télécharger les annotations associées à chaque sommet. | ||
+ | |||
+ | = Enrichment analysis = | ||
+ | |||
+ | Dans cette partie, il s'agit d'analyser un groupe de gènes en le confrontant à des groupes de gènes obtenus selon différentes fonctions de regroupement. | ||
+ | |||
+ | La fonction de regroupement proposée est l'appartenance à une même voie métabolique dans la banque de données BioCyc. Ainsi, pour chaque ''pathway'', un groupe de gènes est formé. | ||
+ | |||
+ | Le script python <tt>blastset.py</tt> ([https://github.com/rbarriot/enrichment github] ou [https://gitlab.com/rbarriot/enrichment gitlab]) permet de charger ces ensembles de gènes pré-formés [[Media:EcolA.biocyc.sets|EcolA.biocyc.sets]] et de chercher les plus similaires à un groupe de gènes d'intérêts. Essayez-le avec <tt>ALAS ARGS ASNS ASPS CYSS GLTX GLYQ GLYS HISS ILES</tt> par exemple pour vous faire une idée de son fonctionnement. | ||
+ | |||
+ | '''Remarque :''' le script python utilise le module scipy, installation si besoin : | ||
+ | conda activate devenv | ||
+ | conda install scipy | ||
+ | |||
+ | Comparez les résultats avec ceux obtenus en recherchant parmi les ensembles formés des gènes annotés avec le même terme de la Gene Ontology ([[Media:EcolA.go.sets|EcolA.go.sets]]). Que constatez-vous ? | ||
+ | |||
+ | Travail à réaliser : | ||
+ | * Analyser le code source du script blastset.py | ||
+ | * Pour chaque pathway biocyc, proposer le term GO le plus représentatif | ||
+ | * Visualisation des résultats avec [http://revigo.irb.hr/ REVIGO] | ||
+ | <!-- * Modifier le script pour utiliser une autre mesure d'enrichissement et comparer les résultats obtenus (ex: χ<sup>2</sup> d'indépendance). (Travail à réaliser <u>en dehors de cette séance</u>) --> | ||
= Intégration dans une base de données orientée graphes = | = Intégration dans une base de données orientée graphes = | ||
Line 39: | Line 40: | ||
* https://neo4j.com/developer/get-started/ | * https://neo4j.com/developer/get-started/ | ||
* pilotes : [https://neo4j.com/developer/python/ python] ; [https://neo4j.com/developer/r/ R] | * pilotes : [https://neo4j.com/developer/python/ python] ; [https://neo4j.com/developer/r/ R] | ||
- | |||
- | |||
- | |||
- | |||
* Cypher reference card: https://neo4j.com/docs/cypher-refcard/current/ | * Cypher reference card: https://neo4j.com/docs/cypher-refcard/current/ | ||
- | * et dans guest@ | + | * et dans guest@intervenant:/home/Documents/eBooks |
* exemples d'applications : | * exemples d'applications : | ||
** graphe de co-expression : https://neo4j.com/graphgist/dba96ed2-2d3c-469c-a1a4-cda067c873fc | ** graphe de co-expression : https://neo4j.com/graphgist/dba96ed2-2d3c-469c-a1a4-cda067c873fc | ||
** réseau métabolique : https://neo4j.com/graphgist/563e4bfc-a3d8-479d-b065-1f9c9b84027e#listing_category=science | ** réseau métabolique : https://neo4j.com/graphgist/563e4bfc-a3d8-479d-b065-1f9c9b84027e#listing_category=science | ||
- | Installation (cf. https://neo4j.com/docs/operations-manual/current/ | + | <!-- |
- | tar | + | ** (pas besoin mais pour info) R : Install RNeo4j using devtools. (from https://nicolewhite.github.io/2014/05/30/demo-of-rneo4j-part1.html) |
- | tar | + | install.packages("devtools") |
- | + | devtools::install_github("nicolewhite/RNeo4j") | |
+ | library(RNeo4j) | ||
+ | --> | ||
+ | |||
+ | Téléchargement linux https://neo4j.com/download-center/#releases (onglet [https://neo4j.com/download-center/#community Community server]) | ||
+ | |||
+ | |||
+ | |||
+ | Installation (cf.https://neo4j.com/docs/operations-manual/current/installation/) | ||
+ | version=3.5.9 | ||
+ | tar tf neo4j-community-$version-unix.tar.gz | ||
+ | tar xf neo4j-community-$version-unix.tar.gz | ||
+ | ln -s neo4j-community-$version neo4j-community | ||
+ | cd neo4j-community/ | ||
Démarrage et arrêt du serveur | Démarrage et arrêt du serveur | ||
Line 62: | Line 72: | ||
http://localhost:7474/ | http://localhost:7474/ | ||
- | + | A la première connexion, le mot de passe est <tt>neo4j</tt>, le système demande ensuite de changer le mot de passe. Explorez l'interface Web de Neo4j browser, notamment le côté gauche avec les paramètres, et les informations sur la base de données. | |
+ | |||
+ | Dans la partie favoris, suivre le premier exemple dans ''Example Graphs'' intitulé ''Movie Graph''. | ||
Passer ensuite à l'exemple suivant ''Northwind Graph'' et adapter les commandes pour importer le modèle suivant : | Passer ensuite à l'exemple suivant ''Northwind Graph'' et adapter les commandes pour importer le modèle suivant : | ||
Line 68: | Line 80: | ||
* les protéines annotés avec ces termes ; cf. STRINGdb | * les protéines annotés avec ces termes ; cf. STRINGdb | ||
- | + | <!-- | |
+ | Pour cela, vous allez devoir : | ||
+ | * télécharger une extraction du modèle et des données de la GO pour les restaurer sur votre instance MySQL, | ||
+ | * récupérer les protéines d'''E.coli'' K12 et les termes GO qui les annotent. | ||
- | + | Après reformatage des données GO en fichiers CSV à partir d'une requête SQL, créer les sommets et arcs ou arêtes correspondants. | |
+ | --> | ||
+ | |||
+ | |||
+ | Requêtes Cypher depuis Neo4j browser ou depuis le shell : | ||
+ | cycli -u neo4j -p | ||
+ | |||
+ | |||
+ | |||
+ | Utilisation depuis python. | ||
+ | |||
+ | Utilisation depuis R. | ||
= Données et scripts = | = Données et scripts = | ||
Line 78: | Line 104: | ||
** [[Media:EcolA.go.sets|EcolA.go.sets]] | ** [[Media:EcolA.go.sets|EcolA.go.sets]] | ||
* R-STRINGdb [[silico:enseignement/m2bbs/idh/R-StringDB-tuto.html|tutoriel]] | * R-STRINGdb [[silico:enseignement/m2bbs/idh/R-StringDB-tuto.html|tutoriel]] | ||
+ | <!-- | ||
* graph db | * graph db | ||
** [[Media:go-2016-09-21-termdb.gz]] | ** [[Media:go-2016-09-21-termdb.gz]] | ||
Line 84: | Line 111: | ||
* nécessaire pour installer RSTRINGdb | * nécessaire pour installer RSTRINGdb | ||
dnf install libcurl-devel.x86_64 | dnf install libcurl-devel.x86_64 | ||
+ | --> | ||
+ | |||
+ | == Neo4j == | ||
+ | Restauration de la base de données entière récupérée sur geneontology.org : | ||
+ | <source lang='bash'> | ||
+ | mysql -uroot -p -e 'create database go' | ||
+ | mysql -uroot -p go < go_daily-termdb-data | ||
+ | </source> | ||
+ | |||
+ | Extraction d'un fichier csv tabulé pour l'import dans neo4j (dans le répertoire import) | ||
+ | <source lang='bash'> | ||
+ | mysql -uroot -p go -B -e "SELECT id, acc, term_type, name FROM term WHERE acc LIKE 'GO:%' AND is_obsolete=0" > neo4j-community/import/go.terms.tsv | ||
+ | </source> | ||
+ | |||
+ | '''Remarque :''' utiliser la commande sed pour remplacer les <tt>\t</tt> par des <tt>,</tt> | ||
+ | |||
+ | Import des termes GO dans Neo4j : | ||
+ | LOAD CSV WITH HEADERS FROM "file:///go.terms.csv" AS row | ||
+ | CREATE (n:GOTerm) | ||
+ | SET n = row, | ||
+ | n.id = row.id, | ||
+ | n.acc = row.acc, | ||
+ | n.term_type = row.term_type, | ||
+ | n.name = row.name | ||
+ | |||
+ | Création des index : | ||
+ | CREATE INDEX ON :GOTerm(id) | ||
+ | CREATE INDEX ON :GOTerm(acc) | ||
+ | |||
+ | Exploration : | ||
+ | MATCH (n:GOTerm) RETURN count(n) | ||
+ | MATCH (n:GOTerm) RETURN n LIMIT 10 | ||
+ | MATCH (n:GOTerm {name: 'reproduction'} ) RETURN n | ||
+ | |||
+ | Ajout des relations de type <tt>is_a</tt> | ||
+ | <source lang='sql'> | ||
+ | SELECT * FROM term WHERE name = 'is_a' OR name = 'part_of'; | ||
+ | </source> | ||
+ | |||
+ | <source lang='bash'> | ||
+ | # IS_A (1) | ||
+ | mysql -uroot -p go -B -e "SELECT term1_id, term2_id FROM term2term WHERE relationship_type_id = 1" > neo4j-community/import/go.rel.is_a.dump.txt | ||
+ | </source> | ||
+ | |||
+ | Commandes dans Neo4j pour l'import : | ||
+ | USING PERIODIC COMMIT 1000 | ||
+ | LOAD CSV WITH HEADERS FROM "file:///go.rel.is_a.dump.txt" AS line | ||
+ | MATCH (t1:GOTerm),(t2:GOTerm) | ||
+ | WHERE t1.id=line.term1_id AND t2.id=line.term2_id | ||
+ | WITH t1,t2 | ||
+ | CREATE UNIQUE (t1)-[:IS_A]->(t2) | ||
+ | |||
+ | * ajout des relations <tt>part_of</tt> | ||
+ | # PART_OF (27) | ||
+ | mysql -uroot -p go -B -e "SELECT term1_id, term2_id FROM term2term WHERE relationship_type_id = 27" > neo4j-community/import/go.rel.part_of.dump.txt | ||
+ | vi neo4j-community/import/go.rel.part_of.dump.txt | ||
+ | |||
+ | USING PERIODIC COMMIT 1000 | ||
+ | LOAD CSV WITH HEADERS FROM "file:///go.rel.part_of.dump.txt" AS line | ||
+ | MATCH (t1:GOTerm),(t2:GOTerm) | ||
+ | WHERE t1.id=line.term1_id AND t2.id=line.term2_id | ||
+ | WITH t1,t2 | ||
+ | CREATE UNIQUE (t1)-[:PART_OF]->(t2) | ||
+ | |||
+ | Ajout des sommets correspondants aux protéines | ||
+ | <source lang='rsplus'> | ||
+ | sdb = STRINGdb$new(version='10', species=511145, score_threshold=0, input_directory='repo_data') | ||
+ | g=sdb$get_graph() | ||
+ | sp=sdb$get_proteins() | ||
+ | </source> | ||
+ | |||
+ | <source lang='bash'> | ||
+ | cp repo_data/511145__proteins.tsv.gz neo4j-community/import/ | ||
+ | gunzip neo4j-community/import/511145__proteins.tsv.gz | ||
+ | </source> | ||
+ | |||
+ | # remplacer les tabulations par des virgules (si besoin) | ||
+ | USING PERIODIC COMMIT 1000 | ||
+ | LOAD CSV WITH HEADERS FROM "file:///511145__proteins.csv" AS row | ||
+ | CREATE (n:Protein) | ||
+ | SET n = row, | ||
+ | n.id = toInt(row.protein_id), | ||
+ | n.name = row.protein_external_id | ||
+ | |||
+ | Ajout de l'index | ||
+ | CREATE INDEX ON :Protein(name) | ||
+ | |||
+ | Test | ||
+ | MATCH (p:Protein) RETURN p LIMIT 10 | ||
+ | |||
+ | Ajout des liens entre protéines et annotations | ||
+ | <source lang='rsplus'> | ||
+ | annot=sdb$get_annotations() | ||
+ | </source> | ||
+ | |||
+ | <source lang='bash'> | ||
+ | cp repo_data/annotations_511145.tsv.gz neo4j-community/import/ | ||
+ | gunzip neo4j-community/import/annotations_511145.tsv.gz | ||
+ | # remplacer les tabulations par des virgules et rajouter les noms de colonnes | ||
+ | # prot,got,branch,iea | ||
+ | echo 'prot,got,branch,iea' > neo4j-community/import/go.annotations_511145.csv | ||
+ | grep 'GO:' neo4j-community/import/annotations_511145.tsv >> neo4j-community/import/annotations_511145.csv | ||
+ | </source> | ||
+ | |||
+ | USING PERIODIC COMMIT 1000 | ||
+ | LOAD CSV WITH HEADERS FROM "file:///annotations_511145.csv" AS line | ||
+ | MATCH (p:Protein), (goterm:GOTerm) | ||
+ | WHERE p.name=line.prot AND goterm.acc=line.got | ||
+ | WITH p, goterm, line | ||
+ | CREATE UNIQUE (goterm)-[r:GOAnnotates { branch: line.branch }]->(p) | ||
+ | |||
+ | * Script python | ||
+ | <source lang='python'> | ||
+ | #!/usr/bin/python | ||
+ | |||
+ | from neo4j.v1 import GraphDatabase, basic_auth | ||
+ | |||
+ | driver = GraphDatabase.driver("bolt://localhost", auth=basic_auth("neo4j", "bioinfo")) | ||
+ | session = driver.session() | ||
+ | |||
+ | #~ session.run("CREATE (a:Person {name:'Arthur', title:'King'})") | ||
+ | |||
+ | result = session.run("MATCH (f:GOTerm)-[:IS_A]->(g:GOTerm) WHERE g.name='reproduction' RETURN f.acc AS acc, f.name AS name") | ||
+ | for record in result: | ||
+ | print "acc: %s, name: %s" % (record['acc'], record['name']) | ||
+ | print | ||
+ | |||
+ | session.close() | ||
+ | </source> | ||
+ | |||
+ | |||
+ | * R | ||
+ | <source lang='rsplus'> | ||
+ | library(RNeo4j) | ||
+ | |||
+ | graph = startGraph("http://localhost:7474/db/data/", 'neo4j','bioinfo') | ||
+ | |||
+ | graph = startGraph("http://localhost:7474/db/data/") | ||
+ | |||
+ | query = "match (g:GOTerm {name:'transport'})-[r:GOAnnotates]->(p:Protein) return p.name,p.protein_size" | ||
+ | |||
+ | cypher(graph,query) | ||
+ | |||
+ | # GOTerm les plus utilisés | ||
+ | query = "MATCH (:Protein)<-[:GOAnnotates]-(g:GOTerm) | ||
+ | RETURN g.name AS GOTerm, COUNT(*) AS count | ||
+ | ORDER BY count DESC | ||
+ | LIMIT 50" | ||
+ | |||
+ | cypher(graph,query) | ||
+ | |||
+ | # GOTerm les plus utilisés dans Biological Process, ou autre | ||
+ | query = "MATCH (:Protein)<-[:GOAnnotates]-(g:GOTerm {term_type:{param}}) | ||
+ | RETURN g.name AS GOTerm, COUNT(*) AS count | ||
+ | ORDER BY count DESC | ||
+ | LIMIT 50" | ||
+ | |||
+ | cypher(graph, query, param = "biological_process") | ||
+ | |||
+ | # ou bien avec les attributs sur les arcs | ||
+ | query = "MATCH (g:GOTerm)-[:GOAnnotates {branch:{param}}]->(:Protein) | ||
+ | RETURN g.name AS GOTerm, COUNT(*) AS count | ||
+ | ORDER BY count DESC | ||
+ | LIMIT 50" | ||
+ | |||
+ | cypher(graph, query, param = "Process") | ||
+ | |||
+ | |||
+ | </source> | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
<!-- | <!-- |
Revision as of 14:42, 18 September 2019
Contents |
Prise en main de la librairie R/Bioconductor R-STRINGdb
Sites et documentation :
- STRING : http://string-db.org/
- R-STRINGdb : https://bioconductor.org/packages/release/bioc/html/STRINGdb.html
- R-STRINGdb Vignette et Man
Travail à réaliser :
- Installer la librairie (si nécessaire)
- Retrouver l'espèce Escherichia coli K12 MG1655, quel est son identifiant taxonomique/STRINGdb ?
- Quelle est la différence entre STRINGdb core et STRINGdb periphery ?
- Télécharger tout le graphe pour E. coli K12 pour un seuil de 400. A quoi correspond ce seuil ? combien d'interactions obtenez-vous ?
- Afficher le sous graphe pour les groupe de gènes ALAS ARGS ASNS ASPS CYSS GLTX GLYQ GLYS HISS ILES. A quoi correspond la p-valeur affichée ?
- Télécharger les annotations associées à chaque sommet.
Enrichment analysis
Dans cette partie, il s'agit d'analyser un groupe de gènes en le confrontant à des groupes de gènes obtenus selon différentes fonctions de regroupement.
La fonction de regroupement proposée est l'appartenance à une même voie métabolique dans la banque de données BioCyc. Ainsi, pour chaque pathway, un groupe de gènes est formé.
Le script python blastset.py (github ou gitlab) permet de charger ces ensembles de gènes pré-formés EcolA.biocyc.sets et de chercher les plus similaires à un groupe de gènes d'intérêts. Essayez-le avec ALAS ARGS ASNS ASPS CYSS GLTX GLYQ GLYS HISS ILES par exemple pour vous faire une idée de son fonctionnement.
Remarque : le script python utilise le module scipy, installation si besoin :
conda activate devenv conda install scipy
Comparez les résultats avec ceux obtenus en recherchant parmi les ensembles formés des gènes annotés avec le même terme de la Gene Ontology (EcolA.go.sets). Que constatez-vous ?
Travail à réaliser :
- Analyser le code source du script blastset.py
- Pour chaque pathway biocyc, proposer le term GO le plus représentatif
- Visualisation des résultats avec REVIGO
Intégration dans une base de données orientée graphes
Sites et documentations :
- https://neo4j.com/
- https://neo4j.com/developer/get-started/
- pilotes : python ; R
- Cypher reference card: https://neo4j.com/docs/cypher-refcard/current/
- et dans guest@intervenant:/home/Documents/eBooks
- exemples d'applications :
- graphe de co-expression : https://neo4j.com/graphgist/dba96ed2-2d3c-469c-a1a4-cda067c873fc
- réseau métabolique : https://neo4j.com/graphgist/563e4bfc-a3d8-479d-b065-1f9c9b84027e#listing_category=science
Téléchargement linux https://neo4j.com/download-center/#releases (onglet Community server)
Installation (cf.https://neo4j.com/docs/operations-manual/current/installation/)
version=3.5.9 tar tf neo4j-community-$version-unix.tar.gz tar xf neo4j-community-$version-unix.tar.gz ln -s neo4j-community-$version neo4j-community cd neo4j-community/
Démarrage et arrêt du serveur
./bin/neo4j console
Le processus est au premier plan donc pour arrêter le serveur il faut faire Ctrl + C dans le terminal.
Utilisation depuis le navigateur (vérifier le port renseigné lors de la précédente commande)
http://localhost:7474/
A la première connexion, le mot de passe est neo4j, le système demande ensuite de changer le mot de passe. Explorez l'interface Web de Neo4j browser, notamment le côté gauche avec les paramètres, et les informations sur la base de données.
Dans la partie favoris, suivre le premier exemple dans Example Graphs intitulé Movie Graph.
Passer ensuite à l'exemple suivant Northwind Graph et adapter les commandes pour importer le modèle suivant :
- les termes de la Gene Ontology et leurs relations is_a et part_of qui ne sont pas "périmés" (obsolete) ; cf. http://geneontology.org/ et http://geneontology.org/page/download-ontology http://geneontology.org/page/lead-database-schema et http://archive.geneontology.org/latest-termdb/go_daily-termdb-data.gz
- les protéines annotés avec ces termes ; cf. STRINGdb
Requêtes Cypher depuis Neo4j browser ou depuis le shell :
cycli -u neo4j -p
Utilisation depuis python.
Utilisation depuis R.
Données et scripts
- enrichment analysis
- R-STRINGdb tutoriel
Neo4j
Restauration de la base de données entière récupérée sur geneontology.org :
mysql -uroot -p -e 'create database go' mysql -uroot -p go < go_daily-termdb-data
Extraction d'un fichier csv tabulé pour l'import dans neo4j (dans le répertoire import)
mysql -uroot -p go -B -e "SELECT id, acc, term_type, name FROM term WHERE acc LIKE 'GO:%' AND is_obsolete=0" > neo4j-community/import/go.terms.tsv
Remarque : utiliser la commande sed pour remplacer les \t par des ,
Import des termes GO dans Neo4j :
LOAD CSV WITH HEADERS FROM "file:///go.terms.csv" AS row CREATE (n:GOTerm) SET n = row, n.id = row.id, n.acc = row.acc, n.term_type = row.term_type, n.name = row.name
Création des index :
CREATE INDEX ON :GOTerm(id) CREATE INDEX ON :GOTerm(acc)
Exploration :
MATCH (n:GOTerm) RETURN count(n) MATCH (n:GOTerm) RETURN n LIMIT 10 MATCH (n:GOTerm {name: 'reproduction'} ) RETURN n
Ajout des relations de type is_a
SELECT * FROM term WHERE name = 'is_a' OR name = 'part_of';
# IS_A (1) mysql -uroot -p go -B -e "SELECT term1_id, term2_id FROM term2term WHERE relationship_type_id = 1" > neo4j-community/import/go.rel.is_a.dump.txt
Commandes dans Neo4j pour l'import :
USING PERIODIC COMMIT 1000 LOAD CSV WITH HEADERS FROM "file:///go.rel.is_a.dump.txt" AS line MATCH (t1:GOTerm),(t2:GOTerm) WHERE t1.id=line.term1_id AND t2.id=line.term2_id WITH t1,t2 CREATE UNIQUE (t1)-[:IS_A]->(t2)
- ajout des relations part_of
# PART_OF (27) mysql -uroot -p go -B -e "SELECT term1_id, term2_id FROM term2term WHERE relationship_type_id = 27" > neo4j-community/import/go.rel.part_of.dump.txt vi neo4j-community/import/go.rel.part_of.dump.txt USING PERIODIC COMMIT 1000 LOAD CSV WITH HEADERS FROM "file:///go.rel.part_of.dump.txt" AS line MATCH (t1:GOTerm),(t2:GOTerm) WHERE t1.id=line.term1_id AND t2.id=line.term2_id WITH t1,t2 CREATE UNIQUE (t1)-[:PART_OF]->(t2)
Ajout des sommets correspondants aux protéines
sdb = STRINGdb$new(version='10', species=511145, score_threshold=0, input_directory='repo_data') g=sdb$get_graph() sp=sdb$get_proteins()
cp repo_data/511145__proteins.tsv.gz neo4j-community/import/ gunzip neo4j-community/import/511145__proteins.tsv.gz
# remplacer les tabulations par des virgules (si besoin) USING PERIODIC COMMIT 1000 LOAD CSV WITH HEADERS FROM "file:///511145__proteins.csv" AS row CREATE (n:Protein) SET n = row, n.id = toInt(row.protein_id), n.name = row.protein_external_id
Ajout de l'index
CREATE INDEX ON :Protein(name)
Test
MATCH (p:Protein) RETURN p LIMIT 10
Ajout des liens entre protéines et annotations
annot=sdb$get_annotations()
cp repo_data/annotations_511145.tsv.gz neo4j-community/import/ gunzip neo4j-community/import/annotations_511145.tsv.gz # remplacer les tabulations par des virgules et rajouter les noms de colonnes # prot,got,branch,iea echo 'prot,got,branch,iea' > neo4j-community/import/go.annotations_511145.csv grep 'GO:' neo4j-community/import/annotations_511145.tsv >> neo4j-community/import/annotations_511145.csv
USING PERIODIC COMMIT 1000 LOAD CSV WITH HEADERS FROM "file:///annotations_511145.csv" AS line MATCH (p:Protein), (goterm:GOTerm) WHERE p.name=line.prot AND goterm.acc=line.got WITH p, goterm, line CREATE UNIQUE (goterm)-[r:GOAnnotates { branch: line.branch }]->(p)
- Script python
#!/usr/bin/python from neo4j.v1 import GraphDatabase, basic_auth driver = GraphDatabase.driver("bolt://localhost", auth=basic_auth("neo4j", "bioinfo")) session = driver.session() #~ session.run("CREATE (a:Person {name:'Arthur', title:'King'})") result = session.run("MATCH (f:GOTerm)-[:IS_A]->(g:GOTerm) WHERE g.name='reproduction' RETURN f.acc AS acc, f.name AS name") for record in result: print "acc: %s, name: %s" % (record['acc'], record['name']) print session.close()
- R
library(RNeo4j) graph = startGraph("http://localhost:7474/db/data/", 'neo4j','bioinfo') graph = startGraph("http://localhost:7474/db/data/") query = "match (g:GOTerm {name:'transport'})-[r:GOAnnotates]->(p:Protein) return p.name,p.protein_size" cypher(graph,query) # GOTerm les plus utilisés query = "MATCH (:Protein)<-[:GOAnnotates]-(g:GOTerm) RETURN g.name AS GOTerm, COUNT(*) AS count ORDER BY count DESC LIMIT 50" cypher(graph,query) # GOTerm les plus utilisés dans Biological Process, ou autre query = "MATCH (:Protein)<-[:GOAnnotates]-(g:GOTerm {term_type:{param}}) RETURN g.name AS GOTerm, COUNT(*) AS count ORDER BY count DESC LIMIT 50" cypher(graph, query, param = "biological_process") # ou bien avec les attributs sur les arcs query = "MATCH (g:GOTerm)-[:GOAnnotates {branch:{param}}]->(:Protein) RETURN g.name AS GOTerm, COUNT(*) AS count ORDER BY count DESC LIMIT 50" cypher(graph, query, param = "Process")