Skip to content

Using split.by kills na_cutoff for genes with zero expression (no lightgrey points...) #268

Description

@CroixJeremy2

Hello, it is me again,

I have found a small visual annoying bug: when all cells have zero expression for a gene of interest, using split.by kills the na_cutoff, which then does not apply correctly, thus the color scale is not showing lightgrey points as it should. Could you correct it please? If this is expected behaviour somehow, can you provide a solution + add a warning for other users please?

Thanks in advance,
Best regards,

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

#Minimal example using ifnb dataset
	#Loading
		data(ifnb)
		ifnb = UpdateSeuratObject(object = ifnb)
		ifnb = Convert_Assay(seurat_object = ifnb, convert_to = "V5")

	#Quick pipeline
		ifnb #normalisation already done, no need to run NormalizeData(ifnb)
		ifnb = FindVariableFeatures(ifnb)
		ifnb = ScaleData(ifnb)
		ifnb = RunPCA(ifnb)
		ifnb = RunUMAP(ifnb, dims = 1:30)

	#Extracting the genes that have zero counts for all cells
		matrix = LayerData(object = ifnb[["RNA"]], layer = "data")
		zero_genes = rownames(matrix)[Matrix::rowSums(matrix) == 0]
		zero_genes
			# "HIST2H2BF"
			# "LHX4"
			# "RP1-191J18.66"
			# "RP11-305L7.1"
			# "NUAK1"
			# "RILPL1"
			# "C22orf15"
			# "SLC1A7"
			# "CTA-363E6.6"

	#Merged UMAP that correctly produces lightgrey points as values are below na_cutoff (as expected)
		FeaturePlot_scCustom(seurat_object = ifnb,
							features = "LHX4")
		# Warning message:
		# All cells have the same value (0) of “LHX4”

	#Split UMAP that incorrectly does NOT produce lightgrey points for values that are below na_cutoff...
		FeaturePlot_scCustom(seurat_object = ifnb,
							split.by = "stim",
							features = "LHX4")
		# Warning messages:
		# 1: All cells have the same value (0) of “LHX4”
		# 2: All cells have the same value (0) of “LHX4”

	#Even setting a tiny na_cutoff does not solve the problem...
		FeaturePlot_scCustom(seurat_object = ifnb,
							split.by = "stim",
							na_cutoff = 1e-300,
							features = "LHX4")
Image Image
sessionInfo() output
> sessionInfo()
R version 4.6.1 (2026-06-24)
Platform: aarch64-apple-darwin23
Running under: macOS Tahoe 26.5.2

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.6/Resources/lib/libRblas.0.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.6/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] pbmc3k.SeuratData_3.1.4 ifnb.SeuratData_3.0.0   SeuratData_0.2.2.9002  
[4] scCustomize_3.3.1.9004  Seurat_5.5.1            SeuratObject_5.4.0     
[7] sp_2.2-1               

loaded via a namespace (and not attached):
  [1] RColorBrewer_1.1-3     rstudioapi_0.19.0      jsonlite_2.0.0        
  [4] shape_1.4.6.1          magrittr_2.0.5         spatstat.utils_3.2-3  
  [7] ggbeeswarm_0.7.3       farver_2.1.2           GlobalOptions_0.1.4   
 [10] vctrs_0.7.3            ROCR_1.0-12            spatstat.explore_3.8-1
 [13] paletteer_1.7.0        janitor_2.2.1          htmltools_0.5.9       
 [16] forcats_1.0.1          sctransform_0.4.3      parallelly_1.48.0     
 [19] KernSmooth_2.23-26     htmlwidgets_1.6.4      ica_1.0-3             
 [22] plyr_1.8.9             plotly_4.12.0          zoo_1.8-15            
 [25] lubridate_1.9.5        igraph_2.3.3           mime_0.13             
 [28] lifecycle_1.0.5        pkgconfig_2.0.3        Matrix_1.7-5          
 [31] R6_2.6.1               fastmap_1.2.0          fitdistrplus_1.2-6    
 [34] future_1.70.0          shiny_1.14.0           snakecase_0.11.1      
 [37] digest_0.6.39          colorspace_2.1-2       rematch2_2.1.2        
 [40] patchwork_1.3.2        tensor_1.5.1           RSpectra_0.16-2       
 [43] irlba_2.3.7            labeling_0.4.3         progressr_1.0.0       
 [46] spatstat.sparse_3.2-0  timechange_0.4.0       httr_1.4.8            
 [49] polyclip_1.10-7        abind_1.4-8            compiler_4.6.1        
 [52] withr_3.0.3            S7_0.2.2               fastDummies_1.7.6     
 [55] MASS_7.3-65            rappdirs_0.3.4         tools_4.6.1           
 [58] vipor_0.4.7            lmtest_0.9-40          otel_0.2.0            
 [61] beeswarm_0.4.0         httpuv_1.6.17          future.apply_1.20.2   
 [64] goftest_1.2-3          glue_1.8.1             nlme_3.1-169          
 [67] promises_1.5.0         grid_4.6.1             Rtsne_0.17            
 [70] cluster_2.1.8.2        reshape2_1.4.5         generics_0.1.4        
 [73] gtable_0.3.6           spatstat.data_3.1-9    tidyr_1.3.2           
 [76] data.table_1.18.4      spatstat.geom_3.8-1    RcppAnnoy_0.0.23      
 [79] ggrepel_0.9.8          RANN_2.6.2             pillar_1.11.1         
 [82] stringr_1.6.0          spam_2.11-4            RcppHNSW_0.7.0        
 [85] ggprism_1.0.7          later_1.4.8            circlize_0.4.18       
 [88] splines_4.6.1          dplyr_1.2.1            lattice_0.22-9        
 [91] survival_3.8-6         deldir_2.0-4           tidyselect_1.2.1      
 [94] miniUI_0.1.2           pbapply_1.7-4          gridExtra_2.3.1       
 [97] scattermore_1.2        matrixStats_1.5.0      stringi_1.8.7         
[100] lazyeval_0.2.3         codetools_0.2-20       tibble_3.3.1          
[103] cli_3.6.6              uwot_0.2.4             xtable_1.8-8          
[106] reticulate_1.46.0      Rcpp_1.1.2             globals_0.19.1        
[109] spatstat.random_3.5-0  mcprogress_0.1.1       png_0.1-9             
[112] ggrastr_1.0.2          spatstat.univar_3.2-0  parallel_4.6.1        
[115] ggplot2_4.0.3          dotCall64_1.2          listenv_1.0.0         
[118] viridisLite_0.4.3      scales_1.4.0           ggridges_0.5.7        
[121] purrr_1.2.2            crayon_1.5.3           rlang_1.3.0           
[124] 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