Closed mbuttner closed 6 years ago
Hi, I tested the provided cell cycle notebook (with the data provided) in the following scanpy setup:
Running Scanpy 1.1a1+15.g1570f7c on 2018-05-18 16:30. Dependencies: anndata==0.6.1+1.ga489245 numpy==1.13.1 scipy==0.19.1 pandas==0.21.0 scikit-learn==0.19.0 statsmodels==0.8.0 python-igraph==0.7.1 louvain==0.6.0+20.g3de109d
running the line sc.tl.score_genes_cell_cycle(adata, s_genes=s_genes, g2m_genes=g2m_genes)
sc.tl.score_genes_cell_cycle(adata, s_genes=s_genes, g2m_genes=g2m_genes)
results in
calculating cell cycle phase computing score 'S_score' --> could not add 'S_score', score of gene set (adata.obs) computing score 'G2M_score' --> could not add 'G2M_score', score of gene set (adata.obs) --------------------------------------------------------------------------- KeyError Traceback (most recent call last) <ipython-input-9-5874179be677> in <module>() ----> 1 sc.tl.score_genes_cell_cycle(adata, s_genes=s_genes, g2m_genes=g2m_genes) ~/Documents/Python/scanpy/scanpy/tools/score_genes.py in score_genes_cell_cycle(adata, s_genes, g2m_genes, copy, **kwargs) 170 # add g2m-score 171 score_genes(adata, gene_list=g2m_genes, score_name='G2M_score', ctrl_size=ctrl_size, **kwargs) --> 172 scores = adata.obs[['S_score', 'G2M_score']] 173 174 # default phase is S ~/miniconda3/lib/python3.6/site-packages/pandas/core/frame.py in __getitem__(self, key) 2131 if isinstance(key, (Series, np.ndarray, Index, list)): 2132 # either boolean or fancy integer index -> 2133 return self._getitem_array(key) 2134 elif isinstance(key, DataFrame): 2135 return self._getitem_frame(key) ~/miniconda3/lib/python3.6/site-packages/pandas/core/frame.py in _getitem_array(self, key) 2175 return self._take(indexer, axis=0, convert=False) 2176 else: -> 2177 indexer = self.loc._convert_to_indexer(key, axis=1) 2178 return self._take(indexer, axis=1, convert=True) 2179 ~/miniconda3/lib/python3.6/site-packages/pandas/core/indexing.py in _convert_to_indexer(self, obj, axis, is_setter) 1267 if mask.any(): 1268 raise KeyError('{mask} not in index' -> 1269 .format(mask=objarr[mask])) 1270 1271 return _values_from_object(indexer) KeyError: "['S_score' 'G2M_score'] not in index"
Sorry for this, Maren. Is fixed in https://github.com/theislab/scanpy/commit/116b4f1ec1d4c235a577a6672c60957387207916.
Hi, I tested the provided cell cycle notebook (with the data provided) in the following scanpy setup:
running the line
sc.tl.score_genes_cell_cycle(adata, s_genes=s_genes, g2m_genes=g2m_genes)
results in