Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: x.cell_ID is type environment which is not supported by data.table join in doLeidenCluster function #1090

Open
yuhan1li opened this issue Jan 7, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@yuhan1li
Copy link

yuhan1li commented Jan 7, 2025

Description
I encountered an error while running the doLeidenCluster function on my visium_brain object. The error message is as follows:
Error: x.cell_ID is type environment which is not supported by data.table join

Steps to Reproduce
Here’s the code snippet that caused the error:
visium_brain <- doLeidenCluster(
gobject = visium_brain,
resolution = 0.4,
n_iterations = 1000
)

Expected Behavior
I expected the function to run without errors and return the updated visium_brain object with Leiden clustering results.
What I Have Tried:
1、Verified that the visium_brain object is correctly initialized.
2、Checked that all required libraries are loaded.
3、Attempted to inspect the x.cell_ID attribute in visium_brain,
class(visium_brain@cell_ID)
[1] "list"

class(visium_brain@cell_ID[["cell"]])
[1] "character"

Session Info
Here’s my session information for reference:

sessionInfo()
R version 4.4.0 (2024-04-24)
Platform: x86_64-pc-linux-gnu
Running under: Ubuntu 22.04.4 LTS

Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so; LAPACK version 3.10.0

locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

time zone: Etc/UTC
tzcode source: system (glibc)

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

other attached packages:
[1] reticulate_1.37.0 patchwork_1.2.0 lubridate_1.9.3 forcats_1.0.0 stringr_1.5.1
[6] dplyr_1.1.4 purrr_1.0.2 readr_2.1.5 tidyr_1.3.1 tibble_3.2.1
[11] ggplot2_3.5.1 tidyverse_2.0.0 Seurat_5.1.0 SeuratObject_5.0.2 sp_2.1-4
[16] Giotto_4.1.0 GiottoClass_0.3.3 GiottoVisuals_0.2.4

loaded via a namespace (and not attached):
[1] RColorBrewer_1.1-3 rstudioapi_0.16.0 jsonlite_1.8.8 magrittr_2.0.3 spatstat.utils_3.0-4
[6] magick_2.8.3 zlibbioc_1.52.0 vctrs_0.6.5 ROCR_1.0-11 spatstat.explore_3.2-7
[11] GiottoUtils_0.1.11 terra_1.7-78 htmltools_0.5.8.1 sctransform_0.4.1 parallelly_1.37.1
[16] KernSmooth_2.23-22 htmlwidgets_1.6.4 ica_1.0-3 plyr_1.8.9 plotly_4.10.4
[21] zoo_1.8-12 igraph_2.0.3 mime_0.12 lifecycle_1.0.4 pkgconfig_2.0.3
[26] Matrix_1.7-0 R6_2.5.1 fastmap_1.2.0 fitdistrplus_1.1-11 future_1.33.2
[31] shiny_1.8.1.1 digest_0.6.35 colorspace_2.1-0 S4Vectors_0.44.0 tensor_1.5
[36] RSpectra_0.16-1 irlba_2.3.5.1 progressr_0.14.0 fansi_1.0.6 spatstat.sparse_3.0-3
[41] timechange_0.3.0 httr_1.4.7 polyclip_1.10-6 abind_1.4-5 compiler_4.4.0
[46] withr_3.0.0 backports_1.5.0 fastDummies_1.7.3 R.utils_2.12.3 MASS_7.3-60.2
[51] gtools_3.9.5 tools_4.4.0 lmtest_0.9-40 httpuv_1.6.15 future.apply_1.11.2
[56] goftest_1.2-3 R.oo_1.26.0 glue_1.7.0 dbscan_1.1-12 nlme_3.1-164
[61] promises_1.3.0 grid_4.4.0 checkmate_2.3.1 Rtsne_0.17 cluster_2.1.6
[66] reshape2_1.4.4 generics_0.1.3 gtable_0.3.5 spatstat.data_3.0-4 tzdb_0.4.0
[71] R.methodsS3_1.8.2 hms_1.1.3 data.table_1.15.4 utf8_1.2.4 XVector_0.46.0
[76] BiocGenerics_0.52.0 spatstat.geom_3.2-9 RcppAnnoy_0.0.22 ggrepel_0.9.5 RANN_2.6.1
[81] pillar_1.9.0 spam_2.10-0 RcppHNSW_0.6.0 later_1.3.2 splines_4.4.0
[86] lattice_0.22-6 survival_3.5-8 deldir_2.0-4 tidyselect_1.2.1 miniUI_0.1.1.1
[91] pbapply_1.7-2 gridExtra_2.3 IRanges_2.40.1 scattermore_1.2 stats4_4.4.0
[96] matrixStats_1.4.1 stringi_1.8.4 lazyeval_0.2.2 codetools_0.2-20 colorRamp2_0.1.0
[101] cli_3.6.2 uwot_0.2.2 xtable_1.8-4 munsell_0.5.1 Rcpp_1.0.12
[106] spatstat.random_3.2-3 globals_0.16.3 png_0.1-8 parallel_4.4.0 dotCall64_1.1-1
[111] listenv_0.9.1 viridisLite_0.4.2 scales_1.3.0 ggridges_0.5.6 leiden_0.4.3.1
[116] rlang_1.1.4 cowplot_1.1.3

Reproducible Example
If necessary, I can provide a reproducible example, though the issue seems related to how x.cell_ID is handled internally by doLeidenCluster.

Additional Context
I’m using the doLeidenCluster function from the Giotto package. My object visium_brain was created and processed following the steps in the package documentation.

Questions
Is there a specific preprocessing step I might have missed that causes x.cell_ID to be an environment type?
Are there any known compatibility issues with data.table or doLeidenCluster in recent package versions?

@yuhan1li yuhan1li added the bug Something isn't working label Jan 7, 2025
@RubD
Copy link
Collaborator

RubD commented Jan 8, 2025

Can you share minimal code to reproduce the problem? I believe you might have done some additional steps that causes this issue.

@yuhan1li
Copy link
Author

Can you share minimal code to reproduce the problem? I believe you might have done some additional steps that causes this issue.

Thank you for your response! Below is the minimal code I used to reproduce the issue.

The data path I am using is ./k11.Giotto/数据/10x_brain/, and my Python environment path is /home/liuhuilin2/anaconda3/envs/giotto_env/bin/python. Here’s the code:
`
library(Giotto)
library(Seurat)
library(tidyverse)
library(patchwork)
##Create Giotto Instructions
python_path <- "/home/liuhuilin2/anaconda3/envs/giotto_env/bin/python"
instructions <- createGiottoInstructions(save_dir = "./out_example/",
save_plot = TRUE,
show_plot = FALSE,
return_plot = FALSE,
python_path = python_path)
##provide path to visium folder
data_path <- "./k11.Giotto/数据/10x_brain/"

##directly from visium folder
visium_brain <- createGiottoVisiumObject(visium_dir = data_path,
expr_data = "filter",
png_name = "tissue_lowres_image.png",
gene_column_index = 2,
instructions = instructions)

##subset on spots that were covered by tissue
metadata <- pDataDT(visium_brain)
in_tissue_barcodes <- metadata[in_tissue == 1]$cell_ID

visium_brain <- subsetGiotto(visium_brain,
cell_ids = in_tissue_barcodes)

##filter
visium_brain <- filterGiotto(gobject = visium_brain,
expression_threshold = 1,
feat_det_in_min_cells = 50,
min_det_feats_per_cell = 1000,
expression_values = "raw",
verbose = TRUE)

normalize

visium_brain <- normalizeGiotto(gobject = visium_brain,
scalefactor = 6000,
verbose = TRUE)

add gene & cell statistics

visium_brain <- addStatistics(gobject = visium_brain)

5 highly variable features / genes (HVF)

visium_brain <- calculateHVF(gobject = visium_brain,
save_plot = TRUE)

##run PCA on expression values (default)
gene_metadata <- fDataDT(visium_brain)
featgenes <- gene_metadata[hvf == "yes" & perc_cells > 3 & mean_expr_det > 0.4]$feat_ID

run PCA on expression values (default)

visium_brain <- runPCA(gobject = visium_brain,
feats_to_use = featgenes)

run UMAP and tSNE on PCA space (default)

visium_brain <- runUMAP(visium_brain,
dimensions_to_use = 1:10)

plotUMAP(gobject = visium_brain)

visium_brain <- runtSNE(visium_brain,
dimensions_to_use = 1:10)

plotTSNE(gobject = visium_brain)

6 Clustering

SNN network (default)

visium_brain <- createNearestNetwork(gobject = visium_brain,
dimensions_to_use = 1:10,
k = 15)

visium_brain <- doLeidenCluster(gobject = visium_brain,
resolution = 0.4,
n_iterations = 1000)

` The above code runs smoothly until the final step.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants