Skip to content

Commit

Permalink
add gwas notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesamcl committed Sep 26, 2024
1 parent 9c00d78 commit e2db4d8
Showing 1 changed file with 100 additions and 0 deletions.
100 changes: 100 additions & 0 deletions notebooks/gwas.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"\n",
"from pathlib import Path\n",
"from py2neo import Graph\n",
"from pandas import DataFrame\n",
"graph = Graph(\"bolt://localhost:7687\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## For GWAS SNPs, what are the associated phenotypes and which IMPC alleles share these phenotypes?"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"\n",
"# SNP -> Disease -> Phenotype -> IMPC association\n",
"\n",
"phenotype_matches_via_disease = DataFrame(graph.run(\"\"\"\n",
"MATCH (snp:`gwas:SNP`)-[:`gwas:associated_with`]->(disease:GraphNode)\n",
" -[:(`biolink:has_phenotype`|`ro:causally_related_to`|`ro:has_characteristic`)]->(phenotype:GraphNode)<-[:`biolink:has_phenotype`]-(mouse_assoc:`impc:GenePhenotypeAssociation`)-[:`impc:mouseAlleleId`]->(mouse_allele:`impc:Allele`)\n",
"RETURN snp.id[0] as snp_id, disease.`grebi:name`[0] as disease, phenotype.`grebi:name`[0] as phenotype, mouse_assoc.`grebi:name`[0] as mouse_gene, mouse_allele.`impc:symbol`[0] as mouse_allele\n",
"\"\"\").data())\n",
"\n",
"phenotype_matches_via_disease.to_csv(\"gwas_disease_phenotype_impc.csv\", index=False)\n"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"\n",
"\n",
"# SNP -> Phenotype -> IMPC association\n",
"\n",
"direct_phenotype_matches = DataFrame(graph.run(\"\"\"\n",
"MATCH (snp:`gwas:SNP`)-[:`gwas:associated_with`]->(trait:GraphNode)\n",
" <-[:`biolink:has_phenotype`]-(mouse_assoc:`impc:GenePhenotypeAssociation`)-[:`impc:mouseAlleleId`]->(mouse_allele:`impc:Allele`)\n",
"RETURN snp.id[0] as snp_id, trait.`grebi:name`[0] as trait, mouse_assoc.`grebi:name`[0] as mouse_gene, mouse_allele.`impc:symbol`[0] as mouse_allele\n",
"\"\"\").data())\n",
"\n",
"direct_phenotype_matches.to_csv(\"gwas_phenotype_impc.csv\", index=False)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"\n",
"# SNP -> Disease -> Phenotype -> IMPC association\n",
"\n",
"phenotype_matches_via_disease = DataFrame(graph.run(\"\"\"\n",
"MATCH (snp:`gwas:SNP`)-[:`gwas:associated_with`]->(disease:GraphNode)\n",
" -[:(`biolink:has_phenotype`|`ro:causally_related_to`|`ro:has_characteristic`)]->(phenotype:GraphNode)<-[:`biolink:has_phenotype`]-(mouse_assoc:`impc:GenePhenotypeAssociation`)-[:`impc:mouseAlleleId`]->(mouse_allele:`impc:Allele`)\n",
"RETURN snp.id[0] as snp_id, disease.`grebi:name`[0] as disease, phenotype.`grebi:name`[0] as phenotype, mouse_assoc.`grebi:name`[0] as mouse_gene, mouse_allele.`impc:symbol`[0] as mouse_allele\n",
"\"\"\").data())\n",
"\n",
"phenotype_matches_via_disease.to_csv(\"gwas_disease_phenotype_impc.csv\", index=False)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": ".venv",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

0 comments on commit e2db4d8

Please sign in to comment.