|
8 | 8 | import umap
|
9 | 9 | import anndata as ad
|
10 | 10 | import igraph as ig
|
11 |
| -# from palettable.colorbrewer.qualitative import Set2_6 |
12 |
| -# from palettable.tableau import GreenOrange_6 |
13 |
| -# from palettable.cartocolors.qualitative import Safe_6 |
14 |
| -# from palettable.cartocolors.qualitative import Vivid_4 |
15 |
| -# from palettable.cartocolors.qualitative import Vivid_6 |
16 |
| -# from palettable.cartocolors.qualitative import Vivid_10 |
17 |
| -# from palettable.scientific.diverging import Roma_20 |
18 |
| -from palettable.scientific.sequential import LaJolla_20 |
19 |
| -from palettable.scientific.sequential import Batlow_20 |
| 11 | +from palettable.scientific.sequential import LaJolla_20, Batlow_20 |
20 | 12 | from anndata import AnnData
|
21 | 13 | from scipy.sparse import csr_matrix
|
22 | 14 | from scipy import sparse
|
23 | 15 | from typing import Optional, Callable
|
24 | 16 | from ..utils import *
|
25 | 17 |
|
26 |
| - |
27 |
| - |
28 | 18 | def umi_counts_ranked(adata, total_counts_column="total_counts"):
|
29 | 19 | """
|
30 | 20 | Identifies and plors the knee point of the UMI count distribution in an AnnData object.
|
@@ -117,55 +107,7 @@ def ontogeny_graph(gra, color_dict):
|
117 | 107 | ig.plot(gra, **v_style, vertex_size=node_sizes)
|
118 | 108 | plt.show()
|
119 | 109 |
|
120 |
| -def dotplot_deg( |
121 |
| - adata: AnnData, |
122 |
| - diff_gene_dict: dict, |
123 |
| - #samples_obsvals: list = [], |
124 |
| - groupby_obsname: str = "comb_sampname", # I think that this is the column that splits cells for DEG |
125 |
| - cellgrp_obsname: str = "comb_cellgrp", # I think that this is the column that splits into discint clusters or cell types |
126 |
| - cellgrp_obsvals: list = [], # this is the subset of clusters or cell types to limit this visualization to |
127 |
| - num_genes: int = 10, |
128 |
| - order_by = 'scores', |
129 |
| - new_obsname = 'grp_by_samp', |
130 |
| - use_raw=False |
131 |
| -): |
132 | 110 |
|
133 |
| - # remove celltypes unspecified in diff_gene_dict |
134 |
| - dd_dict = diff_gene_dict['geneTab_dict'] |
135 |
| - tokeep = list(dd_dict.keys()) |
136 |
| - |
137 |
| - # also remove cell_types not listed in celltype_names |
138 |
| - # default for celltype_names is all celltypes included in dd_dict |
139 |
| - if len(cellgrp_obsvals) > 0: |
140 |
| - cellgrp_obsvals = list(set(cellgrp_obsvals).intersection(set(tokeep))) |
141 |
| - else: |
142 |
| - cellgrp_obsvals = tokeep |
143 |
| - |
144 |
| - adNew = adata.copy() |
145 |
| - adNew = adNew[adNew.obs[cellgrp_obsname].isin(cellgrp_obsvals)].copy() |
146 |
| - |
147 |
| - # remove categories unspecified in diff_gene_dict |
148 |
| - dictkey = list(diff_gene_dict.keys())[0] |
149 |
| - sample_names = diff_gene_dict[dictkey] |
150 |
| - adNew = adNew[adNew.obs[groupby_obsname].isin(sample_names)].copy() |
151 |
| - |
152 |
| - # add column 'grp_by_samp' to obs that indicates cellgrp by sample |
153 |
| - adNew.obs[new_obsname] = adNew.obs[cellgrp_obsname].astype(str) + "_X_" + adNew.obs[groupby_obsname].astype(str) |
154 |
| - |
155 |
| - # define dict of marker genes based on threshold |
156 |
| - genes_to_plot = dict() |
157 |
| - for cellgrp in cellgrp_obsvals: |
158 |
| - print(f"{cellgrp}") |
159 |
| - for sname in sample_names: |
160 |
| - print(f"{sname}") |
161 |
| - genes_to_plot[cellgrp + "_X_" + sname] = pull_out_genes_v2(diff_gene_dict, cell_type = cellgrp, category = sname, num_genes = num_genes, order_by=order_by) |
162 |
| - |
163 |
| - # return adNew, genes_to_plot |
164 |
| - plt.rcParams['figure.constrained_layout.use'] = True |
165 |
| - #xplot = sc.pl.DotPlot(adNew, genes_to_plot, 'ct_by_cat', cmap='RdPu', var_group_rotation = 0) #, dendrogram=True,ax=ax2, show=False) |
166 |
| - xplot = sc.pl.DotPlot(adNew, genes_to_plot, new_obsname, cmap=LaJolla_20.mpl_colormap, var_group_rotation = 0, use_raw=False) #, dendrogram=True,ax=ax2, show=False) |
167 |
| - xplot.swap_axes(True) # see sc.pl.DotPlot docs for useful info |
168 |
| - return xplot |
169 | 111 |
|
170 | 112 |
|
171 | 113 | def dotplot_diff_gene(
|
@@ -229,15 +171,6 @@ def dotplot_scn_scores(
|
229 | 171 | adTemp.obs[groupby] = adata.obs[groupby]
|
230 | 172 | sc.pl.dotplot(adTemp, adTemp.var_names.values, groupby=groupby, expression_cutoff=expression_cutoff, cmap=Batlow_20.mpl_colormap, colorbar_title="SCN score")
|
231 | 173 |
|
232 |
| -def umap_scores_old( |
233 |
| - adata: AnnData, |
234 |
| - scn_classes: list, |
235 |
| - obsm_name = 'SCN_score' |
236 |
| -): |
237 |
| - adTemp = AnnData(adata.obsm[obsm_name], obs=adata.obs) |
238 |
| - adTemp.obsm['X_umap'] = adata.obsm['X_umap'].copy() |
239 |
| - sc.pl.umap(adTemp,color=scn_classes, alpha=.75, s=10, vmin=0, vmax=1) |
240 |
| - |
241 | 174 |
|
242 | 175 | def umap_scores(
|
243 | 176 | adata: AnnData,
|
|
0 commit comments