pachterlab / concordexR

Compute the neighborhood consolidation matrix and identify SHRs
https://pachterlab.github.io/concordexR/
Artistic License 2.0
13 stars 0 forks source link

Issue with check_labels() #3

Closed alecbarrett closed 4 months ago

alecbarrett commented 4 months ago

Hello,

I'm running into an issue running concordexR on my dataset. I'm running with just loading the metadata, trying to follow the example code from the liver dataset in the biorxiv github, but I'm getting an error that seems to trace back to a function that's checking to make sure that every cell has a label. I'm getting this error no matter what annotation I use (leiden, custom cell annotation, random), and I've been ensuring that the labels are encoded as character per the example code I'm using as a template.

The length of the labels is the same as the number of observations, but I'm getting an error saying that they are not the same length. Funnily enough the error message seems to agree! (see below).

Attached code, the metadata that gave the error, the error output, and the R session info. 240722_CellMeta.csv

`#### load libraries library(tidyr) library(dplyr)

library(ggplot2) library(scattermore) library(fs)

devtools::install_github('pachterlab/concordexR')

library(concordexR)

load in metadata ----

meta <- read_csv('Data/240722_CellMeta.csv') meta |> colnames()

coords <- meta[,c("center_x","center_y")]

coords$center_x |> typeof()

cdx <- calculateConcordex( x=coords, labels=meta$leiden, BLUSPARAM=bluster::MbkmeansParam(4,50) )

`

rlang::last_trace(drop = FALSE) <error/rlang_error> Error: ! The number of labels provided is not equal to the number of observations in x ℹ 1000 labels were supplied, but 1000 were expected

Backtrace: ▆

  1. ├─concordexR::calculateConcordex(x = coords, labels = H1602_metadata$leiden[1:1000])
  2. └─concordexR::calculateConcordex(x = coords, labels = H1602_metadata$leiden[1:1000])
  3. └─concordexR (local) .local(x, ...)
  4. └─concordexR:::check_labels(labels, expected = dim(x)[1])
  5. └─concordexR:::stop_no_call(...)
  6. ├─base::do.call(cli_fun, args = c(cli_args, dots))
  7. └─cli::cli_abort(...)
  8. └─rlang::abort(...)

`> sessionInfo() R version 4.4.1 (2024-06-14 ucrt) Platform: x86_64-w64-mingw32/x64 Running under: Windows 10 x64 (build 19045)

Matrix products: default

locale: [1] LC_COLLATE=English_United States.utf8 LC_CTYPE=English_United States.utf8
[3] LC_MONETARY=English_United States.utf8 LC_NUMERIC=C
[5] LC_TIME=English_United States.utf8

time zone: America/Los_Angeles tzcode source: internal

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] concordexR_0.99.3 readr_2.1.5 fs_1.6.4 scattermore_1.2 ggplot2_3.5.1
[6] dplyr_1.1.4 tidyr_1.3.1

loaded via a namespace (and not attached): [1] SummarizedExperiment_1.34.0 gtable_0.3.5 rjson_0.2.21
[4] Biobase_2.64.0 lattice_0.22-6 tzdb_0.4.0
[7] vctrs_0.6.5 tools_4.4.1 generics_0.1.3
[10] stats4_4.4.1 parallel_4.4.1 tibble_3.2.1
[13] fansi_1.0.6 cluster_2.1.6 pkgconfig_2.0.3
[16] BiocNeighbors_1.20.2 Matrix_1.7-0 S4Vectors_0.42.0
[19] sparseMatrixStats_1.16.0 lifecycle_1.0.4 GenomeInfoDbData_1.2.12
[22] compiler_4.4.1 munsell_0.5.1 bluster_1.12.0
[25] codetools_0.2-20 GenomeInfoDb_1.40.1 pillar_1.9.0
[28] crayon_1.5.3 BiocParallel_1.38.0 SingleCellExperiment_1.26.0 [31] DelayedArray_0.30.1 magick_2.8.4 abind_1.4-5
[34] tidyselect_1.2.1 purrr_1.0.2 grid_4.4.1
[37] colorspace_2.1-0 cli_3.6.3 SparseArray_1.4.8
[40] magrittr_2.0.3 S4Arrays_1.4.1 utf8_1.2.4
[43] withr_3.0.0 scales_1.3.0 UCSC.utils_1.0.0
[46] bit64_4.0.5 XVector_0.44.0 httr_1.4.7
[49] matrixStats_1.3.0 bit_4.0.5 igraph_2.0.3
[52] hms_1.1.3 SpatialExperiment_1.12.0 GenomicRanges_1.56.1
[55] IRanges_2.38.0 rlang_1.1.4 Rcpp_1.0.12
[58] glue_1.7.0 BiocGenerics_0.50.0 rstudioapi_0.16.0
[61] vroom_1.6.5 jsonlite_1.8.8 R6_2.5.1
[64] MatrixGenerics_1.16.0 zlibbioc_1.50.0 `

kayla-jackson commented 4 months ago

Hi @alecbarrett I've been updating these checks throughout the morning and writing new tests to address #2. I may have temporarily broken things, sorry!

As a first thought though, I did forget to add conditional controls for displaying the error you described, and I fixed it with 068c6ba. Can you try updating the package to the most recent version that fixes this issue?

alecbarrett commented 4 months ago

hi @kayla-jackson, thanks for the quick response! re-install fixed that issue, but I hit a new error that I was missing the mbkmeans package, installing that manually worked well and now it all seems to be working. Thanks!