Yijia-Jiang / scATAnno-main

0 stars 1 forks source link

Can't run the scATAnno_KNN_assign() #3

Open QuietgraceH opened 1 year ago

QuietgraceH commented 1 year ago

Hi,Yijia.Thank you for the tool you developed. It is a necessary and practical method for cell type definition. Now when I use the BCC_sample sample for testing, I run the following code query_KNN =scATAnno_assignment.scATAnno_KNN_assign(reference,query,reference_label_col="celltypes") and report an error. The error message is as follows. I don’t know how to solve it. I would like to ask you for help.Python version is 3.8.17. Error message:

AttributeError                            Traceback (most recent call last)
Cell In[109], line 6
      4 use_rep = "X_spectral_harmony"
      5 atlas = "HealthyAdult"
----> 6 query_KNN = scATAnno_assignment.scATAnno_KNN_assign(reference,query,reference_label_col="celltypes")
      7 #query_distance = scATAnno_assignment.scATAnno_distance_assign(reference, query, reference_label_col=reference_label_col, distance_threshold=distance_threshold, atlas=atlas, uncertainty_threshold=uncertainty_threshold, use_rep = use_rep)

File /data/houjy/anaconda3/envs/ATAnno/lib/python3.8/site-packages/scATAnno/scATAnno_assignment.py:96, in scATAnno_KNN_assign(reference, query, reference_label_col, low_dim_col, knn_neighbors, in_place)
     92 dists, indices, neighbors_labels, sigma = KNN_classifier(reference, query, low_dim_col = low_dim_col, n_neighbors = knn_neighbors,celltype_col = reference_label_col)
     94 K = gaussian_kernal(dists, sigma)
---> 96 pred_res_major = raw_assignment(K, neighbors_labels)
     98 if in_place:
     99     query.obsm["kernel_distance"] = K

File /data/houjy/anaconda3/envs/ATAnno/lib/python3.8/site-packages/scATAnno/scATAnno_assignment.py:77, in raw_assignment(K, neighbors_labels)
     75     pred_y = u.index[np.argmin(u)]
     76     prediction.append(pred_y)
---> 77     uncertainty.append(np.min(u).values[0])
     78 return prediction, uncertainty

AttributeError: 'numpy.float64' object has no attribute 'values'

Sincerely, Jingya

QuietgraceH commented 1 year ago

Sorry to bother you again. I would like to ask, my sample features are gene names, which are different from the reference features, how to solve this problem.When I run this code assert reference_data.var.shape[0] == sample.var.shape[0] I get an error AssertionError Traceback (most recent call last) Cell In[21], line 1 ----> assert reference_data.var.shape[0] == sample.var.shape[0]

query data feature is a dataframe(24919 rows × 0 columns), as follow: OR4F5 LOC729737 LOC101928626 FAM87B LINC01128 ... RAB39B CLIC2 H2AFB1 F8A2 TMLHE

Yijia-Jiang commented 9 months ago

Hi Jingya, scATAnno cannot use genes as input. You will need to preprocess your scATAC-seq data by following the instructions here (https://github.com/Yijia-Jiang/scATAnno-main/blob/main/prep_data/RunTILAtlas.sh). After you obtain the peak-cell count matrix for your scATAC-seq data, then follow the tutorial.