silico.biotoul.fr
 

M2BBS - IDH

From silico.biotoul.fr

(Difference between revisions)
Jump to: navigation, search
m (Intégration dans une base de données orientée graphes)
m (Données et scripts)
Line 98: Line 98:
* 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]]
** [[Media:go.rel.is_a.dump.txt]]
** [[Media:go.rel.is_a.dump.txt]]
Line 103: Line 104:
* nécessaire pour installer RSTRINGdb
* nécessaire pour installer RSTRINGdb
  dnf install libcurl-devel.x86_64
  dnf install libcurl-devel.x86_64
 +
-->
 +
commandes:
commandes:
* restauration de la base de données go
* restauration de la base de données go
-
  mysql -u root -pbioinfo -e 'create database go'
+
  mysql -uroot -p -e 'create database go'
-
  mysql -u root -pbioinfo go < go_daily-termdb-data
+
  mysql -uroot -p go < go_daily-termdb-data
* extraction d'un fichier csv tabulé pour l'import dans neo4j (dans le répertoire import)
* extraction d'un fichier csv tabulé pour l'import dans neo4j (dans le répertoire import)
-
   mysql -u root -pbioinfo go -B -e "SELECT id, acc, term_type, name FROM term WHERE acc LIKE 'GO:%' AND is_obsolete=0" > neo4j-community-3.0.6/import/go.terms.csv
+
   mysql -uroot -p go -B -e "SELECT id, acc, term_type, name FROM term WHERE acc LIKE 'GO:%' AND is_obsolete=0" > neo4j-community-3.2.3/import/go.terms.csv
-
* remplacer les '\t' par des ','
+
* remplacer les <tt>\t</tt> par des <tt>,</tt>
-
* import dans neo4j
+
* import des termes GO dans Neo4j
  LOAD CSV WITH HEADERS FROM "file:///go.terms.csv" AS row
  LOAD CSV WITH HEADERS FROM "file:///go.terms.csv" AS row
  CREATE (n:GOTerm)
  CREATE (n:GOTerm)
Line 119: Line 122:
   n.term_type = row.term_type,
   n.term_type = row.term_type,
   n.name = row.name   
   n.name = row.name   
-
+
 
 +
* ajouts d'index
  CREATE INDEX ON :GOTerm(id)
  CREATE INDEX ON :GOTerm(id)
  CREATE INDEX ON :GOTerm(acc)
  CREATE INDEX ON :GOTerm(acc)
   
   
-
 
+
* exploration
  MATCH (n:GOTerm) RETURN count(n)
  MATCH (n:GOTerm) RETURN count(n)
  MATCH (n:GOTerm) RETURN n LIMIT 10
  MATCH (n:GOTerm) RETURN n LIMIT 10
  MATCH (n:GOTerm {name: 'reproduction'} ) RETURN n
  MATCH (n:GOTerm {name: 'reproduction'} ) RETURN n
   
   
 +
* ajout des relations <tt>is_a</tt>
  # IS_A (1)
  # IS_A (1)
-
  mysql -u root -pbioinfo go -B -e "SELECT term1_id, term2_id FROM term2term WHERE relationship_type_id = 1" > neo4j-community-3.0.6/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-3.2.3/import/go.rel.is_a.dump.txt
-
  geany neo4j-community-3.0.6/import/go.rel.is_a.dump.txt
+
  vi neo4j-community-3.2.3/import/go.rel.is_a.dump.txt
   
   
  USING PERIODIC COMMIT 1000
  USING PERIODIC COMMIT 1000
Line 139: Line 144:
  CREATE UNIQUE (t1)-[:IS_A]->(t2)
  CREATE UNIQUE (t1)-[:IS_A]->(t2)
   
   
-
  # PART_OF (25)
+
* ajout des relations <tt>part_of</tt>
-
  mysql -u root -pbioinfo go -B -e "SELECT term1_id, term2_id FROM term2term WHERE relationship_type_id = 25" > neo4j-community-3.0.6/import/go.rel.part_of.dump.txt
+
  # PART_OF (27)
-
  geany neo4j-community-3.0.6/import/go.rel.part_of.dump.txt
+
  mysql -uroot -p go -B -e "SELECT term1_id, term2_id FROM term2term WHERE relationship_type_id = 27" > neo4j-community-3.2.3/import/go.rel.part_of.dump.txt
 +
  vi neo4j-community-3.2.3/import/go.rel.part_of.dump.txt
   
   
  USING PERIODIC COMMIT 1000
  USING PERIODIC COMMIT 1000
Line 150: Line 156:
  CREATE UNIQUE (t1)-[:PART_OF]->(t2)
  CREATE UNIQUE (t1)-[:PART_OF]->(t2)
 +
* Ajout des sommets correspondants aux protéines
  # Proteins
  # Proteins
Line 156: Line 163:
  sp=sdb$get_proteins()
  sp=sdb$get_proteins()
  cp ..../repo_data/511145__proteins.tsv.gz neo4j-community-3.0.6/import/
  cp ..../repo_data/511145__proteins.tsv.gz neo4j-community-3.0.6/import/
-
  gunzip neo4j-community-3.0.6/import/511145__proteins.tsv.gz  
+
  gunzip neo4j-community-3.2.3/import/511145__proteins.tsv.gz  
  # remplacer les tabulations par des virgules (si besoin)
  # remplacer les tabulations par des virgules (si besoin)
Line 166: Line 173:
   n.name = row.protein_external_id
   n.name = row.protein_external_id
 +
* création de l'index
  CREATE INDEX ON :Protein(name)
  CREATE INDEX ON :Protein(name)
-
+
 
 +
* test
  MATCH (p:Protein) RETURN p LIMIT 10
  MATCH (p:Protein) RETURN p LIMIT 10
 +
* ajout des liens entre protéines et annotations
  # Liens GO -> Protein
  # Liens GO -> Protein
  annot=sdb$get_annotations()
  annot=sdb$get_annotations()
-
  cp ...../repo_data/annotations_511145.tsv.gz neo4j-community-3.0.6/import/
+
  cp ...../repo_data/annotations_511145.tsv.gz neo4j-community-3.2.3/import/
-
  gunzip neo4j-community-3.0.6/import/annotations_511145.tsv.gz  
+
  gunzip neo4j-community-3.2.3/import/annotations_511145.tsv.gz  
  grep 'GO:' annotations_511145.tsv > annotations_511145.csv
  grep 'GO:' annotations_511145.tsv > annotations_511145.csv
  # remplacer les tabulations par des virgules et rajouter les noms de colonnes
  # remplacer les tabulations par des virgules et rajouter les noms de colonnes
Line 183: Line 193:
  WHERE p.name=line.prot AND goterm.acc=line.got
  WHERE p.name=line.prot AND goterm.acc=line.got
  WITH p, goterm
  WITH p, goterm
-
  CREATE (p)-[:HAS_GO]->(goterm)
+
  CREATE (p)-[:GOAnnotation]->(goterm)
-
# script python
+
* Script python
<source lang='python'>
<source lang='python'>
#!/usr/bin/python  
#!/usr/bin/python  

Revision as of 09:11, 20 September 2017

Contents

Prise en main de la librairie R/Bioconductor R-STRINGdb

Sites et documentation :

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 search_enriched_sets.py 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.

root> pip 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 search_enriched_sets.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 :


Téléchargement linuxhttps://neo4j.com/download/community-edition/


Installation (cf.https://neo4j.com/docs/operations-manual/current/installation/)

tar tf neo4j-community-3.2.3-unix.tar.gz
tar xf neo4j-community-3.2.3-unix.tar.gz
cd neo4j-community-3.2.3/

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 :


Requêtes Cypher.


Interfaçage python.

Données et scripts


commandes:

  • restauration de la base de données go
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-3.2.3/import/go.terms.csv
  • 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  
  • ajouts d'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 is_a
# IS_A (1)
mysql -uroot -p go -B -e "SELECT term1_id, term2_id FROM term2term WHERE relationship_type_id = 1" > neo4j-community-3.2.3/import/go.rel.is_a.dump.txt
vi neo4j-community-3.2.3/import/go.rel.is_a.dump.txt

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-3.2.3/import/go.rel.part_of.dump.txt
vi neo4j-community-3.2.3/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
# Proteins
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-3.0.6/import/
gunzip neo4j-community-3.2.3/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
  • création de l'index
CREATE INDEX ON :Protein(name)
  • test
MATCH (p:Protein) RETURN p LIMIT 10
  • ajout des liens entre protéines et annotations
# Liens GO -> Protein
annot=sdb$get_annotations()
cp ...../repo_data/annotations_511145.tsv.gz neo4j-community-3.2.3/import/
gunzip neo4j-community-3.2.3/import/annotations_511145.tsv.gz 
grep 'GO:' annotations_511145.tsv > annotations_511145.csv
# remplacer les tabulations par des virgules et rajouter les noms de colonnes
# prot,got,branch,iea
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
CREATE (p)-[:GOAnnotation]->(goterm)
  • 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()