neurorestore / Augur

Cell type prioritization in single-cell data
MIT License
100 stars 11 forks source link

Column 'labels' is NULL #4

Open thugib opened 4 years ago

thugib commented 4 years ago

I am running Augur on a Seurat object that was created using Seurat's integrating datasets methods. I receive an error that 'Column 'labels' is NULL. The R commands and results are below:

augur = calculate_auc(ABCpm.combined) Error: All columns in a tibble must be vectors. x Column labels is NULL. Run rlang::last_error() to see where the error occurred. rlang::last_error() <error/tibble_error_column_scalar_type> All columns in a tibble must be vectors. x Column labels is NULL. Backtrace:

  1. Augur::calculate_auc(ABCpm.combined)
  2. dplyr::n_distinct(labels)
  3. tibble:::as_tibble.list(columns, .name_repair = "minimal")
  4. tibble:::lst_to_tibble(x, .rows, .name_repair, col_lengths(x))
  5. tibble:::check_valid_cols(x) Run rlang::last_trace() to see the full context. rlang::last_trace() <error/tibble_error_column_scalar_type> All columns in a tibble must be vectors. x Column labels is NULL. Backtrace: █
  6. └─Augur::calculate_auc(ABCpm.combined)
  7. └─dplyr::n_distinct(labels)
  8. ├─tibble::as_tibble(columns, .name_repair = "minimal")
  9. └─tibble:::as_tibble.list(columns, .name_repair = "minimal")
  10. └─tibble:::lst_to_tibble(x, .rows, .name_repair, col_lengths(x))
  11. └─tibble:::check_valid_cols(x)
skinnider commented 4 years ago

Hi @thugib, Augur assumes by default that your sample labels will be a column label (singular, not plural). You can either rename this column in your Seurat object, or set the label_col argument to calculate_auc:

augur = calculate_auc(ABCpm.combined, cell_type_col = "labels")
thugib commented 4 years ago

Hi skinnider, So, I do not have a 'labels' in the Seuart object. Looking at the metadata: ..@ meta.data :'data.frame': 2152 obs. of 10 variables: .. ..$ orig.ident : chr [1:2152] "root" "root" "root" "root" ... .. ..$ nCount_RNA : num [1:2152] 2515 35299 4830 11057 3212 ... . ..$ nFeature_RNA : int [1:2152] 1369 4560 2314 1475 1624 4561 1269 2856 2450 1389 ... .. ..$ percent.mt : num [1:2152] 0 0.275 3.499 1.348 0.28 ... .. ..$ nCount_SCT : num [1:2152] 4805 6460 5398 6798 5320 ... .. ..$ nFeature_SCT : int [1:2152] 1430 2116 2271 1353 1612 1807 1472 2830 2392 1463 ... .. ..$ treatment : chr [1:2152] "minus" "minus" "minus" "minus" ... .. ..$ group : chr [1:2152] "A" "A" "A" "A" ... .. ..$ integrated_snn_res.0.5: Factor w/ 12 levels "0","1","2","3",..: 4 7 5 9 2 7 3 2 5 12 ... .. ..$ seurat_clusters : Factor w/ 12 levels "0","1","2","3",..: 4 7 5 9 2 7 3 2 5 12

I tried using 'treatment' for the labels: augur = calculate_auc(ABCpm.combined, cell_type_col = "seurat_clusters", label_col = "treatment" )

But, I was getting an error: Error in calculate_auc(ABCpm.combined, cell_type_col = "seurat_clusters", : (converted from warning) coercing labels to factor ...

So, I had to convert 'treatment' into a factor: ABCpm.combinedAu@meta.data$treatment <- as.factor(ABCpm.combinedAu@meta.data$treatment)

and they I could run: augur = calculate_auc(ABCpm.combinedAu, cell_type_col = "seurat_clusters", label_col = "treatment" )

Now it works ! Thanks.