GuangyuWangLab2021 / cellDancer

Predict RNA velocity through deep learning
https://guangyuwanglab2021.github.io/cellDancer_website/
BSD 3-Clause "New" or "Revised" License
60 stars 11 forks source link

ValueError in RNA velocity estimation #5

Closed liuxz1213 closed 1 year ago

liuxz1213 commented 1 year ago

when I used this command for the RNA velocity estimation: cd.velocity(cell_type_u_s_test, permutation_ratio=0.125, n_jobs=8)

then, got the error ValueError: Input contains NaN, infinity or a value too large for dtype('float64').

My data has many zero in unsplice and splice count, Is this the cause of the problem?

Abclisy commented 1 year ago

Hi, thank you for the feedback! Could you show us the detail of the error message, your device, and your Python environment? Also, if possible, could you provide a small subset of your data to let us repeat your error?

Abclisy commented 1 year ago

Hi, one possible reason for your data containing many zeros is that the preprocessing is not complete. The codes below probably will give you some ideas of pre-processing.

# !pip install scvelo --upgrade --quiet
import scvelo as scv
scv.pp.filter_and_normalize(adata, min_shared_counts=20, n_top_genes=2000)
scv.pp.moments(adata, n_pcs=30, n_neighbors=30)

scv.pp.filter_and_normalize function runs the following

scv.pp.filter_genes(adata, min_shared_counts=20)
scv.pp.normalize_per_cell(adata)
scv.pp.filter_genes_dispersion(adata, n_top_genes=2000)
scv.pp.log1p(adata)

You may also want to visualize genes before the prediction as the scripts shown below.

ncols=5
height=math.ceil(len(gene_list)/5)*4
fig = plt.figure(figsize=(20,height))

for i in range(len(gene_list)):
    ax = fig.add_subplot(math.ceil(len(gene_list)/ncols), ncols, i+1)
    cdplt.scatter_gene(
        ax=ax,
        x='splice',
        y='unsplice',
        cellDancer_df=cellDancer_df,
        custom_xlim=None,
        custom_ylim=None,
        alpha=0.5,
        s = 5,
        # velocity=True,
        gene=gene_list[i])

    ax.set_title(gene_list[i])
    ax.axis('on')

plt.show()

For more information, Data Preparation might be helpful. We will add more details about the preprocessing on our website later. Thank you!

Abclisy commented 1 year ago

Hello, it's been a while since we heard back from you regarding this issue. We will be closing this issue. However, please don't hesitate to reopen it or create a new issue if you have further questions or concerns. Thank you for your understanding.