diff --git a/genes2genes/VisualUtils.py b/genes2genes/VisualUtils.py index 7e55a0e..904ddd3 100644 --- a/genes2genes/VisualUtils.py +++ b/genes2genes/VisualUtils.py @@ -404,7 +404,7 @@ def plot_heatmaps(mat_ref,mat_query,GENE_LIST, pathway_name, cluster=False, FIGS max_val = np.max([np.max(mat_ref),np.max(mat_query)]) min_val = np.min([np.min(mat_ref),np.min(mat_query)]) plt.subplot(1,2,1) - ax=sb.heatmap(df, vmax=max_val,vmin=min_val, cbar_kws = dict(use_gridspec=False,location="top")) + ax=sb.heatmap(df, vmax=max_val,vmin=min_val, cbar_kws = dict(use_gridspec=False,location="top"), xticklabels=True, yticklabels=True) plt.title('Reference') ax.yaxis.set_label_position("left") for tick in ax.get_yticklabels(): diff --git a/notebooks/Tutorial.ipynb b/notebooks/Tutorial.ipynb index d7a1e86..347de76 100644 --- a/notebooks/Tutorial.ipynb +++ b/notebooks/Tutorial.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "markdown", - "id": "insured-murray", + "id": "noble-syntax", "metadata": {}, "source": [ "# Tutorial on single-cell trajectory alignment using Genes2Genes\n", @@ -15,7 +15,7 @@ { "cell_type": "code", "execution_count": 1, - "id": "gross-campus", + "id": "inappropriate-canada", "metadata": {}, "outputs": [], "source": [ @@ -36,7 +36,7 @@ }, { "cell_type": "markdown", - "id": "involved-egypt", + "id": "demanding-profit", "metadata": {}, "source": [ "### Load anndata reference and query objects\n", @@ -49,18 +49,18 @@ { "cell_type": "code", "execution_count": 2, - "id": "developed-breed", + "id": "automotive-context", "metadata": {}, "outputs": [], "source": [ - "input_dir = 'notebooks/data/'\n", + "input_dir = 'data/'\n", "adata_ref = anndata.read_h5ad(input_dir + 'adata_pam_local.h5ad') # Reference dataset\n", "adata_query = anndata.read_h5ad(input_dir +'adata_lps_local.h5ad') # Query dataset" ] }, { "cell_type": "markdown", - "id": "favorite-pearl", + "id": "lightweight-scheduling", "metadata": {}, "source": [ "## 1. Preparing data for alignment " @@ -68,7 +68,7 @@ }, { "cell_type": "markdown", - "id": "everyday-ratio", + "id": "mounted-syria", "metadata": {}, "source": [ "### Pseudotime range check\n", @@ -78,7 +78,7 @@ { "cell_type": "code", "execution_count": 3, - "id": "lightweight-management", + "id": "impressive-trustee", "metadata": {}, "outputs": [ { @@ -102,7 +102,7 @@ { "cell_type": "code", "execution_count": 4, - "id": "beneficial-major", + "id": "absolute-gothic", "metadata": {}, "outputs": [ { @@ -125,7 +125,7 @@ }, { "cell_type": "markdown", - "id": "short-feature", + "id": "eligible-substance", "metadata": {}, "source": [ "### Determine the number of discrete pseudotime points to align\n", @@ -136,7 +136,7 @@ { "cell_type": "code", "execution_count": 5, - "id": "coral-detective", + "id": "blank-cause", "metadata": {}, "outputs": [ { @@ -168,7 +168,7 @@ }, { "cell_type": "markdown", - "id": "curious-visitor", + "id": "turned-cliff", "metadata": {}, "source": [ "Accordingly, we go with `n_bins=14`" @@ -177,7 +177,7 @@ { "cell_type": "code", "execution_count": 6, - "id": "selective-payroll", + "id": "authorized-shanghai", "metadata": {}, "outputs": [], "source": [ @@ -186,7 +186,7 @@ }, { "cell_type": "markdown", - "id": "stopped-shore", + "id": "split-gibraltar", "metadata": {}, "source": [ "### Define which cell type annotations and color scheme to use for visualization purposes\n", @@ -197,7 +197,7 @@ { "cell_type": "code", "execution_count": 7, - "id": "sexual-narrow", + "id": "behavioral-greeting", "metadata": {}, "outputs": [], "source": [ @@ -213,7 +213,7 @@ }, { "cell_type": "markdown", - "id": "norman-hungarian", + "id": "terminal-cincinnati", "metadata": {}, "source": [ "Inspect the cell type compositions around each discrete pseudotime point (x-axis) to see if it reasonably represents the entire trajectory of interest. " @@ -222,7 +222,7 @@ { "cell_type": "code", "execution_count": 8, - "id": "taken-opposition", + "id": "recreational-aerospace", "metadata": {}, "outputs": [ { @@ -253,7 +253,7 @@ }, { "cell_type": "markdown", - "id": "failing-botswana", + "id": "imported-lawsuit", "metadata": {}, "source": [ "## 2. G2G trajectory alignment" @@ -262,7 +262,7 @@ { "cell_type": "code", "execution_count": 9, - "id": "important-survivor", + "id": "little-fisher", "metadata": {}, "outputs": [ { @@ -281,7 +281,7 @@ }, { "cell_type": "markdown", - "id": "experienced-serbia", + "id": "stainless-pacific", "metadata": {}, "source": [ "### Aligning all genes" @@ -290,7 +290,7 @@ { "cell_type": "code", "execution_count": 15, - "id": "alpine-italian", + "id": "quantitative-float", "metadata": {}, "outputs": [ { @@ -337,7 +337,7 @@ }, { "cell_type": "markdown", - "id": "suited-commander", + "id": "rolled-pantyhose", "metadata": {}, "source": [ "To access gene-level alignments, use the dictionary: `aligner.results_map` which carries all gene alignment objects.
\n", @@ -347,7 +347,7 @@ { "cell_type": "code", "execution_count": 11, - "id": "occupational-remains", + "id": "norman-verse", "metadata": {}, "outputs": [ { @@ -391,7 +391,7 @@ }, { "cell_type": "markdown", - "id": "alert-silence", + "id": "tracked-pathology", "metadata": {}, "source": [ "Visualise alignment in terms of both the cell-type compositions, as well as actual and interpolated gene expression.
\n", @@ -403,7 +403,7 @@ { "cell_type": "code", "execution_count": 12, - "id": "radio-mirror", + "id": "double-moses", "metadata": {}, "outputs": [ { @@ -445,7 +445,7 @@ }, { "cell_type": "markdown", - "id": "entitled-brass", + "id": "optimum-logan", "metadata": {}, "source": [ "### Aggregate (average) cell-level alignment across all aligned genes\n", @@ -456,7 +456,7 @@ { "cell_type": "code", "execution_count": 13, - "id": "spanish-bowling", + "id": "circular-missouri", "metadata": {}, "outputs": [ { @@ -486,7 +486,7 @@ }, { "cell_type": "markdown", - "id": "powered-wyoming", + "id": "biblical-shelter", "metadata": {}, "source": [ "## 3. Analysing gene-level alignments\n", @@ -497,7 +497,7 @@ { "cell_type": "code", "execution_count": 14, - "id": "chubby-stomach", + "id": "atmospheric-massage", "metadata": {}, "outputs": [ { @@ -695,7 +695,7 @@ { "cell_type": "code", "execution_count": 16, - "id": "controversial-calgary", + "id": "naughty-criminal", "metadata": {}, "outputs": [ { @@ -715,7 +715,7 @@ }, { "cell_type": "markdown", - "id": "under-sponsorship", + "id": "addressed-indication", "metadata": {}, "source": [ "A ranked list of genes based on their first match occurrence " @@ -724,7 +724,7 @@ { "cell_type": "code", "execution_count": 17, - "id": "cleared-jimmy", + "id": "interior-hearing", "metadata": {}, "outputs": [ { @@ -832,7 +832,7 @@ }, { "cell_type": "markdown", - "id": "retired-legislation", + "id": "talented-canadian", "metadata": {}, "source": [ "## Gene-set overrepresentation analysis on the top dissimilar genes \n", @@ -843,7 +843,7 @@ { "cell_type": "code", "execution_count": 18, - "id": "bound-sheep", + "id": "dangerous-documentary", "metadata": {}, "outputs": [ { @@ -1006,7 +1006,7 @@ }, { "cell_type": "markdown", - "id": "helpful-remove", + "id": "alert-shannon", "metadata": {}, "source": [ "## Clustering alignments \n", @@ -1017,7 +1017,7 @@ { "cell_type": "code", "execution_count": 19, - "id": "grand-pakistan", + "id": "actual-midnight", "metadata": {}, "outputs": [ { @@ -1061,7 +1061,7 @@ }, { "cell_type": "markdown", - "id": "metallic-duncan", + "id": "civilian-leather", "metadata": {}, "source": [ "Run clustering with the chosen distance threshold. In this case we select 0.37" @@ -1070,7 +1070,7 @@ { "cell_type": "code", "execution_count": 20, - "id": "equal-above", + "id": "possible-portland", "metadata": {}, "outputs": [ { @@ -1090,7 +1090,7 @@ }, { "cell_type": "markdown", - "id": "forty-psychology", + "id": "informed-avatar", "metadata": {}, "source": [ "Visualise gene alignment grouped together in each cluster
\n", @@ -1100,7 +1100,7 @@ { "cell_type": "code", "execution_count": 21, - "id": "alert-story", + "id": "super-configuration", "metadata": {}, "outputs": [ { @@ -1127,7 +1127,7 @@ }, { "cell_type": "markdown", - "id": "fancy-meter", + "id": "impossible-cigarette", "metadata": {}, "source": [ "Visualise the distance matrix used in the clustering " @@ -1136,7 +1136,7 @@ { "cell_type": "code", "execution_count": 22, - "id": "suspected-ordering", + "id": "professional-questionnaire", "metadata": {}, "outputs": [ { @@ -1156,7 +1156,7 @@ }, { "cell_type": "markdown", - "id": "welcome-darwin", + "id": "discrete-magnet", "metadata": {}, "source": [ "Print the aggregate (average) cell-level alignments for each cluster" @@ -1165,7 +1165,7 @@ { "cell_type": "code", "execution_count": 23, - "id": "swiss-marketplace", + "id": "catholic-intake", "metadata": {}, "outputs": [ { @@ -1189,7 +1189,7 @@ { "cell_type": "code", "execution_count": 24, - "id": "continent-ancient", + "id": "developing-letters", "metadata": {}, "outputs": [ { @@ -1230,7 +1230,7 @@ { "cell_type": "code", "execution_count": 25, - "id": "neural-wales", + "id": "peripheral-oregon", "metadata": {}, "outputs": [ { @@ -1251,7 +1251,7 @@ }, { "cell_type": "markdown", - "id": "confirmed-nepal", + "id": "bridal-insulin", "metadata": {}, "source": [ "### Average alignment of any given subset of genes \n", @@ -1261,7 +1261,7 @@ { "cell_type": "code", "execution_count": 26, - "id": "operational-wayne", + "id": "wound-calculation", "metadata": {}, "outputs": [ { @@ -1289,7 +1289,7 @@ }, { "cell_type": "markdown", - "id": "alone-maryland", + "id": "nonprofit-pricing", "metadata": {}, "source": [ "### Exploring alignment and trends of a given gene set" @@ -1297,7 +1297,7 @@ }, { "cell_type": "markdown", - "id": "welcome-wilderness", + "id": "designed-location", "metadata": {}, "source": [ "Following call extracts a specified pathway gene set from msigdb database. It requires downloading the database from https://www.gsea-msigdb.org/gsea/downloads.jsp and specifying path to the msigdb folder and its version. " @@ -1306,7 +1306,7 @@ { "cell_type": "code", "execution_count": 27, - "id": "surprised-bryan", + "id": "surrounded-receptor", "metadata": {}, "outputs": [ { @@ -1321,7 +1321,7 @@ } ], "source": [ - "IGS = PathwayAnalyser.InterestingGeneSets(MSIGDB_PATH='../../OrgAlign/msigdb', version='7.5.1') # need to create db folder and pass args\n", + "IGS = PathwayAnalyser.InterestingGeneSets(MSIGDB_PATH='/msigdb', version='7.5.1') # need to create db folder and pass args\n", "IGS.add_new_set_from_msigdb('hallmark', 'HALLMARK_EPITHELIAL_MESENCHYMAL_TRANSITION', aligner.gene_list, 'EMT') \n", "IGS.SETS['EMT']" ] @@ -1329,7 +1329,7 @@ { "cell_type": "code", "execution_count": 28, - "id": "aboriginal-dakota", + "id": "fatty-playlist", "metadata": {}, "outputs": [ { @@ -1371,7 +1371,7 @@ { "cell_type": "code", "execution_count": 29, - "id": "single-medium", + "id": "motivated-thunder", "metadata": {}, "outputs": [ { @@ -1413,7 +1413,7 @@ { "cell_type": "code", "execution_count": null, - "id": "secret-terminology", + "id": "living-nudist", "metadata": {}, "outputs": [], "source": []