e:\miniconda3\envs\pysc\lib\site-packages\umap\distances.py:1063: NumbaDeprecationWarning: [1mThe 'nopython' keyword argument was not supplied to the 'numba.jit' decorator. The implicit default value for this argument is currently False, but it will be changed to True in Numba 0.59.0. See https://numba.readthedocs.io/en/stable/reference/deprecation.html#deprecation-of-object-mode-fall-back-behaviour-when-using-jit for details.[0m
@numba.jit()
e:\miniconda3\envs\pysc\lib\site-packages\umap\distances.py:1071: NumbaDeprecationWarning: [1mThe 'nopython' keyword argument was not supplied to the 'numba.jit' decorator. The implicit default value for this argument is currently False, but it will be changed to True in Numba 0.59.0. See https://numba.readthedocs.io/en/stable/reference/deprecation.html#deprecation-of-object-mode-fall-back-behaviour-when-using-jit for details.[0m
@numba.jit()
e:\miniconda3\envs\pysc\lib\site-packages\umap\distances.py:1086: NumbaDeprecationWarning: [1mThe 'nopython' keyword argument was not supplied to the 'numba.jit' decorator. The implicit default value for this argument is currently False, but it will be changed to True in Numba 0.59.0. See https://numba.readthedocs.io/en/stable/reference/deprecation.html#deprecation-of-object-mode-fall-back-behaviour-when-using-jit for details.[0m
@numba.jit()
e:\miniconda3\envs\pysc\lib\site-packages\tqdm\auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
from .autonotebook import tqdm as notebook_tqdm
scanpy==1.9.3 anndata==0.9.1 umap==0.5.3 numpy==1.24.4 scipy==1.11.1 pandas==2.0.3 scikit-learn==1.3.0 statsmodels==0.14.0 python-igraph==0.10.6 pynndescent==0.5.10
e:\miniconda3\envs\pysc\lib\site-packages\umap\umap_.py:660: NumbaDeprecationWarning: [1mThe 'nopython' keyword argument was not supplied to the 'numba.jit' decorator. The implicit default value for this argument is currently False, but it will be changed to True in Numba 0.59.0. See https://numba.readthedocs.io/en/stable/reference/deprecation.html#deprecation-of-object-mode-fall-back-behaviour-when-using-jit for details.[0m
@numba.jit()
1
results_file='output/pbmc3k.h5ad'# the file that will store the analysis results
1 2 3 4
adata = sc.read_10x_mtx('data/filtered_gene_bc_matrices/hg19/', # the directory with the `.mtx` file var_names='gene_symbols', # use gene symbols for the variable names (variables-axis index) cache=True# write a cache file for faster subsequent reading )
... reading from cache file cache\data-filtered_gene_bc_matrices-hg19-matrix.h5ad
1 2 3
# remove duplicated symbols adata.var_names_make_unique() # this is unnecessary if using `var_names='gene_ids'` in `sc.read_10x_mtx` adata
e:\miniconda3\envs\pysc\lib\site-packages\seaborn\axisgrid.py:118: UserWarning: The figure layout has changed to tight
self._figure.tight_layout(*args, **kwargs)
# store normalized data adata.layers['data'] = adata.X.copy()
normalizing counts per cell
finished (0:00:00)
e:\miniconda3\envs\pysc\lib\site-packages\scanpy\preprocessing\_normalization.py:170: UserWarning: Received a view of an AnnData. Making a copy.
view_to_actual(adata)
computing neighbors
using 'X_pca' with n_pcs = 40
finished: added to `.uns['neighbors']`
`.obsp['distances']`, distances for each pair of neighbors
`.obsp['connectivities']`, weighted adjacency matrix (0:00:02)
running Leiden clustering
finished: found 8 clusters and added
'leiden', the cluster labels (adata.obs, categorical) (0:00:00)
e:\miniconda3\envs\pysc\lib\site-packages\scanpy\plotting\_tools\scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
cax = scatter(
1 2
# save the result adata.write(results_file)
Finding marker genes
Wilcoxon rank-sum test to identify markers
1 2 3
# compare each group with the rest of cell sc.tl.rank_genes_groups(adata, 'leiden', method='wilcoxon') sc.pl.rank_genes_groups(adata, n_genes=25, sharey=False) # sharey: Controls if the y-axis of each panels should be shared.
ranking genes
finished: added to `.uns['rank_genes_groups']`
'names', sorted np.recarray to be indexed by group ids
'scores', sorted np.recarray to be indexed by group ids
'logfoldchanges', sorted np.recarray to be indexed by group ids
'pvals', sorted np.recarray to be indexed by group ids
'pvals_adj', sorted np.recarray to be indexed by group ids (0:00:01)
# top 5 ranked genes per cluster pd.DataFrame(adata.uns['rank_genes_groups']['names']).head(5)
0
1
2
3
4
5
6
7
0
RPS12
LYZ
CD74
CCL5
NKG7
LST1
HLA-DPA1
PF4
1
LDHB
S100A9
CD79A
NKG7
GNLY
FCER1G
HLA-DPB1
SDPR
2
RPS25
S100A8
HLA-DRA
B2M
GZMB
AIF1
HLA-DRA
GNG11
3
RPS27
TYROBP
CD79B
CST7
CTSW
COTL1
HLA-DRB1
PPBP
4
RPS6
FTL
HLA-DPB1
GZMA
PRF1
FCGR3A
CD74
NRGN
1 2 3 4 5 6
result = adata.uns['rank_genes_groups'] groups = result['names'].dtype.names pd.DataFrame( {group + '_' + key[:1] : result[key][group] # create new dictionary for group in groups for key in ['names', 'pvals']} ).head(5)
0_n
0_p
1_n
1_p
2_n
2_p
3_n
3_p
4_n
4_p
5_n
5_p
6_n
6_p
7_n
7_p
0
RPS12
1.659522e-223
LYZ
7.634876e-249
CD74
2.487145e-183
CCL5
1.674383e-128
NKG7
1.203971e-96
LST1
1.322111e-88
HLA-DPA1
5.422417e-21
PF4
4.722886e-10
1
LDHB
3.010889e-218
S100A9
4.626358e-246
CD79A
1.679730e-170
NKG7
5.307754e-104
GNLY
1.257170e-88
FCER1G
6.259712e-85
HLA-DPB1
7.591860e-21
SDPR
4.733899e-10
2
RPS25
9.032935e-198
S100A8
1.622835e-238
HLA-DRA
6.949695e-167
B2M
1.364508e-81
GZMB
1.429027e-88
AIF1
1.348814e-83
HLA-DRA
1.306768e-19
GNG11
4.733899e-10
3
RPS27
8.254312e-188
TYROBP
2.957652e-220
CD79B
2.569135e-154
CST7
7.977466e-78
CTSW
4.144726e-87
COTL1
5.974694e-82
HLA-DRB1
1.865104e-19
PPBP
4.744938e-10
4
RPS6
8.002057e-185
FTL
2.479195e-214
HLA-DPB1
3.580735e-148
GZMA
7.266551e-74
PRF1
1.692100e-85
FCGR3A
1.392377e-77
CD74
5.853161e-19
NRGN
4.800511e-10
1 2 3
# compare between groups sc.tl.rank_genes_groups(adata, 'leiden', groups=['0'], reference='1', method='wilcoxon') sc.pl.rank_genes_groups(adata, groups=['0'], n_genes=20)
ranking genes
finished: added to `.uns['rank_genes_groups']`
'names', sorted np.recarray to be indexed by group ids
'scores', sorted np.recarray to be indexed by group ids
'logfoldchanges', sorted np.recarray to be indexed by group ids
'pvals', sorted np.recarray to be indexed by group ids
'pvals_adj', sorted np.recarray to be indexed by group ids (0:00:00)
1 2
# 0 vs. 1 sc.pl.rank_genes_groups_violin(adata, groups='0', n_genes=8)
e:\miniconda3\envs\pysc\lib\site-packages\seaborn\categorical.py:166: FutureWarning: Setting a gradient palette using color= is deprecated and will be removed in version 0.13. Set `palette='dark:black'` for same effect.
warnings.warn(msg, FutureWarning)
1 2 3
# Reload the object with the computed differential expression (i.e. DE via a comparison with the rest of the groups): adata = sc.read(results_file) sc.pl.rank_genes_groups_violin(adata, groups='0', n_genes=8)
e:\miniconda3\envs\pysc\lib\site-packages\seaborn\categorical.py:166: FutureWarning: Setting a gradient palette using color= is deprecated and will be removed in version 0.13. Set `palette='dark:black'` for same effect.
warnings.warn(msg, FutureWarning)
1 2
# plot expression across clusters sc.pl.violin(adata, ['CST3', 'NKG7', 'PPBP'], groupby='leiden')
WARNING: saving figure to file figures\umap.pdf
e:\miniconda3\envs\pysc\lib\site-packages\scanpy\plotting\_tools\scatterplots.py:392: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap' will be ignored
cax = scatter(
1 2
# dotplot for marker genes sc.pl.dotplot(adata, marker_genes, groupby='leiden')
e:\miniconda3\envs\pysc\lib\site-packages\scanpy\plotting\_dotplot.py:749: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap', 'norm' will be ignored
dot_ax.scatter(x, y, **kwds)
# save in h5ad adata.write(results_file) # save in loom adata.write_loom("output/pbmc3k.loom")
The loom file will lack these fields:
{'X_umap', 'PCs', 'X_pca'}
Use write_obsm_varm=True to export multi-dimensional annotations
e:\miniconda3\envs\pysc\lib\site-packages\loompy\bus_file.py:68: NumbaDeprecationWarning: [1mThe 'nopython' keyword argument was not supplied to the 'numba.jit' decorator. The implicit default value for this argument is currently False, but it will be changed to True in Numba 0.59.0. See https://numba.readthedocs.io/en/stable/reference/deprecation.html#deprecation-of-object-mode-fall-back-behaviour-when-using-jit for details.[0m
def twobit_to_dna(twobit: int, size: int) -> str:
e:\miniconda3\envs\pysc\lib\site-packages\loompy\bus_file.py:85: NumbaDeprecationWarning: [1mThe 'nopython' keyword argument was not supplied to the 'numba.jit' decorator. The implicit default value for this argument is currently False, but it will be changed to True in Numba 0.59.0. See https://numba.readthedocs.io/en/stable/reference/deprecation.html#deprecation-of-object-mode-fall-back-behaviour-when-using-jit for details.[0m
def dna_to_twobit(dna: str) -> int:
e:\miniconda3\envs\pysc\lib\site-packages\loompy\bus_file.py:102: NumbaDeprecationWarning: [1mThe 'nopython' keyword argument was not supplied to the 'numba.jit' decorator. The implicit default value for this argument is currently False, but it will be changed to True in Numba 0.59.0. See https://numba.readthedocs.io/en/stable/reference/deprecation.html#deprecation-of-object-mode-fall-back-behaviour-when-using-jit for details.[0m
def twobit_1hamming(twobit: int, size: int) -> List[int]: