silico.biotoul.fr
 

M2BBS - IDH

From silico.biotoul.fr

Revision as of 11:20, 13 September 2018 by Barriot (Talk | contribs)
Jump to: navigation, search

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 linux https://neo4j.com/download-center/#releases (onglet Community server)


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

tar tf neo4j-community-3.4.7-unix.tar.gz
tar xf neo4j-community-3.4.7-unix.tar.gz
ln -s neo4j-community-3.4.7 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 :


Requêtes Cypher depuis Neo4j browser ou depuis le shell :

cycli -u neo4j -p


Utilisation depuis python.

Utilisation depuis R.

Données et scripts

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.csv

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
# 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/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/import/
gunzip neo4j-community/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, 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")