Skip to content

The assay parameter inside FeaturePlot_scCustom() does not work properly when combined with the split.by parameter #267

Description

@CroixJeremy2

Hello, it is me again,

Everything is in the title and in the following minimal example. I think something inside FeaturePlot_scCustom (and maybe other related functions?) is missing somewhere.

#Required libraries
	library(Seurat)
	library(ggplot2)
	library(patchwork)
	library(scCustomize)
	library(SeuratData)
	# SeuratData::InstallData("ifnb")

#Load data (minimal example)
	data(ifnb)
	ifnb = UpdateSeuratObject(object = ifnb)
	ifnb = Convert_Assay(seurat_object = ifnb, convert_to = "V5")

	head(ifnb)
	#                   orig.ident nCount_RNA nFeature_RNA stim seurat_annotations
	# AAACATACATTTCC.1 IMMUNE_CTRL       3017          877 CTRL          CD14 Mono
	# AAACATACCAGAAA.1 IMMUNE_CTRL       2481          713 CTRL          CD14 Mono
	# AAACATACCTCGCT.1 IMMUNE_CTRL       3420          850 CTRL          CD14 Mono
	# AAACATACCTGGTA.1 IMMUNE_CTRL       3156         1109 CTRL                pDC
	# AAACATACGATGAA.1 IMMUNE_CTRL       1868          634 CTRL       CD4 Memory T
	# AAACATACGGCATT.1 IMMUNE_CTRL       1581          557 CTRL          CD14 Mono
	# AAACATACTGCGTA.1 IMMUNE_CTRL       2747          980 CTRL        T activated
	# AAACATACTGCTGA.1 IMMUNE_CTRL       1341          581 CTRL        CD4 Naive T
	# AAACATTGAGTGTC.1 IMMUNE_CTRL       2155          880 CTRL              CD8 T
	# AAACATTGCTTCGC.1 IMMUNE_CTRL       2536          669 CTRL          CD14 Mono

	table(ifnb$seurat_annotations, ifnb$stim)
	#              CTRL STIM
	# CD14 Mono    2215 2147
	# CD4 Naive T   978 1526
	# CD4 Memory T  859  903
	# CD16 Mono     507  537
	# B             407  571
	# CD8 T         352  462
	# T activated   300  333
	# NK            298  321
	# DC            258  214
	# B Activated   185  203
	# Mk            115  121
	# pDC            51   81
	# Eryth          23   32

#Checking which meta.data column is set as the Idents()
	unique(Idents(ifnb)) #IMMUNE_CTRL IMMUNE_STIM, OK, as it corresponds to the two datasets of this study

#Quick standard pipeline in order to generate a UMAP embedding
	ifnb = NormalizeData(ifnb)
	ifnb = FindVariableFeatures(ifnb)
	ifnb = ScaleData(ifnb)
	ifnb = RunPCA(ifnb)
	ifnb = RunUMAP(ifnb, dims = 1:30)

	ifnb
	# An object of class Seurat 
	# 14053 features across 13999 samples within 1 assay 
	# Active assay: RNA (14053 features, 2000 variable features)
	#  3 layers present: counts, data, scale.data
	#  2 dimensional reductions calculated: pca, umap

#Checking the name of the default assay
	DefaultAssay(ifnb) #"RNA", as expected

#DefaultAssay behaviour, OK, it works as expected
	#Retrieving the range
		range(FetchData(object = ifnb, vars = "GAPDH", assay = "RNA")[,1], na.rm = TRUE) #0.000000 5.225659

	#Merged graph on RNA assay, OK
		FeaturePlot_scCustom(seurat_object = ifnb,
								features = "GAPDH") #color scale matches with the range of FetchData, OK
Image
	#Split graph on RNA assay, OK
		FeaturePlot_scCustom(seurat_object = ifnb,
								features = "GAPDH",
								split.by = "stim") #color scale matches with the range of FetchData, OK
Image
#Creating another new assay (quickly using SCT for example, but in theory it could be anything else)
	ifnb = SCTransform(object = ifnb, return.only.var.genes = FALSE)

	ifnb
	# An object of class Seurat 
	# 27515 features across 13999 samples within 2 assays 
	# Active assay: SCT (13462 features, 3000 variable features)
	#  3 layers present: counts, data, scale.data
	#  1 other assay present: RNA
	#  2 dimensional reductions calculated: pca, umap

	DefaultAssay(ifnb) # now "SCT", but let's switch it back to "RNA" (the main one in my real-non-minimal data; but for clarity in this issue I used ifnb as a minimal example)
	DefaultAssay(ifnb) = "RNA"

#Same graphs, but made on the second assay: PROBLEM
	#Retrieving the range
		range(FetchData(object = ifnb, vars = "GAPDH", assay = "SCT")[,1], na.rm = TRUE) #0.000000 3.433987; different than the RNA assay, OK, as expected

	#Merged graph on RNA assay, OK
		FeaturePlot_scCustom(seurat_object = ifnb,
								assay = "SCT",
								features = "GAPDH") #color scale matches with the range of FetchData for this specific assay, OK
Image
	#Split graph on RNA assay, NOT OK
		FeaturePlot_scCustom(seurat_object = ifnb,
								assay = "SCT",
								features = "GAPDH",
								split.by = "stim") #the color scale does not match the SCT assay limits anymore... and goes back to the one of the RNA assay somehow...
Image
#Remark: switching manually the DefaultAssay BEFORE FeaturePlot_scCustom is a workaround, but it would be way better to rather make the "assay" parameter of FeaturePlot_scCustom working properly
	DefaultAssay(ifnb) = "SCT"

	#Split graph on RNA assay, OK now
		FeaturePlot_scCustom(seurat_object = ifnb,
								# assay = "SCT", #no need to use it anymore here
								features = "GAPDH",
								split.by = "stim") #the color scale NOW does match the SCT assay limits, but it would be better to select correctly the assay inside FeaturePlot_scCustom()

Image

Is there a way to make the assay parameter work when combined with split.by please?

Thanks in advance for your response, and thanks again for this great package,
Best regards,


sessionInfo() output
R version 4.5.3 (2026-03-11)
Platform: aarch64-apple-darwin20
Running under: macOS Tahoe 26.5.1

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib/libRblas.0.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.12.1

locale:
[1] C.UTF-8/C.UTF-8/C.UTF-8/C/C.UTF-8/C.UTF-8

time zone: Europe/Paris
tzcode source: internal

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

other attached packages:
 [1] future_1.70.0           pbmc3k.SeuratData_3.1.4 ifnb.SeuratData_3.0.0  
 [4] SeuratData_0.2.2.9002   scCustomize_3.3.0       patchwork_1.3.2        
 [7] ggplot2_4.0.3           Seurat_5.5.0            SeuratObject_5.4.0     
[10] sp_2.2-1               

loaded via a namespace (and not attached):
  [1] RColorBrewer_1.1-3          rstudioapi_0.18.0          
  [3] jsonlite_2.0.0              shape_1.4.6.1              
  [5] magrittr_2.0.5              spatstat.utils_3.2-3       
  [7] ggbeeswarm_0.7.3            farver_2.1.2               
  [9] GlobalOptions_0.1.4         vctrs_0.7.3                
 [11] ROCR_1.0-12                 DelayedMatrixStats_1.32.0  
 [13] spatstat.explore_3.8-0      paletteer_1.7.0            
 [15] janitor_2.2.1               S4Arrays_1.10.1            
 [17] htmltools_0.5.9             forcats_1.0.1              
 [19] SparseArray_1.10.10         sctransform_0.4.3          
 [21] parallelly_1.47.0           KernSmooth_2.23-26         
 [23] htmlwidgets_1.6.4           ica_1.0-3                  
 [25] plyr_1.8.9                  plotly_4.12.0              
 [27] zoo_1.8-15                  lubridate_1.9.5            
 [29] igraph_2.3.1                mime_0.13                  
 [31] lifecycle_1.0.5             pkgconfig_2.0.3            
 [33] Matrix_1.7-4                R6_2.6.1                   
 [35] fastmap_1.2.0               MatrixGenerics_1.22.0      
 [37] fitdistrplus_1.2-6          shiny_1.13.0               
 [39] snakecase_0.11.1            digest_0.6.39              
 [41] colorspace_2.1-2            rematch2_2.1.2             
 [43] S4Vectors_0.48.1            tensor_1.5.1               
 [45] RSpectra_0.16-2             irlba_2.3.7                
 [47] GenomicRanges_1.62.1        beachmat_2.26.0            
 [49] labeling_0.4.3              progressr_0.19.0           
 [51] spatstat.sparse_3.1-0       timechange_0.4.0           
 [53] httr_1.4.8                  polyclip_1.10-7            
 [55] abind_1.4-8                 compiler_4.5.3             
 [57] withr_3.0.2                 S7_0.2.2                   
 [59] fastDummies_1.7.6           MASS_7.3-65                
 [61] DelayedArray_0.36.1         rappdirs_0.3.4             
 [63] tools_4.5.3                 vipor_0.4.7                
 [65] lmtest_0.9-40               otel_0.2.0                 
 [67] beeswarm_0.4.0              httpuv_1.6.17              
 [69] future.apply_1.20.2         goftest_1.2-3              
 [71] glmGamPoi_1.22.0            glue_1.8.1                 
 [73] nlme_3.1-168                promises_1.5.0             
 [75] grid_4.5.3                  Rtsne_0.17                 
 [77] cluster_2.1.8.2             reshape2_1.4.5             
 [79] generics_0.1.4              gtable_0.3.6               
 [81] spatstat.data_3.1-9         tidyr_1.3.2                
 [83] data.table_1.18.4           XVector_0.50.0             
 [85] BiocGenerics_0.56.0         spatstat.geom_3.7-3        
 [87] RcppAnnoy_0.0.23            ggrepel_0.9.8              
 [89] RANN_2.6.2                  pillar_1.11.1              
 [91] stringr_1.6.0               spam_2.11-3                
 [93] RcppHNSW_0.6.0              ggprism_1.0.7              
 [95] later_1.4.8                 circlize_0.4.18            
 [97] splines_4.5.3               dplyr_1.2.1                
 [99] lattice_0.22-9              survival_3.8-6             
[101] deldir_2.0-4                tidyselect_1.2.1           
[103] miniUI_0.1.2                pbapply_1.7-4              
[105] gridExtra_2.3               Seqinfo_1.0.0              
[107] IRanges_2.44.0              SummarizedExperiment_1.40.0
[109] scattermore_1.2             stats4_4.5.3               
[111] Biobase_2.70.0              matrixStats_1.5.0          
[113] stringi_1.8.7               lazyeval_0.2.3             
[115] codetools_0.2-20            tibble_3.3.1               
[117] cli_3.6.6                   uwot_0.2.4                 
[119] xtable_1.8-8                reticulate_1.46.0          
[121] Rcpp_1.1.1-1.1              globals_0.19.1             
[123] spatstat.random_3.4-5       mcprogress_0.1.1           
[125] png_0.1-9                   ggrastr_1.0.2              
[127] spatstat.univar_3.2-0       parallel_4.5.3             
[129] dotCall64_1.2               sparseMatrixStats_1.22.0   
[131] listenv_0.10.1              viridisLite_0.4.3          
[133] scales_1.4.0                ggridges_0.5.7             
[135] crayon_1.5.3                purrr_1.2.2                
[137] rlang_1.2.0                 cowplot_1.2.0              

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions