|
1744 | 1744 | }, |
1745 | 1745 | { |
1746 | 1746 | "cell_type": "code", |
1747 | | - "execution_count": null, |
| 1747 | + "execution_count": 23, |
1748 | 1748 | "id": "90126937", |
1749 | 1749 | "metadata": {}, |
1750 | 1750 | "outputs": [ |
|
1753 | 1753 | "output_type": "stream", |
1754 | 1754 | "text": [ |
1755 | 1755 | "13:50:06 | INFO | scope.pipeline.sc_pipeline — === SingleCellPipeline.fit ===\n", |
1756 | | - "13:50:06 | INFO | scope.preprocessing.single_cell — SingleCellPreprocessor fitted.\n" |
| 1756 | + "13:50:06 | INFO | scope.preprocessing.single_cell — SingleCellPreprocessor fitted.\n", |
| 1757 | + "13:52:16 | INFO | scope.utils.gene_utils — Gene universe: 16214 shared, 4316 bulk-only, 10470 sc-only\n", |
| 1758 | + "13:54:18 | INFO | scope.preprocessing.alignment — BulkSCAligner fitted (method=moment_matching, n_genes=16214).\n", |
| 1759 | + "13:54:18 | INFO | scope.pipeline.sc_pipeline — SingleCellPipeline.fit complete.\n", |
| 1760 | + "13:54:18 | INFO | scope.pipeline.sc_pipeline — === SingleCellPipeline.transform ===\n", |
| 1761 | + "13:56:48 | WARNING | scope.pipeline.sc_pipeline — 4316 / 20530 bulk genes absent from sc data (will be zero-padded).\n", |
| 1762 | + "14:10:27 | INFO | scope.pipeline.sc_pipeline — Projected 200128 cells into 200-D latent space.\n", |
| 1763 | + "14:10:31 | INFO | scope.pipeline.sc_pipeline — Inferred probabilities for 22 mutations.\n" |
| 1764 | + ] |
| 1765 | + }, |
| 1766 | + { |
| 1767 | + "name": "stdout", |
| 1768 | + "output_type": "stream", |
| 1769 | + "text": [ |
| 1770 | + "Inferred mutation probability columns: ['mutation_prob_PIK3CA', 'mutation_prob_PIK3R1', 'mutation_prob_PTEN', 'mutation_prob_AKT1', 'mutation_prob_TP53', 'mutation_prob_CDH1', 'mutation_prob_ERBB2', 'mutation_prob_ERBB3', 'mutation_prob_KRAS', 'mutation_prob_BRAF', 'mutation_prob_GATA3', 'mutation_prob_RUNX1', 'mutation_prob_FOXA1', 'mutation_prob_BRCA1', 'mutation_prob_BRCA2', 'mutation_prob_PALB2', 'mutation_prob_ATM', 'mutation_prob_KMT2C', 'mutation_prob_ARID1A', 'mutation_prob_MAP3K1', 'mutation_prob_RB1', 'mutation_prob_CCND1']\n" |
1757 | 1771 | ] |
1758 | 1772 | } |
1759 | 1773 | ], |
|
1784 | 1798 | "execution_count": null, |
1785 | 1799 | "id": "dc506e05", |
1786 | 1800 | "metadata": {}, |
| 1801 | + "outputs": [ |
| 1802 | + { |
| 1803 | + "name": "stderr", |
| 1804 | + "output_type": "stream", |
| 1805 | + "text": [ |
| 1806 | + "/opt/homebrew/Cellar/micromamba/2.5.0_1/envs/scope-dev/lib/python3.10/site-packages/umap/umap_.py:1952: UserWarning: n_jobs value 1 overridden to 1 by setting random_state. Use no seed for parallelism.\n", |
| 1807 | + " warn(\n" |
| 1808 | + ] |
| 1809 | + } |
| 1810 | + ], |
| 1811 | + "source": [ |
| 1812 | + "adata_sc = compute_umap(adata_sc, obsm_key=\"X_svd\")\n" |
| 1813 | + ] |
| 1814 | + }, |
| 1815 | + { |
| 1816 | + "cell_type": "code", |
| 1817 | + "execution_count": null, |
| 1818 | + "id": "0de7b082-a42d-47b2-9e72-99144c24d937", |
| 1819 | + "metadata": {}, |
1787 | 1820 | "outputs": [], |
1788 | 1821 | "source": [ |
1789 | | - "adata_sc = compute_umap(adata_sc, obsm_key=\"X_svd\")\n", |
1790 | | - "\n", |
1791 | 1822 | "ct_col = next((c for c in adata_sc.obs.columns\n", |
1792 | 1823 | " if \"celltype\" in c.lower() or \"cell_type\" in c.lower()), \"sample_id\")\n", |
1793 | 1824 | "\n", |
1794 | | - "fig, axes = plt.subplots(1, 2, figsize=(14, 5))\n", |
| 1825 | + "fig, axes = plt.subplots(2, 1, figsize=(14, 12))\n", |
1795 | 1826 | "sc.pl.umap(adata_sc, color=ct_col, ax=axes[0], show=False, title=\"Cell type\")\n", |
1796 | 1827 | "sc.pl.umap(adata_sc, color=\"sample_id\", ax=axes[1], show=False, title=\"Patient\")\n", |
1797 | 1828 | "plt.tight_layout()\n", |
1798 | 1829 | "fig.savefig(os.path.join(MODELS_DIR, \"BRCA_umap_celltype.pdf\"), bbox_inches=\"tight\")\n", |
1799 | 1830 | "plt.show()\n" |
1800 | 1831 | ] |
1801 | 1832 | }, |
| 1833 | + { |
| 1834 | + "cell_type": "code", |
| 1835 | + "execution_count": null, |
| 1836 | + "id": "c4b4b183-853a-49a1-9058-9580382ce2a3", |
| 1837 | + "metadata": {}, |
| 1838 | + "outputs": [], |
| 1839 | + "source": [ |
| 1840 | + "print(adata_sc)\n" |
| 1841 | + ] |
| 1842 | + }, |
| 1843 | + { |
| 1844 | + "cell_type": "code", |
| 1845 | + "execution_count": null, |
| 1846 | + "id": "54269169-a965-4389-b2b9-eec4f674f07a", |
| 1847 | + "metadata": {}, |
| 1848 | + "outputs": [], |
| 1849 | + "source": [ |
| 1850 | + "sc.pl.umap(adata_sc, color=\"sample_id\", ax=axes[1], show=False, title=\"Patient\")\n" |
| 1851 | + ] |
| 1852 | + }, |
1802 | 1853 | { |
1803 | 1854 | "cell_type": "code", |
1804 | 1855 | "execution_count": null, |
|
1807 | 1858 | "outputs": [], |
1808 | 1859 | "source": [ |
1809 | 1860 | "top_muts = (\n", |
1810 | | - " mutation_labels.sum().sort_values(ascending=False).head(6).index.tolist()\n", |
| 1861 | + " mutation_labels.sum().sort_values(ascending=False).index.tolist()\n", |
1811 | 1862 | ")\n", |
1812 | 1863 | "fig = plot_mutation_probabilities(adata_sc, mutations=top_muts)\n", |
1813 | 1864 | "fig.savefig(os.path.join(MODELS_DIR, \"BRCA_mutation_probs.pdf\"), bbox_inches=\"tight\")\n", |
|
1822 | 1873 | "outputs": [], |
1823 | 1874 | "source": [ |
1824 | 1875 | "fig, ax = plot_mutation_heatmap(adata_sc, cluster_key=ct_col, mutations=top_muts)\n", |
| 1876 | + "fig.set_size_inches(20, 8) # width, height in inches\n", |
1825 | 1877 | "fig.savefig(os.path.join(MODELS_DIR, \"BRCA_heatmap.pdf\"), bbox_inches=\"tight\")\n", |
1826 | 1878 | "plt.show()\n" |
1827 | 1879 | ] |
|
0 commit comments