Direct integration with RCTD on the Visium adult mouse brain dataset

[1]:
set.seed(20250626)
library(Matrix)
library(spacexr)
library(MCube)
library(ggplot2)
[2]:
RESULT_PATH <- "/import/home/share/zw/pql/results/mouse_brain/reliability"

Cell type deconvolution results from RCTD

[3]:
myRCTD <- readRDS(file.path(RESULT_PATH, "visium_1", "myRCTD.rds"))

Integration of MCube and RCTD using one line of code

[4]:
mcube_object <- mcubeRCTD(myRCTD, RCTD_mode = "full", num_workers = 36, num_threads = 1, shared_memory = TRUE)
The batch_id is not provided!
All spots are assumed to be from the same batch and share the same gene platform effects.

Select high-abundance cell types to analyze with proportion_threshold = 0.1 and celltype_threshold = 100.

mcubeFilterCellTypes: Cell type(s) Ext_L23, Oligo_2, Inh_1, Ext_Thal_1, Ext_Thal_2, Inh_4, Astro_HPC pass the threshold.

Cell type(s) Astro_THAL_med, Inh_Sst, Inh_6, Ext_L5_3, Inh_Meis2_3, Micro, Ext_L5_2, Ext_Pir, Astro_AMY, Inh_2, Inh_Pvalb, Inh_Lamp5, Ext_L25, Nb_2, Ext_L56, Ext_Unk_2, Ext_Unk_3, Inh_3, Ext_Amy_2, Ext_L5_1, OPC_1, Astro_AMY_CTX, Ext_Hpc_DG1, Astro_HYPO, Inh_Meis2_1, Ext_Hpc_DG2, Ext_Med, Inh_Meis2_2, Ext_Hpc_CA1, Ext_L6B, Astro_CTX, Ext_Amy_1, Astro_WM, Oligo_1, Astro_STR, Ext_L6, Astro_THAL_lat, Nb_1, LowQ_2, Inh_Vip, Ext_ClauPyr, Ext_Hpc_CA2, OPC_2, Inh_5, Ext_Hpc_CA3, Ext_Unk_1, Inh_Meis2_4, Unk_2, Astro_THAL_hab, LowQ_1, Endo has/have less than the minimum celltype_threshold = 100 with proportion_threshold = 0.1.
To include the above cell type(s), please reduce celltype_threshold or proportion_threshold.

Cell type(s) Ext_L23, Oligo_2, Inh_1, Ext_Thal_1, Ext_Thal_2, Inh_4, Astro_HPC will be analyzed.

Filter out lowly-expressed genes with gene_threshold = 5e-05.

mcubeFilterGenes: 2768 genes pass the threshold.

The platform effects are not provided and need to be estimated from data!

Select highly-expressed genes to analyze for each specific cell type with reference_threshold = 0.5.

mcubeFilterGenesCellType: Select 1209 genes to analyze for Ext_L23.

mcubeFilterGenesCellType: Select 1203 genes to analyze for Oligo_2.

mcubeFilterGenesCellType: Select 1435 genes to analyze for Inh_1.

mcubeFilterGenesCellType: Select 1137 genes to analyze for Ext_Thal_1.

mcubeFilterGenesCellType: Select 1300 genes to analyze for Ext_Thal_2.

mcubeFilterGenesCellType: Select 1421 genes to analyze for Inh_4.

mcubeFilterGenesCellType: Select 1276 genes to analyze for Astro_HPC.

Preprocessed data description: 4167 spots and 58 cell types in total. 3361 spots, 2757 genes, and 7 cell type(s) to analyze.

Number of physical cores: 72.

Number of workers: 36.

Number of thread(s) on BLAS per worker: 1.

mcubeKernel: length_scale is set as 0.101063440730398 for the Gaussian kernel.

mcubeKernel: length_scale is set as 0.142925288541018 for the Gaussian kernel.

mcubeKernel: length_scale is set as 0.101063440730398 for the Gaussian_transformed kernel.

mcubeKernel: length_scale is set as 0.142925288541018 for the Gaussian_transformed kernel.

Number of physical cores: 72.

Number of workers: 36.

Number of thread(s) on BLAS per worker: 1.

Visiualization

Cell type proportions

[5]:
celltype <- "Ext_Thal_1"
mcubePlotPropCellType(mcube_object@proportions, mcube_object@coordinates, celltype)
../_images/RCTD_mouse_brain_9_0.png
[6]:
head(mcubeGetSigGenes(mcube_object@pvalues)[[celltype]])
mcubeGetSigGenes: Set adjust_method as BH and alpha as 0.05.

A data.frame: 6 × 2
pvalueadjusted_pvalue
<dbl><dbl>
Pcp48.069989e-707.037030e-67
Cplx11.206592e-625.260740e-60
Atp1b14.314774e-501.254161e-47
Snap252.196608e-414.788606e-39
Nsmf3.104560e-395.414353e-37
Nefm1.083976e-331.575379e-31

Overall gene expression

[7]:
gene <- "Nsmf"
mcubePlotExpr(mcube_object@counts, mcube_object@coordinates, gene, background = TRUE)
../_images/RCTD_mouse_brain_12_0.png

Gene expression variations within a specific cell type

[8]:
mcubePlotExprCellTypeBinary(mcube_object, celltype, gene, background = TRUE)
../_images/RCTD_mouse_brain_14_0.png
[ ]: