Open llumdi opened 1 year ago
Same error in function bc.st.additional_labeling()
adata = bc.st.additional_labeling(adata, "celltype1", "celltype1", "Major cell types, short names", annot_author, results_folder)
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
Cell In [93], line 2
1 ### Save labelling celltype1
----> 2 adata = bc.st.additional_labeling(adata, "celltype0", "celltype0", "Broad annotation, short names", annot_author, results_folder)
3 adata = bc.st.additional_labeling(adata, "celltype1", "celltype1", "Major cell types, short names", annot_author, results_folder)
4 adata = bc.st.additional_labeling(adata, "celltype2", "celltype2", "Intermediate cell types, short names", annot_author, results_folder)
File ~/scratch/conda/envs/besca25_LAS/lib/python3.8/site-packages/besca/st/_wrapper_funcs.py:706, in additional_labeling(adata, labeling_to_use, labeling_name, labeling_description, labeling_author, results_folder, cluster_method, is_celltype_labeling, filename)
703 if len(set(adata.obs.get(labeling_to_use))) != 1:
704 start1 = time()
--> 706 rank_genes_groups(
707 adata,
708 labeling_to_use,
709 method="wilcoxon",
710 use_raw=True,
711 n_genes=adata.raw.X.shape[1],
712 )
713 print("rank genes per label calculated using method wilcoxon.")
714 logging.info(
715 "Marker gene detection performed on a per-label basis using the method wilcoxon."
716 + "\n\tTime for marker gene detection: "
717 + str(round(time() - start1, 3))
718 + "s"
719 )
File ~/scratch/conda/envs/besca25_LAS/lib/python3.8/site-packages/scanpy/tools/_rank_genes_groups.py:590, in rank_genes_groups(adata, groupby, use_raw, groups, reference, n_genes, rankby_abs, pts, key_added, copy, method, corr_method, tie_correct, layer, **kwds)
580 adata.uns[key_added] = {}
581 adata.uns[key_added]['params'] = dict(
582 groupby=groupby,
583 reference=reference,
(...)
587 corr_method=corr_method,
588 )
--> 590 test_obj = _RankGenes(adata, groups_order, groupby, reference, use_raw, layer, pts)
592 if check_nonnegative_integers(test_obj.X) and method != 'logreg':
593 logg.warning(
594 "It seems you use rank_genes_groups on the raw count data. "
595 "Please logarithmize your data before calling rank_genes_groups."
596 )
File ~/scratch/conda/envs/besca25_LAS/lib/python3.8/site-packages/scanpy/tools/_rank_genes_groups.py:93, in _RankGenes.__init__(self, adata, groups, groupby, reference, use_raw, layer, comp_pts)
82 def __init__(
83 self,
84 adata,
(...)
90 comp_pts=False,
91 ):
---> 93 if 'log1p' in adata.uns_keys() and adata.uns['log1p']['base'] is not None:
94 self.expm1_func = lambda x: np.expm1(x * np.log(adata.uns['log1p']['base']))
95 else:
KeyError: 'base'
Looks like this scanpy bug: https://github.com/scverse/scanpy/issues/2239 The workaround as described in the above issue would be:
adata.uns['log1p']["base"] = None
Every time after reading a h5ad file.
Thanks, it works now. Would be good to add it in the celltype notebook until is fixed
By using besca25 I get the following error in the celltype annotation notebook:
DEgenes = bc.tl.dge.get_de(adata, clusters, demethod="wilcoxon", topnr=5000, logfc=1, padj=0.05)
This is a blocking error for my analysis. I hope you can help. Best, Llucia