NVIDIA-Genomics-Research / rapids-single-cell-examples

Examples of single-cell genomic analysis accelerated with RAPIDS
Apache License 2.0
318 stars 68 forks source link

fix `rapids_scanpy_funcs.highly_variable_genes` #111

Open hw-ju opened 1 year ago

hw-ju commented 1 year ago

In /notebooks/hlca_lung_gpu_analysis.ipynb, when run cell 19

%%time
hvg = rapids_scanpy_funcs.highly_variable_genes(sparse_gpu_array, genes, n_top_genes=5000)

it raises error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<timed exec> in <module>

/workspace/notebooks/rapids_scanpy_funcs.py in highly_variable_genes(sparse_gpu_array, genes, n_top_genes)
    801     mean = sparse_gpu_array.sum(axis=0).flatten() / n_cells
    802     mean_sq = sparse_gpu_array.multiply(sparse_gpu_array).sum(axis=0).flatten() / n_cells
--> 803     variable_genes = _cellranger_hvg(mean, mean_sq, genes, n_cells, n_top_genes)
    804 
    805     return variable_genes

/workspace/notebooks/rapids_scanpy_funcs.py in _cellranger_hvg(mean, mean_sq, genes, n_cells, n_top_genes)
    750     df = pd.DataFrame()
    751     # Note - can be replaced with cudf once 'cut' is added in 21.08
--> 752     df['genes'] = genes.to_numpy()
    753     df['means'] = mean.tolist()
    754     df['dispersions'] = dispersion.tolist()

AttributeError: 'Series' object has no attribute 'to_numpy'

Could you fix the rapids_scanpy_funcs.highly_variable_genes?