Repository navigation
No match for coord x,y,z #59
Copy link
Copy link
Open
Labels
Description
Hi There,
Im very impressed with this package, but am running into an issue as I am trying to read in our data.
Here is what the data look like:
> msa_pre
MSImagingArrays with 254387 spectra
spectraData(2): intensity, mz
pixelData(7): x, y, z, ..., 3DPositionX, 3DPositionY, 3DPositionZ
coord(3): x = 1...2002, y = 1...300, z = 1...1
runNames(1): tissue_fat_pad
experimentData(10): spectrumType, instrumentModel, ionSource, ..., scanType, lineScanDirection, pixelSize
centroided: NA
continuous: FALSE
And here is the coord slot:
> coord(msa_pre)
DataFrame with 254387 rows and 3 columns
x y z
<numeric> <numeric> <integer>
spectrum=0 57 124 1
spectrum=1 58 124 1
spectrum=2 59 124 1
spectrum=3 60 124 1
spectrum=4 61 124 1
... ... ... ...
spectrum=254382 357 233 1
spectrum=254383 358 233 1
spectrum=254384 359 233 1
spectrum=254385 360 233 1
spectrum=254386 361 233 1
I notice that x and y are numeric, and z is an integer.
When I try to plot by coord, I receive the following error:
> Cardinal::plot(msa_pre, coord = list(x = 57, y = 124, z = 1))
Error in plotlist[[1L]] : subscript out of bounds
In addition: Warning message:
in .find_positions(object, coord, run, tolerance): no match for coord x = 57, y = 124, z = 1; nearest is x = 57, y = 124, z = 1
I receive no such error when trying to plot by specifying the index:
> plot(msa_pre, i=2)
When I try to specify the type, I receive the same error:
> Cardinal::plot(msa_pre, coord = list(
+ x = as.numeric(57),
+ y = as.numeric(124),
+ z = as.integer(1)
+ ))
Error in plotlist[[1L]] : subscript out of bounds
In addition: Warning message:
in .find_positions(object, coord, run, tolerance): no match for coord x = 57, y = 124, z = 1; nearest is x = 57, y = 124, z = 1
I can see that the spectra exist at those coordinates:
> subset_spectrum <- spectra(msa_pre)[coord(msa_pre)$x == 57 & coord(msa_pre)$y == 124 & coord(msa_pre)$z == 1, ]
> str(subset_spectrum)
List of 1
$ spectrum=0: num [1:25511] 7 6 6 6 12 6 6 6 6 6 ...
Can you think of any reasons this could be? I note that there is only one z value, so removing that slot entirely would be a fine solution, if there are methods to achieve that.
Thank you very much,
Christian Potts
session info:
> sessionInfo()
R version 4.4.1 (2024-06-14)
Platform: aarch64-apple-darwin20
Running under: macOS 15.0.1
Matrix products: default
BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.12.0
Random number generation:
RNG: L'Ecuyer-CMRG
Normal: Inversion
Sample: Rejection
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
time zone: America/New_York
tzcode source: internal
attached base packages:
[1] stats4 stats graphics grDevices datasets utils methods base
other attached packages:
[1] lubridate_1.9.4 forcats_1.0.0 stringr_1.5.1 dplyr_1.1.4
[5] purrr_1.0.4 readr_2.1.5 tidyr_1.3.1 tibble_3.2.1
[9] ggplot2_3.5.1 tidyverse_2.0.0 Cardinal_3.8.3 S4Vectors_0.44.0
[13] ProtGenerics_1.38.0 BiocGenerics_0.52.0 BiocParallel_1.40.0 BiocManager_1.30.25
loaded via a namespace (and not attached):
[1] generics_0.1.3 tiff_0.1-12 renv_1.1.0 bitops_1.0-9 stringi_1.8.4
[6] jpeg_0.1-10 lattice_0.22-6 hms_1.1.3 digest_0.6.37 magrittr_2.0.3
[11] timechange_0.3.0 grid_4.4.1 fftwtools_0.9-11 fastmap_1.2.0 Matrix_1.7-1
[16] ontologyIndex_2.12 matter_2.8.0 scales_1.3.0 codetools_0.2-20 abind_1.4-8
[21] cli_3.6.3 rlang_1.1.5 CardinalIO_1.4.0 Biobase_2.66.0 EBImage_4.48.0
[26] munsell_0.5.1 withr_3.0.2 tools_4.4.1 parallel_4.4.1 tzdb_0.4.0
[31] colorspace_2.1-1 locfit_1.5-9.11 vctrs_0.6.5 R6_2.5.1 png_0.1-8
[36] lifecycle_1.0.4 htmlwidgets_1.6.4 irlba_2.3.5.1 pkgconfig_2.0.3 pillar_1.10.1
[41] gtable_0.3.6 glue_1.8.0 tidyselect_1.2.1 rstudioapi_0.17.1 htmltools_0.5.8.1
[46] nlme_3.1-166 compiler_4.4.1 RCurl_1.98-1.16
Reactions are currently unavailable

Activity
kuwisdelu commentedon Feb 5, 2025
I will leave this open to investigate further when I have more time. Datasets with an unnecessary z-dimension have been an issue in the past, and it looks like my testing didn't catch this.
For the time being, I would suggest removing the z-dimension if it isn't used.
Should do it.
ChrPotts commentedon Feb 7, 2025
That worked great! Thank you for the fast response.
kuwisdelu commentedon Feb 7, 2025
Keeping this open since it is still a bug, even though there is a workaround.