{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "reset" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#Please run this code block only once, the first time you are running this notebook\n", "!pip3 install google.cloud" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "#To be able to retrieve data from google cloud bigquery tables \n", "from google.cloud import bigquery" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Go to the following link in your browser:\n", "\n", " https://accounts.google.com/o/oauth2/auth?client_id=764086051850-6qr4p6gpi6hn506pt8ejuq83di341hur.apps.googleusercontent.com&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&scope=openid+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloud-platform+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Faccounts.reauth&code_challenge=YersnwhVgYOV3cr4BZNoOv5q8zoGEPEK3l8Ll6lzqIk&code_challenge_method=S256&access_type=offline&response_type=code&prompt=select_account\n", "\n", "\n", "Enter verification code: ^C\n", "\n", "\n", "Command killed by keyboard interrupt\n", "\n" ] } ], "source": [ "# authentication in myBinder\n", "!./google-cloud-sdk/bin/gcloud auth application-default login\n", "\n", "# If you install google cloud sdk \n", "#!gcloud auth application-default login" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "project_id='syntheticlethality' #please replace syntheticlethality with your own projectid\n", "client = bigquery.Client(project_id)\n", "#client = bigquery.Client(credentials=credentials, project=credentials.project_id)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Retireve BRCA1 gene effect score of the first data entry for gene BRCA1 from CRISPR dataset\n", "crispr_query=\"\"\"\n", "SELECT * FROM \n", "`syntheticlethality.DepMap_public_20Q3.Achilles_gene_effect`\n", "WHERE Hugo_Symbol='BRCA1'\n", "LIMIT 10\n", "\"\"\"\n", "brca1_gene_effect=client.query(crispr_query).result().to_dataframe()\n", "brca1_gene_effect" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Retrieve the first 10 records for BRCA1 gene expression from pancancer atlas dataset\n", "pancancer_atlas_query=\"\"\"\n", "SELECT * FROM\n", "`pancancer-atlas.Filtered.EBpp_AdjustPANCAN_IlluminaHiSeq_RNASeqV2_genExp_filtered` \n", "WHERE Symbol='BRCA1'\n", "LIMIT 10\n", "\"\"\"\n", "brca1_gene_exp=client.query(pancancer_atlas_query).result().to_dataframe()\n", "brca1_gene_exp" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.8.12" } }, "nbformat": 4, "nbformat_minor": 4 }