Giter VIP home page Giter VIP logo

celltrek's Introduction

A Quick Tour of CellTrek Toolkit

1. Introduction and installation

CellTrek is a computational framework that can directly map single cells back to their spatial coordinates in tissue sections based on scRNA-seq and ST data. This method provides a new paradigm that is distinct from ST deconvolution, enabling a more flexible and direct investigation of single cell data with spatial topography. The CellTrek toolkit also provides two downstream analysis modules, including SColoc for spatial colocalization analysis and SCoexp for spatial co-expression analysis.

In this tutorial, we will demonstrate the cell charting workflow based on the mouse brain data as part of our paper Figure 2

library(devtools)
install_github("navinlabcode/CellTrek")

2. Loading the packages and datasets (scRNA-seq and ST data)

We start by loading the packages needed for the analyses. Please install them if you haven't.

options(stringsAsFactors = F)
library("CellTrek")
library("dplyr")
library("Seurat")
library("viridis")
library("ConsensusClusterPlus")

We then load mouse brain scRNA-seq and ST data, respectively. For ST data, we only used the frontal cortex region for this study. For scRNA-seq data, if you are running the code on a personal laptop, you may need to subset the scRNA-seq data to hundreds of cells since it will cost several minutes for using the whole scRNA-seq data in the CellTrek step.

You can download the scRNA-seq data here: https://www.dropbox.com/s/ruseq3necn176c7/brain_sc.rds?dl=0

You can download the ST data here: https://www.dropbox.com/s/azjysbt7lbpmbew/brain_st_cortex.rds?dl=0

brain_st_cortex <- readRDS("brain_st_cortex.rds")
brain_sc <- readRDS("brain_sc.rds")

## Rename the cells/spots with syntactically valid names
brain_st_cortex <- RenameCells(brain_st_cortex, new.names=make.names(Cells(brain_st_cortex)))
brain_sc <- RenameCells(brain_sc, new.names=make.names(Cells(brain_sc)))

## Visualize the ST data
SpatialDimPlot(brain_st_cortex)

## Visualize the scRNA-seq data
DimPlot(brain_sc, label = T, label.size = 4.5)

3. Cell charting using CellTrek

We first co-embed ST and scRNA-seq datasets using traint

brain_traint <- CellTrek::traint(st_data=brain_st_cortex, sc_data=brain_sc, sc_assay='RNA', cell_names='cell_type')
## Finding transfer anchors... 
## Using 2000 features for integration... 
## Data transfering... 
## Creating new Seurat object... 
## Scaling -> PCA -> UMAP...
## We can check the co-embedding result to see if there is overlap between these two data modalities
DimPlot(brain_traint, group.by = "type") 

After coembedding, we can chart single cells to their spatial locations. Here, we use the non-linear interpolation (intp = T, intp_lin=F) approach to augment the ST spots.

brain_celltrek <- CellTrek::celltrek(st_sc_int=brain_traint, int_assay='traint', sc_data=brain_sc, sc_assay = 'RNA', 
                                   reduction='pca', intp=T, intp_pnt=5000, intp_lin=F, nPCs=30, ntree=1000, 
                                   dist_thresh=0.55, top_spot=5, spot_n=5, repel_r=20, repel_iter=20, keep_model=T)$celltrek
## Distance between spots is: 138 
## Interpolating...
## Random Forest training... 
## Random Forest prediction...  
## Making distance matrix... 
## Making graph... 
## Pruning graph...
## Spatial Charting SC data...
## Repelling points...
## Creating Seurat Object... 
## sc data...

After cell charting, we can interactively visualize the CellTrek result using celltrek_vis

brain_celltrek$cell_type <- factor(brain_celltrek$cell_type, levels=sort(unique(brain_celltrek$cell_type)))

CellTrek::celltrek_vis(brain_celltrek@meta.data %>% dplyr::select(coord_x, coord_y, cell_type:id_new),
                       brain_celltrek@images$anterior1@image, brain_celltrek@images$anterior1@scale.factors$lowres)

We select “cell_type” from the “Color” option and set “Categorical” from “Type” option.

4. Cell colocalization analysis

Based on the CellTrek result, we can summarize the colocalization patterns between different cell types using SColoc module. Here, we are using glutamatergic neuron cell types as an example (it is recommended to remove some cell types with very few cells, e.g., n<20). We first subset the glutamatergic neuron cell types from our charting result.

glut_cell <- c('L2/3 IT', 'L4', 'L5 IT', 'L5 PT', 'NP', 'L6 IT', 'L6 CT',  'L6b')
names(glut_cell) <- make.names(glut_cell)
brain_celltrek_glut <- subset(brain_celltrek, subset=cell_type %in% glut_cell)
brain_celltrek_glut$cell_type <- factor(brain_celltrek_glut$cell_type, levels=glut_cell)

Then we can use scoloc module to perform colocalization analysis.

brain_sgraph_KL <- CellTrek::scoloc(brain_celltrek_glut, col_cell='cell_type', use_method='KL', eps=1e-50)
## 1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  19  20
## We extract the minimum spanning tree (MST) result from the graph
brain_sgraph_KL_mst_cons <- brain_sgraph_KL$mst_cons
rownames(brain_sgraph_KL_mst_cons) <- colnames(brain_sgraph_KL_mst_cons) <- glut_cell[colnames(brain_sgraph_KL_mst_cons)]
## We then extract the metadata (including cell types and their frequencies)
brain_cell_class <- brain_celltrek@meta.data %>% dplyr::select(id=cell_type) %>% unique
brain_celltrek_count <- data.frame(freq = table(brain_celltrek$cell_type))
brain_cell_class_new <- merge(brain_cell_class, brain_celltrek_count, by.x ="id", by.y = "freq.Var1")

Next, we can visualize the colocalization result. Feel free to adjust the edge value cutoff.

CellTrek::scoloc_vis(brain_sgraph_KL_mst_cons, meta_data=brain_cell_class)

5. Spatial-weighted gene co-expression analysis within the cell type of interest

Based on the CellTrek result, we can further investigate the co-expression patterns within the cell type of interest using SCoexp module. Here, we will take L5 IT cells as an example using consensus clustering (CC) method. L5 IT cells first are extracted from the charting result.

brain_celltrek_l5 <- subset(brain_celltrek, subset=cell_type=='L5 IT')
brain_celltrek_l5@assays$RNA@scale.data <- matrix(NA, 1, 1)
brain_celltrek_l5$cluster <- gsub('L5 IT VISp ', '', brain_celltrek_l5$cluster)
DimPlot(brain_celltrek_l5, group.by = 'cluster')

We select top 2000 variable genes (exclude mitochondrial, ribosomal and high-zero genes)

brain_celltrek_l5 <- FindVariableFeatures(brain_celltrek_l5)
vst_df <- brain_celltrek_l5@assays$RNA@meta.features %>% data.frame %>% mutate(id=rownames(.))
nz_test <- apply(as.matrix(brain_celltrek_l5[['RNA']]@data), 1, function(x) mean(x!=0)*100)
hz_gene <- names(nz_test)[nz_test<20]
mt_gene <- grep('^Mt-', rownames(brain_celltrek_l5), value=T)
rp_gene <- grep('^Rpl|^Rps', rownames(brain_celltrek_l5), value=T)
vst_df <- vst_df %>% dplyr::filter(!(id %in% c(mt_gene, rp_gene, hz_gene))) %>% arrange(., -vst.variance.standardized)
feature_temp <- vst_df$id[1:2000]

We use scoexp to do the spatial-weighted gene co-expression analysis.

brain_celltrek_l5_scoexp_res_cc <- CellTrek::scoexp(celltrek_inp=brain_celltrek_l5, assay='RNA', approach='cc', gene_select = feature_temp, sigm=140, avg_cor_min=.4, zero_cutoff=3, min_gen=40, max_gen=400)
## Calculating spatial-weighted cross-correlation...
## Consensus clustering...
## Gene module detecting...
## 1  2  3  4  5  6  7  8

We can visualize the co-expression modules using heatmap.

brain_celltrek_l5_k <- rbind(data.frame(gene=c(brain_celltrek_l5_scoexp_res_cc$gs[[1]]), G='K1'), 
                           data.frame(gene=c(brain_celltrek_l5_scoexp_res_cc$gs[[2]]), G='K2')) %>% 
                           magrittr::set_rownames(.$gene) %>% dplyr::select(-1)
pheatmap::pheatmap(brain_celltrek_l5_scoexp_res_cc$wcor[rownames(brain_celltrek_l5_k), rownames(brain_celltrek_l5_k)], 
                   clustering_method='ward.D2', annotation_row=brain_celltrek_l5_k, show_rownames=F, show_colnames=F, 
                   treeheight_row=10, treeheight_col=10, annotation_legend = T, fontsize=8,
                   color=viridis(10), main='L5 IT spatial co-expression')

We identified two distinct modules. Based on our identified co-expression modules, we can calculated the module scores.

brain_celltrek_l5 <- AddModuleScore(brain_celltrek_l5, features=brain_celltrek_l5_scoexp_res_cc$gs, name='CC_', nbin=10, ctrl=50, seed=42)
## First we look into the coexpression module based on the scRNA-seq embedding
FeaturePlot(brain_celltrek_l5, grep('CC_', colnames(brain_celltrek_l5@meta.data), value=T))

Next we investigate the module scores at the spatial level.

SpatialFeaturePlot(brain_celltrek_l5, grep('CC_', colnames(brain_celltrek_l5@meta.data), value=T))

sessionInfo()
## R version 3.6.2 (2019-12-12)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Red Hat Enterprise Linux
## 
## Matrix products: default
## BLAS:   /usr/lib64/R/lib/libRblas.so
## LAPACK: /usr/lib64/R/lib/libRlapack.so
## 
## locale:
##  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
##  [3] 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   
##  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
##  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
##  [1] viridis_0.5.1       viridisLite_0.3.0   plotly_4.9.3       
##  [4] ggplot2_3.3.3       shiny_1.5.0         visNetwork_2.0.9   
##  [7] reshape2_1.4.4      hdf5r_1.3.0         SeuratData_0.2.1   
## [10] Seurat_3.1.4.9904   spatstat_1.63-2     rpart_4.1-15       
## [13] nlme_3.1-148        spatstat.data_2.1-0 pheatmap_1.0.12    
## [16] dbscan_1.1-6        magrittr_2.0.1      dplyr_1.0.5        
## 
## loaded via a namespace (and not attached):
##   [1] philentropy_0.4.0           Rtsne_0.15                 
##   [3] colorspace_2.0-0            deldir_0.1-25              
##   [5] ellipsis_0.3.1              ggridges_0.5.3             
##   [7] farver_2.1.0                leiden_0.3.3               
##   [9] listenv_0.8.0               ggrepel_0.9.1              
##  [11] bit64_4.0.2                 RSpectra_0.16-0            
##  [13] fansi_0.4.2                 codetools_0.2-16           
##  [15] splines_3.6.2               knitr_1.31                 
##  [17] polyclip_1.10-0             jsonlite_1.7.2             
##  [19] ica_1.0-2                   cluster_2.1.0              
##  [21] png_0.1-7                   uwot_0.1.8                 
##  [23] data.tree_1.0.0             sctransform_0.2.1          
##  [25] DiagrammeR_1.0.6.1          compiler_3.6.2             
##  [27] httr_1.4.2                  randomForestSRC_2.10.1     
##  [29] CellTrek_0.0.0.9000       assertthat_0.2.1           
##  [31] Matrix_1.2-18               fastmap_1.0.1              
##  [33] lazyeval_0.2.2              cli_2.0.2                  
##  [35] later_1.1.0.1               htmltools_0.5.1.1          
##  [37] tools_3.6.2                 rsvd_1.0.3                 
##  [39] igraph_1.2.6                gtable_0.3.0               
##  [41] glue_1.4.2                  RANN_2.6.1                 
##  [43] rappdirs_0.3.3              Rcpp_1.0.6                 
##  [45] Biobase_2.46.0              vctrs_0.3.7                
##  [47] debugme_1.1.0               ape_5.4                    
##  [49] lmtest_0.9-38               xfun_0.22                  
##  [51] stringr_1.4.0               globals_0.14.0             
##  [53] akima_0.6-2.1               mime_0.10                  
##  [55] miniUI_0.1.1.1              lifecycle_1.0.0            
##  [57] irlba_2.3.3                 goftest_1.2-2              
##  [59] future_1.21.0               packcircles_0.3.4          
##  [61] MASS_7.3-51.6               zoo_1.8-9                  
##  [63] scales_1.1.1                promises_1.2.0.1           
##  [65] spatstat.utils_2.1-0        parallel_3.6.2             
##  [67] RColorBrewer_1.1-2          yaml_2.2.1                 
##  [69] reticulate_1.16             pbapply_1.4-2              
##  [71] gridExtra_2.3               stringi_1.5.3              
##  [73] highr_0.8                   BiocGenerics_0.32.0        
##  [75] rlang_0.4.10                pkgconfig_2.0.3            
##  [77] evaluate_0.14               lattice_0.20-41            
##  [79] ROCR_1.0-11                 purrr_0.3.4                
##  [81] tensor_1.5                  labeling_0.4.2             
##  [83] patchwork_1.0.1             htmlwidgets_1.5.3          
##  [85] cowplot_1.0.0               bit_4.0.4                  
##  [87] tidyselect_1.1.0            parallelly_1.24.0          
##  [89] RcppAnnoy_0.0.18            plyr_1.8.6                 
##  [91] R6_2.5.0                    generics_0.1.0             
##  [93] DBI_1.1.0                   withr_2.4.1                
##  [95] pillar_1.5.1                mgcv_1.8-31                
##  [97] fitdistrplus_1.1-1          sp_1.4-5                   
##  [99] survival_3.2-3              abind_1.4-5                
## [101] tibble_3.1.0                future.apply_1.7.0         
## [103] tsne_0.1-3                  crayon_1.4.1               
## [105] KernSmooth_2.23-17          utf8_1.2.1                 
## [107] rmarkdown_2.3               grid_3.6.2                 
## [109] data.table_1.14.0           blob_1.2.1                 
## [111] ConsensusClusterPlus_1.50.0 digest_0.6.27              
## [113] xtable_1.8-4                tidyr_1.1.3                
## [115] httpuv_1.5.5                munsell_0.5.0

celltrek's People

Contributors

minbio avatar nnavinlab avatar wanderum avatar williamhsy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

celltrek's Issues

Error in rownames(st_data[[st_assay]]@data) : no slot of name "data" for this object of class "Assay5", Possible Seurat v5.0 error

Hiya, got a problem here

traint_result <- CellTrek::traint(st_data = ST,
                                  sc_data = SC,
                                  sc_assay = 'RNA',
                                  norm = 'SCT',
                                  cell_names = 'subclass')
Finding transfer anchors... 
No variable features found for object2 in the object.list. Running FindVariableFeatures ...
Calculating gene variances
0%   10   20   30   40   50   60   70   80   90   100%
[----|----|----|----|----|----|----|----|----|----|
**************************************************|
Calculating feature variances of standardized and clipped values
0%   10   20   30   40   50   60   70   80   90   100%
[----|----|----|----|----|----|----|----|----|----|
**************************************************|
Error in rownames(st_data[[st_assay]]@data) : 
  no slot of name "data" for this object of class "Assay5"

I think the error is caused by Seurat v5 object's format change. This is the format of my object, which uses Seurat v5
image
The count and data are wrapped in layer object(?)/variable(?). I wonder if someone has a tool to downgrade Seurat object, since my preprocessing code didn't work on the latest v4...

p.s: Tried to just copy and paste the count and data outside the layer object(?)/variable(?), didn't work...

sessionInfo()

R version 4.3.2 (2023-10-31)
Platform: aarch64-unknown-linux-gnu (64-bit)
Running under: Ubuntu 22.04.3 LTS

Matrix products: default
BLAS:   /usr/lib/aarch64-linux-gnu/openblas-pthread/libblas.so.3 
LAPACK: /usr/lib/aarch64-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: Asia/Jakarta
tzcode source: system (glibc)

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

other attached packages:
[1] ConsensusClusterPlus_1.66.0 viridis_0.6.4               viridisLite_0.4.2           Seurat_5.0.1               
[5] SeuratObject_5.0.1          sp_2.1-2                    dplyr_1.1.4                 CellTrek_0.0.94            

loaded via a namespace (and not attached):
  [1] RColorBrewer_1.1-3     rstudioapi_0.15.0      jsonlite_1.8.8         magrittr_2.0.3        
  [5] spatstat.utils_3.0-4   vctrs_0.6.5            ROCR_1.0-11            spatstat.explore_3.2-5
  [9] rstatix_0.7.2          htmltools_0.5.7        dynamicTreeCut_1.63-1  broom_1.0.5           
 [13] sctransform_0.4.1      parallelly_1.36.0      KernSmooth_2.23-22     htmlwidgets_1.6.4     
 [17] ica_1.0-3              plyr_1.8.9             plotly_4.10.3          zoo_1.8-12            
 [21] igraph_1.6.0           mime_0.12              lifecycle_1.0.4        pkgconfig_2.0.3       
 [25] Matrix_1.6-4           R6_2.5.1               fastmap_1.1.1          magic_1.6-1           
 [29] fitdistrplus_1.1-11    future_1.33.1          shiny_1.8.0            digest_0.6.33         
 [33] colorspace_2.1-0       patchwork_1.1.3        tensor_1.5             RSpectra_0.16-1       
 [37] irlba_2.3.5.1          akima_0.6-3.4          ggpubr_0.6.0           philentropy_0.8.0     
 [41] progressr_0.14.0       fansi_1.0.6            spatstat.sparse_3.0-3  httr_1.4.7            
 [45] polyclip_1.10-6        abind_1.4-5            compiler_4.3.2         backports_1.4.1       
 [49] carData_3.0-5          fastDummies_1.7.3      ggsignif_0.6.4         MASS_7.3-60           
 [53] tools_4.3.2            lmtest_0.9-40          httpuv_1.6.13          future.apply_1.11.1   
 [57] goftest_1.2-3          glue_1.6.2             dbscan_1.1-12          DiagrammeR_1.0.10     
 [61] nlme_3.1-163           promises_1.2.1         grid_4.3.2             Rtsne_0.17            
 [65] cluster_2.1.4          reshape2_1.4.4         generics_0.1.3         gtable_0.3.4          
 [69] spatstat.data_3.0-3    tidyr_1.3.0            data.table_1.14.10     car_3.1-2             
 [73] utf8_1.2.4             BiocGenerics_0.48.1    spatstat.geom_3.2-7    RcppAnnoy_0.0.21      
 [77] ggrepel_0.9.4          RANN_2.6.1             pillar_1.9.0           stringr_1.5.1         
 [81] spam_2.10-0            RcppHNSW_0.5.0         later_1.3.2            splines_4.3.2         
 [85] lattice_0.22-5         survival_3.5-7         deldir_2.0-2           tidyselect_1.2.0      
 [89] miniUI_0.1.1.1         pbapply_1.7-2          gridExtra_2.3          scattermore_1.2       
 [93] Biobase_2.62.0         matrixStats_1.2.0      visNetwork_2.1.2       stringi_1.8.3         
 [97] lazyeval_0.2.2         codetools_0.2-19       data.tree_1.1.0        tibble_3.2.1          
[101] packcircles_0.3.6      cli_3.6.2              uwot_0.1.16            geometry_0.4.7        
[105] xtable_1.8-4           reticulate_1.34.0      randomForestSRC_3.2.3  munsell_0.5.0         
[109] Rcpp_1.0.11            globals_0.16.2         spatstat.random_3.2-2  png_0.1-8             
[113] fastcluster_1.2.3      parallel_4.3.2         ellipsis_0.3.2         ggplot2_3.4.4         
[117] dotCall64_1.1-1        listenv_0.9.0          scales_1.3.0           ggridges_0.5.5        
[121] leiden_0.4.3.1         purrr_1.0.2            rlang_1.1.2            cowplot_1.1.2

Question about Supplementary Figure 7e

Hello CellTrek,

Congratulations for this tools, which seems impressive!
I tried understanding supp.fig-7e,
You've identified the three tumor subclones locations, and five clusters by unsupervised learning, right?
Then, you validate results by G.E. based spearman correlation analysis.
How to create matrix based on clustering? By mean gene expression ? and how to select gene ?
Can you please post the code or pseudo code to this analysis?

Thanks in advance,
Chuang

Publicly available Single cell data with ST data

As a researcher using spatial transcriptomics data but without my own single-cell data, I find CellTrek to be a wonderful tool for deconstructing microenvironments. I am interested in incorporating publicly available single-cell RNA sequencing (scRNA-seq) data into my CellTrek analysis to gain additional insights. Can you please elaborate on the recommended approaches for integrating publicly available scRNA-seq data with CellTrek when single-cell data is not available? Thank you!
Best,
Ateeq Khaliq

Simualtion dataset

Hi Team,

Congratulation on the amazing work. It seems simulating different conditions is a critical portion of the paper. However, I could not find function or method to repeat those simulation. Is it possible to share the code for simulating the datasets from the paper. I am especially referring to Supp Fig 4

image

Error in intI(j, n = x@Dim[2], dn[[2]], give.dn = FALSE) : invalid character indexing

Thanks for a great package!

I previously was able to make the algorithm run with the LogNormalize method. I am now using a different single cell dataset that has been SCTransform-ed and am getting the following error. I did check the colnames and rownames of the liver_sc@assays$SCT and they are all unique. Any help is appreciated!

traint <- CellTrek::traint(st_data=spatial_6a,
sc_data=liver_sc,
sc_assay='SCT',
st_assay='SCT',
norm = 'SCT',
cell_names='seurat_clusters',
recompute.residuals = FALSE)

liver_celltrek <- CellTrek::celltrek(
st_sc_int=traint,
int_assay='traint',
sc_data=liver_sc,
sc_assay = 'SCT',
reduction='pca',
intp=T,
intp_pnt=5000,
intp_lin=F,
nPCs=30,
ntree=1000,
dist_thresh=0.55,
top_spot=5,
spot_n=5,
repel_r=20,
repel_iter=20,
keep_model=T)$seurat_clusters

Joining, by = c("Var1", "Var2", "value", "val_rsc", "Var1_type", "Var2_type")Spatial Charting SC data...
Repelling points...
Creating Seurat Object...
sc data...Error in intI(j, n = x@Dim[2], dn[[2]], give.dn = FALSE) :
invalid character indexing

"Celltrek"_Simualtion dataset

Dear Professor:
Hello! First of all, congratulations for doing such a good job. We are very interested in your training using simulated data, but did not find a relevant method to create simulated data. Could you provide the source code and data for constructing the simulated data in your thesis, thank you very much! My e-mail address is: [email protected]

Failed to visualize the ST data, error returns "Error in SpatialPlot(object = object, group.by = group.by, images = images, : Could not find any spatial image information"

After I successfully load rds file usingh_st <- readRDS("cellbin.gef.rds") and rename it using h_st <- RenameCells(h_st, new.names=make.names(Cells(h_st))), with instruction h_st in the terminal Radian shows as follow:

An object of class Seurat
26758 features across 79270 samples within 1 assay
Active assay: RNA (26758 features, 0 variable features)
2 layers present: counts, data
1 dimensional reduction calculated: spatial

There is something weird when I try to run SpatialDimPlot(h_st).
The error says:

Error in SpatialPlot(object = object, group.by = group.by, images = images, :
Could not find any spatial image information

And the error also occurs when I using h_st <- readRDS("tissue.gef.rds") with same terminal returned info


Additional info: The tissuebin and cellbin files are both converted by follow program(h5ad2rdsutil.R):

library(sceasy)

args = commandArgs(trailingOnly = TRUE)
source_file = args[1]
samename_aim_file = args[2]

sceasy::convertFormat(source_file,from="anndata",to="seurat",outFile=samename_aim_file)

I ran this in terminal by Rscript h5ad2rdsutil.R cellbin.gef.h5ad cellbin.gef.rds and Rscript h5ad2rdsutil.R tissue.gef.h5ad tissue.gef.rds

If there is a need for how h5ad files are generated, here is the program(readGEFutil.py) with stereopy0.13.0b1:

import sys
import stereo as st
import re
import os

assert len(sys.argv) == 4
_,mode,gef_file_path,aim_path = sys.argv
assert mode in ['tissuebin','cellbin']

if mode == 'tissuebin' and re.search(r"tissue.gef$",os.path.basename(gef_file_path)) is not None:
data = st.io.read_gef(file_path=gef_file_path,bin_size=100)
data.tl.raw_checkpoint()
adata=st.io.stereo_to_anndata(data,flavor='seurat')
adata.write_h5ad(aim_path+'/'+os.path.basename(gef_file_path)+'.h5ad')

if mode == 'cellbin' and re.search(r"cellbin.gef$",os.path.basename(gef_file_path)) is not None:
data = st.io.read_gef(file_path=gef_file_path,bin_type='cell_bins')
data.tl.raw_checkpoint()
adata=st.io.stereo_to_anndata(data,flavor='seurat')
adata.write_h5ad(aim_path+'/'+os.path.basename(gef_file_path)+'.h5ad')

I ran this in terminal by python readGEFutil.py cellbin cellbin.gef aim_path/ and python readGEFutil.py tissue.gef aim_path/

selection of Edge cut-off threshold for spatial colocalisation of cells

Hi CellTrek team,

Thanks for this tool which is really useful to test the hypothesis on my spatial data. I would like to know, how to decide which cut-off makes sense for me to look at the spatial colocalization of cells. Please elaborate on this?

For instance, if cell A is interacting with cell B at edge cut-off 0 but not at edge cut-off 0.2? then how to interpret that?

Best Regards,
Pratap
Senior Bioinformatics Specialist,
NCCS,
Singapore

Coembedding shows batch effect

I obtained not very expected results from celltrek (some cell types are mapped randomly) and it made me wonder if something went wrong downstream. My main suspect is coembedding where data types are very well separated:
image
I followed the tutorial in the readme and did not apply any extra filtering/gene selection/preprocessing steps. Could you suggest what might be the issue?

Disorder coordiantes for 10x visium data.

Hi all,

I perform CellTrek on my unpublised 10x visium data with default parameters, but the predicted coordinate for each single cell couldn't match to the HE picture, here is the shiny plot.

image

Best,
Ran

Dealing with spatial data with merged samples

Hello,
I try to use CellTrek to merge my spatial and single-cell data. However, I had this error when running the traint ():

Cannot add more or fewer cell meta.data information without values being named with cell names

I found out that it is caused by st_data$coord_x <- st_data@images[[1]]@coordinates[, coord_xy[1]].

The spatial data is merged from two different samples. Therefore, the total spot number in the meta.data is larger if only images[[1]] coordinates are loaded.

The two spatial samples are replicates so I don't want to remove it. Is there a way I can load the merged st object for this analysis?

Thanks,
Ziliang

Minimum feature overlap between scRNAseq and spatial method?

Hello!

I was wondering whether CellTrek could also be used in combination with other spatial approaches, for example multiplexed immunofluorescence (instead of RNA measure protein level and in a lower throughput). Have you tried? What would you recommend as the minimum number of features overlap between the 2 methods (i.e. scRNAseq and spatial)?

Thanks!

Question about "celltrek_vis" results

Hi,

Thank you for providing this great tool for ST research!
While when I tried to run CellTrek on own samples (NOT 10X platform), I met a problem. Which is in the step of Celltrek _vis, the plot is not same shape as original ST seurat object. It is a Oval shape (as pitcture 1).
The original ST spatial plot is also attached below as pitcture 2.

The original ST seurat object does not store a coresponding real image, its @images is like below( pitcture 3).
Could you give a hint on how to fix this?

Thanks in advance!

Best,
pitcture 1:
newplot
pitcture 2:
original_ST_plot
pitcture 3:
Snipaste_2022-03-28_14-48-41

should I subset the scRNA data or the ST data?

Hello,

I have a scRNA-seq data with more than 20K cells with 19 celltypes, and ST data with 23k spots. Now I want to detect all the celltypes distribution on the ST with celltrek function. But this process takes too much computing memory, about 200G, so I want to subset the data and analyze separately. I was wondering should I subset the scRNA data and map to the ST data, then merge the results together, or subset the ST data?

Best regards,
thanks!

Error: invalid character indexing

Hi,
I am running celltrek with default settings, but I am encountering the following error, I am not able to debug, please let me know if this can be resolved. Thanks a lot

`s21_h8_celltrek <- CellTrek::celltrek(st_sc_int=ct_train, int_assay='traint', sc_data=sc, sc_assay = 'RNA',
                                   reduction='pca', intp=T, intp_pnt=5000, intp_lin=F, nPCs=30, ntree=1000,
                                   dist_thresh=0.55, top_spot=5, spot_n=5, repel_r=20, repel_iter=20, keep_model=T)$celltrek`

`09:18:32 Optimization finished
Rasterizing points since number of points exceeds 100,000.
To disable this behavior set `raster=FALSE`
Joining, by = c("Var1", "Var2", "value", "val_rsc", "Var1_type", "Var2_type")
Error in intI(j, n = x@Dim[2], dn[[2]], give.dn = FALSE) :
  invalid character indexing
Calls: <Anonymous> ... callGeneric -> eval -> eval -> [ -> [ -> subCsp_cols -> intI
Execution halted.

Regards,
AMK

Error in CellTrek::celltrek step

Hi,

I encountered the following error at the CellTrek::celltrek step following your tutorial.

> ## Chart single cells to their spatial locations
> visium_scRNAseq_celltrek <- CellTrek::celltrek(st_sc_int=visium_traint, int_assay='traint', sc_data=s_df, sc_assay = 'RNA', reduction='pca', intp=T, intp_pnt=5000, intp_lin=F, nPCs=30, ntree=1000,  dist_thresh=0.55, top_spot=5, spot_n=5, repel_r=20, repel_iter=20, keep_model=F)
Distance between spots is: 216 
Interpolating...
Random Forest training... 
Random Forest prediction...  
Making distance matrix... 
Making graph... 
Pruning graph...
Joining, by = c("Var1", "Var2", "value", "val_rsc", "Var1_type", "Var2_type")
Spatial Charting SC data...
Repelling points...
Creating Seurat Object... 
sc data...Error in intI(j, n = x@Dim[2], dn[[2]], give.dn = FALSE) : 
  invalid character indexing

Any ideas how to solve it? Thank you.

General Questions

Hello!

Thanks a lot for sharing this fantastic package and huge congrats on your nature biotech publication! While we are trying to implement CellTrek to our data, we have some questions to understand the steps behind wrapped functions:

  1. You mentioned akima package has been used for interpolation to augment spatial resolution. We are confused about what exactly the interpolation step does here and what "augment spatial resolution" means.
  2. Even though we get the general idea that the RF distance matrix could be a # of cells * # of pixels matrix, could you please elaborate/give an example of how RF distance is calculated? We are a little lost when you mention "# of edges to the immediately shared ancestor on the tree" and "# of edges to the tree root". In particular, is your description based on a cell node or a pixel node on the tree? Is there any averaging among 1000 trees?
  3. KL-divergence has been used repeatedly as a benchmarking value. Could you please explain a bit how you define the value under this charting context?

Thank you in advance for your help!

Best,
CY

Customized Plot

Dear developers,
It's great that CellTrek provide a interactive way to visulized the results.
I am wondering whether it's possible to plot by ourselves and then we can optimize the figure like the color of dots.
Is it possible to map the cells back to the spots from ST and calculate the ratio of cells in spots?

Best regards
Song

Error while running CellTrek:celltrek function

Hi,
while running the cell trek package, especially at the CellTrek::celltrek function, I'm getting the following error (shown in the [screenshot)] and attached my R script screenshot too along with SessionInfo. It would be a great help to know how to fix this.

Screenshot 2022-10-04 at 1 44 28 PM

Screenshot 2022-10-04 at 2 06 52 PM

Best Regards,
Pratap,
Bioinformatician,
NCCS,
Singapore

Utilizing CellChat after CellTrek

Hi, Thank you for such a great tool! I noticed in the paper you described utilizing CellChat after CellTrek to incorporate the spatial information into CellChat. Is there code to go along with this example?

ERROR

你好 我在用示例数据进行的时候出现了以下错误
brain_traint <- CellTrek::traint(st_data=brain_st_cortex, sc_data=brain_sc, sc_assay='RNA', cell_names='cell_type')
Finding transfer anchors...
Using 2000 features for integration...
Running CCA
Merging objects
Finding neighborhoods
Finding anchors
Found 3730 anchors
Data transfering...
Finding integration vectors
Finding integration vector weights
0% 10 20 30 40 50 60 70 80 90 100%
[----|----|----|----|----|----|----|----|----|----|
**************************************************|
Transfering 2000 features onto reference data
Creating new Seurat object...
Warning: Data is of class data.frame. Coercing to dgCMatrix.
Error in CellTrek::traint(st_data = brain_st_cortex, sc_data = brain_sc, :
no slot of name "counts" for this object of class "Assay5"
In addition: Warning messages:
1: Command ScaleData.RNA changing from SeuratCommand to SeuratCommand
2: Adding image data that isn't associated with any assays

请问是某些R包的版本问题吗

The error of CellTrek

Hi, thank you for your code sharing.
When I used the CellTrek, I found that there are some errors in the calculation of coordinates.
coord_x <- row_x[1] + (spot_dis/2)*sin(theta)*alpha
coord_y <- row_x[2] + (spot_dis/2)*cos(theta)*alpha
I think it may be
coord_x <- row_x[1] + (spot_dis/2)*cos(theta)*alpha
coord_y <- row_x[2] + (spot_dis/2)*sin(theta)*alpha
Best wishes.

Error: package or namespace load failed for ‘CellTrek’

Error: package or namespace load failed for ‘CellTrek’: (converted from warning) replacing previous import ‘data.table::last’ by ‘dplyr::last’ when loading ‘CellTrek’

I try to remove cellltrek and install it again,but the error remains.Then I remove data.table and dplyr ,nothing changes. I dont know how to fix it,could you help me,please?

Dimension reduce warning in function celltrek

Hello,
I have a question about dimension in 'celltrek' function.

I am running celltrek in remote server (school server) and using same nPC as in tutorial (30),
but it keeps giving me a warning message of 'please reduce dimesion if possible' and eventually kills itself.

My sc seurat object is kind of large (50GB with 155312 cells, 33538 features)., will this be the reason?
Also, I want to know if this program is heavier than seurat and cloupe, since I experienced no problem using the same data.

Thank you!

Errors in CellTrek::traint on example data from README

I'm attempting to get the example from the README working, but am encountering an error on the CellTrek::traint step during FindTransferAnchors:

> brain_traint <- CellTrek::traint(st_data=brain_st_cortex, sc_data=brain_sc, sc_assay='RNA', cell_names='cell_type')
Finding transfer anchors... 
Using 2000 features for integration... 
Running CCA
Merging objects
Error in dimnames(x) <- dn : 
  length of 'dimnames' [1] not equal to array extent
In addition: Warning messages:
1: Command ScaleData.RNA changing from SeuratCommand to SeuratCommand 
2: Command ScaleData.Spatial changing from SeuratCommand to SeuratCommand 
3: In RunCCA.Seurat(object1 = reference, object2 = query, features = features,  :
  Running CCA on different assays

Downgrading to Seurat 3.1.1 (corresponding to Version(brain_sc)) gets us past this step but encounters a new error slightly later in the execution of FindTransferAnchors. I've included that error at the end of this issue in case it is useful.


Debugging info (Seurat 4.4.0)

Traceback

> traceback()
5: `rownames<-`(x = `*tmp*`, value = Cells(x = combined.object))
4: RunCCA.Seurat(object1 = reference, object2 = query, features = features, 
       num.cc = max(dims), renormalize = FALSE, rescale = FALSE, 
       verbose = verbose)
3: RunCCA(object1 = reference, object2 = query, features = features, 
       num.cc = max(dims), renormalize = FALSE, rescale = FALSE, 
       verbose = verbose)
2: Seurat::FindTransferAnchors(reference = sc_data, query = st_data, 
       reference.assay = sc_assay, query.assay = st_assay, normalization.method = norm, 
       features = sc_st_features, reduction = "cca", ...)
1: CellTrek::traint(st_data = brain_st_cortex, sc_data = brain_sc, 
       sc_assay = "RNA", cell_names = "cell_type")

Session Info

> sessionInfo()
R version 4.3.0 (2023-04-21)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Ventura 13.3.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.3-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.11.0

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: Europe/London
tzcode source: internal

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

other attached packages:
[1] viridis_0.6.4      viridisLite_0.4.2  dplyr_1.1.3        SeuratObject_5.0.0
[5] Seurat_4.4.0       CellTrek_0.0.94   

loaded via a namespace (and not attached):
  [1] RColorBrewer_1.1-3     rstudioapi_0.15.0      jsonlite_1.8.7        
  [4] magrittr_2.0.3         spatstat.utils_3.0-3   farver_2.1.1          
  [7] vctrs_0.6.3            ROCR_1.0-11            spatstat.explore_3.2-3
 [10] rstatix_0.7.2          htmltools_0.5.6        dynamicTreeCut_1.63-1 
 [13] broom_1.0.5            sctransform_0.4.0      parallelly_1.36.0     
 [16] KernSmooth_2.23-20     htmlwidgets_1.6.2      ica_1.0-3             
 [19] plyr_1.8.8             plotly_4.10.2          zoo_1.8-12            
 [22] igraph_1.5.1           mime_0.12              lifecycle_1.0.3       
 [25] pkgconfig_2.0.3        Matrix_1.6-1.1         R6_2.5.1              
 [28] fastmap_1.1.1          magic_1.6-1            fitdistrplus_1.1-11   
 [31] future_1.33.0          shiny_1.7.5            digest_0.6.33         
 [34] colorspace_2.1-0       patchwork_1.1.3        tensor_1.5            
 [37] irlba_2.3.5.1          akima_0.6-3.4          ggpubr_0.6.0          
 [40] labeling_0.4.3         philentropy_0.7.0      progressr_0.14.0      
 [43] fansi_1.0.4            spatstat.sparse_3.0-2  httr_1.4.7            
 [46] polyclip_1.10-4        abind_1.4-5            compiler_4.3.0        
 [49] withr_2.5.0            backports_1.4.1        carData_3.0-5         
 [52] ggsignif_0.6.4         MASS_7.3-58.4          tools_4.3.0           
 [55] lmtest_0.9-40          httpuv_1.6.11          future.apply_1.11.0   
 [58] goftest_1.2-3          glue_1.6.2             dbscan_1.1-11         
 [61] DiagrammeR_1.0.10      nlme_3.1-162           promises_1.2.1        
 [64] grid_4.3.0             Rtsne_0.16             cluster_2.1.4         
 [67] reshape2_1.4.4         generics_0.1.3         gtable_0.3.4          
 [70] spatstat.data_3.0-1    tidyr_1.3.0            data.table_1.14.8     
 [73] sp_2.0-0               car_3.1-2              utf8_1.2.3            
 [76] spatstat.geom_3.2-5    RcppAnnoy_0.0.21       ggrepel_0.9.3         
 [79] RANN_2.6.1             pillar_1.9.0           stringr_1.5.0         
 [82] spam_2.10-0            later_1.3.1            splines_4.3.0         
 [85] lattice_0.21-8         survival_3.5-5         deldir_1.0-9          
 [88] tidyselect_1.2.0       miniUI_0.1.1.1         pbapply_1.7-2         
 [91] gridExtra_2.3          scattermore_1.2        matrixStats_1.0.0     
 [94] visNetwork_2.1.2       stringi_1.7.12         lazyeval_0.2.2        
 [97] codetools_0.2-19       data.tree_1.0.0        tibble_3.2.1          
[100] packcircles_0.3.6      cli_3.6.1              uwot_0.1.16           
[103] xtable_1.8-4           geometry_0.4.7         reticulate_1.32.0     
[106] randomForestSRC_3.2.2  munsell_0.5.0          Rcpp_1.0.11           
[109] globals_0.16.2         spatstat.random_3.1-6  png_0.1-8             
[112] fastcluster_1.2.3      parallel_4.3.0         ellipsis_0.3.2        
[115] ggplot2_3.4.3          dotCall64_1.1-0        listenv_0.9.0         
[118] scales_1.2.1           ggridges_0.5.4         leiden_0.4.3          
[121] purrr_1.0.2            rlang_1.1.1            cowplot_1.1.1    

Debugging info (Seurat 3.1.1)

Error

> brain_traint <- CellTrek::traint(st_data=brain_st_cortex, sc_data=brain_sc, sc_assay='RNA', cell_names='cell_type')
Finding transfer anchors... 
Using 2000 features for integration... 
Running CCA
Merging objects
Finding neighborhoods
Finding anchors
Error in !(cells1 %in% colnames(object)) || !(cells2 %in% colnames(object)) : 
  'length = 5860' in coercion to 'logical(1)'
In addition: Warning message:
In RunCCA.Seurat(object1 = reference, object2 = query, features = features,  :
  Running CCA on different assays

Traceback

> traceback()
4: FindAnchorPairs(object = object.pair, integration.name = "integrated", 
       k.anchor = k.anchor, verbose = verbose)
3: FindAnchors(object.pair = combined.ob, assay = c(reference.assay, 
       query.assay), slot = slot, cells1 = colnames(x = reference), 
       cells2 = colnames(x = query), reduction = reduction, internal.neighbors = list(NULL, 
           NULL), dims = dims, k.anchor = k.anchor, k.filter = k.filter, 
       k.score = k.score, max.features = max.features, nn.method = nn.method, 
       eps = eps, projected = projected, verbose = verbose)
2: Seurat::FindTransferAnchors(reference = sc_data, query = st_data, 
       reference.assay = sc_assay, query.assay = st_assay, normalization.method = norm, 
       features = sc_st_features, reduction = "cca", ...)
1: CellTrek::traint(st_data = brain_st_cortex, sc_data = brain_sc, 
       sc_assay = "RNA", cell_names = "cell_type")

Session Info

> sessionInfo()
R version 4.3.0 (2023-04-21)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Ventura 13.3.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.3-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.11.0

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: Europe/London
tzcode source: internal

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

other attached packages:
[1] CellTrek_0.0.94 Seurat_3.1.1   

loaded via a namespace (and not attached):
  [1] mathjaxr_1.6-0        RColorBrewer_1.1-3    rstudioapi_0.15.0    
  [4] jsonlite_1.8.7        magrittr_2.0.3        TH.data_1.1-2        
  [7] vctrs_0.6.3           multtest_2.8.0        ROCR_1.0-11          
 [10] rstatix_0.7.2         htmltools_0.5.6       dynamicTreeCut_1.63-1
 [13] plotrix_3.8-2         broom_1.0.5           sctransform_0.4.0    
 [16] parallelly_1.36.0     KernSmooth_2.23-20    htmlwidgets_1.6.2    
 [19] ica_1.0-3             plyr_1.8.8            sandwich_3.0-2       
 [22] plotly_4.10.2         zoo_1.8-12            igraph_1.5.1         
 [25] mime_0.12             lifecycle_1.0.3       pkgconfig_2.0.3      
 [28] rsvd_1.0.5            Matrix_1.6-1.1        R6_2.5.1             
 [31] fastmap_1.1.1         magic_1.6-1           rbibutils_2.2.16     
 [34] fitdistrplus_1.1-11   future_1.33.0         shiny_1.7.5          
 [37] digest_0.6.33         numDeriv_2016.8-1.1   colorspace_2.1-0     
 [40] irlba_2.3.5.1         akima_0.6-3.4         ggpubr_0.6.0         
 [43] philentropy_0.7.0     fansi_1.0.4           httr_1.4.7           
 [46] TFisher_0.2.0         abind_1.4-5           compiler_4.3.0       
 [49] mutoss_0.1-13         backports_1.4.1       carData_3.0-5        
 [52] R.utils_2.12.2        ggsignif_0.6.4        MASS_7.3-58.4        
 [55] tsne_0.1-3.1          tools_4.3.0           lmtest_0.9-40        
 [58] ape_5.7-1             metap_1.9             httpuv_1.6.11        
 [61] future.apply_1.11.0   qqconf_1.3.2          R.oo_1.25.0          
 [64] glue_1.6.2            dbscan_1.1-11         DiagrammeR_1.0.10    
 [67] promises_1.2.1        nlme_3.1-162          grid_4.3.0           
 [70] Rtsne_0.16            cluster_2.1.4         reshape2_1.4.4       
 [73] generics_0.1.3        gtable_0.3.4          R.methodsS3_1.8.2    
 [76] tidyr_1.3.0           sn_2.1.1              data.table_1.14.8    
 [79] sp_2.0-0              car_3.1-2             utf8_1.2.3           
 [82] BiocGenerics_0.48.0   RcppAnnoy_0.0.21      ggrepel_0.9.3        
 [85] RANN_2.6.1            pillar_1.9.0          stringr_1.5.0        
 [88] later_1.3.1           splines_4.3.0         dplyr_1.1.3          
 [91] lattice_0.21-8        survival_3.5-5        tidyselect_1.2.0     
 [94] pbapply_1.7-2         gridExtra_2.3         stats4_4.3.0         
 [97] Biobase_2.62.0        matrixStats_1.0.0     visNetwork_2.1.2     
[100] stringi_1.7.12        lazyeval_0.2.2        codetools_0.2-19     
[103] data.tree_1.0.0       tibble_3.2.1          packcircles_0.3.6    
[106] cli_3.6.1             uwot_0.1.16           geometry_0.4.7       
[109] xtable_1.8-4          reticulate_1.32.0     randomForestSRC_3.2.2
[112] Rdpack_2.5            munsell_0.5.0         Rcpp_1.0.11          
[115] globals_0.16.2        png_0.1-8             fastcluster_1.2.3    
[118] parallel_4.3.0        ellipsis_0.3.2        ggplot2_3.4.3        
[121] listenv_0.9.0         viridisLite_0.4.2     mvtnorm_1.2-3        
[124] SDMTools_1.1-221      scales_1.2.1          ggridges_0.5.4       
[127] leiden_0.4.3          purrr_1.0.2           rlang_1.1.1          
[130] cowplot_1.1.1         multcomp_1.4-25       mnormt_2.1.1  

celltrek_vis Error

I don't know where the problem lies,The Error info is as follows:

CellTrek::celltrek_vis([email protected] %>%
dplyr::select(coord_x, coord_y, cell_type:id_new),
brain_celltrek@images$anterior1@image,
brain_celltrek@images$[email protected]$lowres)

Listening on http://127.0.0.1:7705
Error in utils::browseURL(appUrl) :
'browser' must be a non-empty character string

Request for cell type annotation of mouse kidney and DCIS1 datasets

I am interested in mouse kidney and DCIS1 datasets to replicate the results of the article . However, I require the cell type annotation for these datasets to better understand and analyze the results.

Is it possible to provide the cell type annotation for both of these datasets so that I can further explore the data and use it for my research?

Thank you for your assistance!

Some cells are missing from output

I am trying to use CellTrek to map my single-cell RNA-seq data onto Visium ST coordinates. I have a dataset of 500k+ cells for my single-cell RNA-seq.

I ran the traint function with default arguments, and the co-embedding looks pretty reasonable. However, when I tried to run celltrek with the default arguments, I noticed that only a fraction of the cells in my single-cell dataset were mapped. I also tried downsampling my scRNA data to only map a portion with celltrek, but still there are a lot of cells missing from the output of celltrek. I am not sure why this is happening, but I am wondering what settings I should use in the celltrek function if I want to return coordinates for every input cell? Alternatively, if there are cells that have a low mapping to the ST dataset, and that's why they aren't showing up in the output, are there any metrics that celltrek returns to check the prediction condidence? Let me know if you need any more info to answer my question.

Thanks,
Sam

clarification on overall method

Hi,

thanks for a great package! I wanted to clarify your overall method. The resulting image in the shiny app shows one cell per spot (i think), and I wanted to clarify how that specific cell was chosen when in reality there are multiple cells per spot.

Does CellTrek map each cell to a specific spot so that each spot has multiple cells (and then choose one for the shiny app) or does it choose the best cell for each spot and leave many of the single cells without a spatial location?

Any clarification is appreciated!

Using Celltrek on non-matching data ST and SC data.

Hello Celltrek devs,

I would like to map cells from a single-cell dataset which only includes one cell type to a spatial transcriptomics dataset which includes multiple cell types. Is this possible, and if so, is there anything I should keep in mind while doing so?

If this is not possible, are there any work-arounds, such as merging the single cell dataset with a reference dataset which includes additional cell types I would expect?

sincerely,
Dillon

Visualization and error in celltrek_vis

Hi,

Congratulations on such a great tool! I am hoping you can help me figure out the following issues I've encountered:

  1. In celltrek_vis, I get the following error in the Shiny app pop-up: "
    Error: no applicable method for 'as.raster' applied to an object of class "c('VisiumV1', 'SpatialImage')"
  2. Without celltrek_vis working, I visualized the cells on the Visium embedding as follows:
    DimPlot(brain_celltrek, reduction='celltrek_raw', group.by = "CellType")
    But this doesn't give me the H&E image. Do you have any suggestions on how to get this to work? Or No. 1 above? I think either one will help solve the issue.
  3. Lastly, when calculating the spatial weighted cross-correlation, I noticed that the CC scores are too big and are not positioned correctly to the HE image. Do you have any suggestions on how to resolve this?

Thank you very much for your help!

celltrek_vis error

Hi,

Congratulations on such a great tool! I am hoping you can help me figure out the following issues I've encountered:

  1. When drawing with the celltrek_vis function, the picture cannot be displayed without any error. Using the test data you provided was also unsuccessful. The scoloc_ vis function can succeed!
    Uploading e5346fbe2ee714733669fd4b69ba9f7.png…
    Uploading f831a8a11a23ea8db948361c9d237c9.png…

Assigning all single cells

Dear CellTrek Team

I wonder whether there is a way to force assign all single cells to a spatial location? I tried to change dist_thresh=0.55 to dist_thresh=2, but still didn't get all my single cells with at least one position assigned. May I ask 2hat would be a setting so that all cells could be assigned? Thank you!

keep raw data in celltrek object

I noticed that in the celltrek object that is created in the main celltrek function, only the @data matrix is kept. Is it possible to also transfer the @counts and @scale.data? I noticed these slots were empty in my final object (liver_celltrek_6b), but present in my original single nucleus seurat object (liver_sc_6b).

Thank you!
Kate

liver_celltrek_6b <- CellTrek::celltrek( st_sc_int=traint_6b, int_assay='traint', sc_data=liver_sc_6b, sc_assay = 'SCT', reduction='pca', intp=T, intp_pnt=5000, intp_lin=F, nPCs=30, ntree=1000, dist_thresh=0.55, top_spot=5, spot_n=5, repel_r=20, repel_iter=20, keep_model=T)$celltrek

image

Installation problem

There are lot of issues in the installation. For example, in the DESCRIPTION file, "dynamicTreeCut" is needed. However in your provided sessionInfo no any information of dynamicTreeCut is shown. Thus, we can not no the matched version of these dependencies. The recommended install process doesn't work anymore. Since the R version is pretty old (3.6.2 is used in your file.), a detailed dependencies information may be helpful.

Celltrek output to spot and cell mapping

Hi,

I recently started using Celltrek. I am trying to understand how to interpret the x and y coordinate output in celltrek data.

My celltrek results are interpolated (for the visium data) to show cells between the spots. I am trying to understand or accurately decipher the tumor proportions for each site. I was looking at the image output of the Seurat object and the celltrek output. Do the two things mean the same?

> head(samp_celltrek$coord_x)
Other_10X249_2.CTGTAGACAGGCATTT.5 Other_10X175_2.TCTCAGCAGTGACACG.5
                         7084.793                          7076.214
Other_10X264_3.TAACGACAGGCGTCCT.5 Other_10X249_2.CCTCACAGTGGCCTCA.5
                         7062.018                          7095.788
Other_10X249_4.GTTGCGGAGGATTTCC.5 Other_10X265_5.TTTGGTTAGCCGGATA.5
                         7066.821                          7091.498
> head(samp_celltrek$coord_y)
Other_10X249_2.CTGTAGACAGGCATTT.5 Other_10X175_2.TCTCAGCAGTGACACG.5
                         7656.116                          7638.562
Other_10X264_3.TAACGACAGGCGTCCT.5 Other_10X249_2.CCTCACAGTGGCCTCA.5
                         7643.233                          7639.805
Other_10X249_4.GTTGCGGAGGATTTCC.5 Other_10X265_5.TTTGGTTAGCCGGATA.5
                         7634.537                          7648.865

sum(table(samp_celltrek$clean_cell_type[grep(7077,samp_celltrek$coord_x)]))
sum(table(samp_celltrek$clean_cell_type[grep(7642,samp_celltrek$coord_y)]))

I see there is a difference here which is possible because of the interpolation celltrek does for 10x visium for cells which may lie between two spots.

But is this the correct understanding of the output or is there a more accurate way to get the cells/celltypes for a particular spot? Kindly let me know.

Thank you!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.