M2BBS - IDH
From silico.biotoul.fr
m (→Neo4j) |
m (→Neo4j) |
||
Line 146: | Line 146: | ||
MATCH (n:GOTerm {name: 'reproduction'} ) RETURN n | MATCH (n:GOTerm {name: 'reproduction'} ) RETURN n | ||
- | Ajout des relations de type <tt>is_a</tt> | + | Ajout des relations de type <tt>is_a</tt> et <tt>part_of</tt>. On recherche leur identifiant interne (qui change régulièrement) : |
<source lang='sql'> | <source lang='sql'> | ||
- | SELECT * FROM term WHERE | + | SELECT * FROM term WHERE is_relation; |
</source> | </source> | ||
<source lang='bash'> | <source lang='bash'> | ||
- | # IS_A (1) | + | # IS_A (internal term id = 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 | 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> | </source> | ||
Line 165: | Line 165: | ||
* ajout des relations <tt>part_of</tt> | * ajout des relations <tt>part_of</tt> | ||
- | # PART_OF (20) | + | # PART_OF (internal term id = 20) |
mysql -uroot -p go -B -e "SELECT term1_id, term2_id FROM term2term WHERE relationship_type_id = 20" > neo4j-community/import/go.rel.part_of.dump.txt | mysql -uroot -p go -B -e "SELECT term1_id, term2_id FROM term2term WHERE relationship_type_id = 20" > neo4j-community/import/go.rel.part_of.dump.txt | ||
vi neo4j-community/import/go.rel.part_of.dump.txt | vi neo4j-community/import/go.rel.part_of.dump.txt |
Revision as of 07:09, 15 September 2020
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 :
./bin/cypher-shell
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
Pour pouvoir importer les données depuis un fichier local, il faut modifier la configuration de neo4j : dans le fichier conf/neo4j.conf, ajouter vers la ligne 227 :
dbms.security.allow_csv_import_from_file_urls=true
Import des termes GO dans Neo4j :
LOAD CSV WITH HEADERS FROM "file:///go.terms.tsv" AS row FIELDTERMINATOR '\t' 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 et part_of. On recherche leur identifiant interne (qui change régulièrement) :
SELECT * FROM term WHERE is_relation;
# IS_A (internal term id = 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 FIELDTERMINATOR '\t' MATCH (t1:GOTerm),(t2:GOTerm) WHERE t1.id=line.term1_id AND t2.id=line.term2_id WITH t1,t2 MERGE (t1)-[:IS_A]->(t2)
- ajout des relations part_of
# PART_OF (internal term id = 20) mysql -uroot -p go -B -e "SELECT term1_id, term2_id FROM term2term WHERE relationship_type_id = 20" > 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 FIELDTERMINATOR '\t' MATCH (t1:GOTerm),(t2:GOTerm) WHERE t1.id=line.term1_id AND t2.id=line.term2_id WITH t1,t2 MERGE (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")