In this vignette we will demonstrate how to apply the main Starlng function to single-cell RNA-seq data. We will exemplify this on the PBMC3k dataset.
library(Starlng)
library(Seurat)
#> Loading required package: SeuratObject
#> Loading required package: sp
#>
#> Attaching package: 'SeuratObject'
#> The following objects are masked from 'package:base':
#>
#> intersect, t
library(SeuratData)
#> ── Installed datasets ──────────────────────────────── SeuratData v0.2.2.9002 ──
#> ✔ pbmc3k 3.1.4
#> ────────────────────────────────────── Key ─────────────────────────────────────
#> ✔ Dataset loaded successfully
#> ❯ Dataset built with a newer version of Seurat than installed
#> ❓ Unknown version of Seurat installed
print(packageVersion("Starlng"))
#> [1] '1.0.0'We repeated the procedures of downloading, qc filtering, normalising and dimensionality reduction as described in the ClustAssess vignette.
InstallData("pbmc3k")
#> Warning: The following packages are already installed and will not be
#> reinstalled: pbmc3k
data("pbmc3k")
pbmc3k <- UpdateSeuratObject(pbmc3k)
#> Validating object structure
#> Updating object slots
#> Ensuring keys are in the proper structure
#> Warning: Assay RNA changing from Assay to Assay
#> Ensuring keys are in the proper structure
#> Ensuring feature names don't have underscores or pipes
#> Updating slots in RNA
#> Validating object structure for Assay 'RNA'
#> Object representation is consistent with the most current Seurat version
pbmc3k <- PercentageFeatureSet(pbmc3k, pattern = "^MT-", col.name = "percent.mito")
pbmc3k <- PercentageFeatureSet(pbmc3k, pattern = "^RP[SL][[:digit:]]", col.name = "percent.rp")
all.index <- seq_len(nrow(pbmc3k))
MT.index <- grep(pattern = "^MT-", x = rownames(pbmc3k), value = FALSE)
RP.index <- grep(pattern = "^RP[SL][[:digit:]]", x = rownames(pbmc3k), value = FALSE)
pbmc3k <- pbmc3k[!((all.index %in% MT.index) | (all.index %in% RP.index)), ]
pbmc3k <- subset(pbmc3k, nFeature_RNA < 2000 & nCount_RNA < 2500 & percent.mito < 7 & percent.rp > 7)
pbmc3k <- NormalizeData(pbmc3k, verbose = FALSE)
#> Warning: The `slot` argument of `SetAssayData()` is deprecated as of SeuratObject 5.0.0.
#> ℹ Please use the `layer` argument instead.
#> ℹ The deprecated feature was likely used in the Seurat package.
#> Please report the issue at <https://github.com/satijalab/seurat/issues>.
#> This warning is displayed once every 8 hours.
#> Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
#> generated.
#> Warning: The `slot` argument of `GetAssayData()` is deprecated as of SeuratObject 5.0.0.
#> ℹ Please use the `layer` argument instead.
#> ℹ The deprecated feature was likely used in the Seurat package.
#> Please report the issue at <https://github.com/satijalab/seurat/issues>.
#> This warning is displayed once every 8 hours.
#> Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
#> generated.
pbmc3k <- FindVariableFeatures(pbmc3k, selection.method = "vst", nfeatures = 3000, verbose = FALSE)
pbmc3k <- ScaleData(pbmc3k, features = rownames(pbmc3k), verbose = FALSE)
pbmc3k <- RunPCA(pbmc3k,
npcs = 30,
approx = FALSE,
verbose = FALSE
)
pbmc3k <- RunUMAP(pbmc3k,
reduction = "pca",
dims = 1:30,
n.neighbors = 30,
min.dist = 0.3,
metric = "cosine",
verbose = FALSE
)
#> Warning: The default method for RunUMAP has changed from calling Python UMAP via reticulate to the R-native UWOT using the cosine metric
#> To use Python UMAP via reticulate, set umap.method to 'umap-learn' and metric to 'correlation'
#> This message will be shown once per session
pbmc3k
#> An object of class Seurat
#> 13607 features across 2401 samples within 1 assay
#> Active assay: RNA (13607 features, 3000 variable features)
#> 3 layers present: counts, data, scale.data
#> 2 dimensional reductions calculated: pca, umapApplying Starlng is straightforward, using the starlng_write_app_default() function. The function requires a normalised expression matrix, a metadata dataframe, a PCA and UMAP embedding. The function allows controlling the number of points used in inferring the pseudotime trajectory (learn_graph_parameters), filtering the genes based on autocorrelation (gene_filtering_function) and the parameters used in the stability assessment of gene clustering (clustering_parameters).
starlng_write_app_default(
folder_path = "starlng_app_pbmc3k",
expression_matrix = GetAssayData(pbmc3k, assay = "RNA", slot = "data"),
metadata_df = pbmc3k@meta.data,
pca_embedding = Embeddings(pbmc3k, reduction = "pca"),
umap_embedding = Embeddings(pbmc3k, reduction = "umap"),
app_title_name = "Starlng PBMC3K Example"
)The function will create a Starlng Shiny application in the specified folder. You can run the application using the following command:
shiny::runApp("starlng_app_pbmc3k")Session Info
sessionInfo()
#> R version 4.5.1 (2025-06-13)
#> Platform: x86_64-pc-linux-gnu
#> Running under: Ubuntu 22.04.5 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=C.UTF-8 LC_NUMERIC=C LC_TIME=C.UTF-8
#> [4] LC_COLLATE=C.UTF-8 LC_MONETARY=C.UTF-8 LC_MESSAGES=C.UTF-8
#> [7] LC_PAPER=C.UTF-8 LC_NAME=C LC_ADDRESS=C
#> [10] LC_TELEPHONE=C LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C
#>
#> time zone: Europe/Bucharest
#> tzcode source: system (glibc)
#>
#> attached base packages:
#> [1] stats graphics grDevices utils datasets methods base
#>
#> other attached packages:
#> [1] pbmc3k.SeuratData_3.1.4 SeuratData_0.2.2.9002 Seurat_5.3.0
#> [4] SeuratObject_5.2.0 sp_2.2-0 Starlng_1.0.0
#>
#> loaded via a namespace (and not attached):
#> [1] deldir_2.0-4 pbapply_1.7-4 gridExtra_2.3
#> [4] rlang_1.1.6 magrittr_2.0.4 RcppAnnoy_0.0.22
#> [7] spatstat.geom_3.6-0 matrixStats_1.5.0 ggridges_0.5.7
#> [10] compiler_4.5.1 png_0.1-8 systemfonts_1.3.1
#> [13] vctrs_0.6.5 reshape2_1.4.4 stringr_1.5.2
#> [16] crayon_1.5.3 pkgconfig_2.0.3 fastmap_1.2.0
#> [19] promises_1.3.3 rmarkdown_2.30 ragg_1.5.0
#> [22] purrr_1.1.0 xfun_0.53 cachem_1.1.0
#> [25] jsonlite_2.0.0 goftest_1.2-3 later_1.4.4
#> [28] spatstat.utils_3.2-0 irlba_2.3.5.1 parallel_4.5.1
#> [31] cluster_2.1.8.1 R6_2.6.1 ica_1.0-3
#> [34] spatstat.data_3.1-9 stringi_1.8.7 bslib_0.9.0
#> [37] RColorBrewer_1.1-3 reticulate_1.43.0 spatstat.univar_3.1-4
#> [40] parallelly_1.45.1 lmtest_0.9-40 jquerylib_0.1.4
#> [43] scattermore_1.2 Rcpp_1.1.0 iterators_1.0.14
#> [46] knitr_1.50 tensor_1.5.1 future.apply_1.20.0
#> [49] zoo_1.8-14 sctransform_0.4.2 httpuv_1.6.16
#> [52] Matrix_1.7-4 splines_4.5.1 igraph_2.2.0
#> [55] tidyselect_1.2.1 abind_1.4-8 yaml_2.3.10
#> [58] spatstat.random_3.4-2 spatstat.explore_3.5-3 codetools_0.2-19
#> [61] miniUI_0.1.2 listenv_0.9.1 lattice_0.22-5
#> [64] tibble_3.3.0 plyr_1.8.9 shiny_1.11.1
#> [67] S7_0.2.0 ROCR_1.0-11 evaluate_1.0.5
#> [70] Rtsne_0.17 future_1.67.0 fastDummies_1.7.5
#> [73] desc_1.4.3 survival_3.8-3 polyclip_1.10-7
#> [76] fitdistrplus_1.2-4 pillar_1.11.1 KernSmooth_2.23-26
#> [79] foreach_1.5.2 plotly_4.11.0 generics_0.1.4
#> [82] RcppHNSW_0.6.0 ggplot2_4.0.0 scales_1.4.0
#> [85] globals_0.18.0 xtable_1.8-4 glue_1.8.0
#> [88] lazyeval_0.2.2 tools_4.5.1 data.table_1.17.8
#> [91] RSpectra_0.16-2 RANN_2.6.2 fs_1.6.6
#> [94] dotCall64_1.2 cowplot_1.2.0 grid_4.5.1
#> [97] tidyr_1.3.1 nlme_3.1-168 patchwork_1.3.2
#> [100] cli_3.6.5 rappdirs_0.3.3 spatstat.sparse_3.1-0
#> [103] textshaping_1.0.4 spam_2.11-1 viridisLite_0.4.2
#> [106] dplyr_1.1.4 uwot_0.2.3 gtable_0.3.6
#> [109] sass_0.4.10 digest_0.6.37 progressr_0.17.0
#> [112] ggrepel_0.9.6 htmlwidgets_1.6.4 farver_2.1.2
#> [115] htmltools_0.5.8.1 pkgdown_2.1.3 lifecycle_1.0.4
#> [118] httr_1.4.7 mime_0.13 MASS_7.3-65