dpeerlab/Palantir

Error in pca_projections

sneupane04 opened this issue · 1 comments

I was running the codes from the notebook and encountered this error using the same example in:
https://nbviewer.org/github/dpeerlab/Palantir/blob/master/notebooks/Palantir_sample_notebook.ipynb

pca_projections, _ = palantir.utils.run_pca(norm_df)

Error:


ValueError Traceback (most recent call last)
Input In [42], in <cell line: 1>()
----> 1 pca_projections, _ = palantir.utils.run_pca(norm_df, n_components=ncomps)

File ~/opt/anaconda3/lib/python3.9/site-packages/palantir/utils.py:28, in run_pca(data, n_components, use_hvg)
26 n_comps = n_components
27 else:
---> 28 sc.pp.pca(ad, n_comps=1000, use_highly_variable=True, zero_center=False)
29 try:
30 n_comps = np.where(np.cumsum(ad.uns['pca']['variance_ratio']) > 0.85)[0][0]

File ~/opt/anaconda3/lib/python3.9/site-packages/scanpy/preprocessing/_pca.py:132, in pca(data, n_comps, zero_center, svd_solver, random_state, return_info, use_highly_variable, dtype, copy, chunked, chunk_size)
129 adata = AnnData(data, dtype=data.dtype)
131 if use_highly_variable is True and 'highly_variable' not in adata.var.keys():
--> 132 raise ValueError(
133 'Did not find adata.var['highly_variable']. '
134 'Either your data already only consists of highly-variable genes '
135 'or consider running pp.highly_variable_genes first.'
136 )
137 if use_highly_variable is None:
138 use_highly_variable = True if 'highly_variable' in adata.var.keys() else False

ValueError: Did not find adata.var['highly_variable']. Either your data already only consists of highly-variable genes or consider running pp.highly_variable_genes first.

Are there more steps to run before running pca?

Please run sc.pp.highly_variable_genes before running PCA