| Title: | A unified language for interacting with Seurat and SingleCellExperiment |
|---|---|
| Description: | scLang is a suite for package development for scRNA-seq analysis. It offers functions that can operate on both Seurat and SingleCellExperiment objects. These functions are primarily aimed to help developers build tools compatible with both types of input. |
| Authors: | Andrei-Florian Stoica [aut, cre] (ORCID: <https://orcid.org/0000-0002-5253-0826>) |
| Maintainer: | Andrei-Florian Stoica <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 1.1.3 |
| Built: | 2026-05-07 11:15:55 UTC |
| Source: | https://github.com/bioc/scLang |
This function creates a dimensionality reduction plot
dimPlot( scObj, groupBy = NULL, title = NULL, dimred = "umap", dims = c(1, 2), legendTitle = "Group", noGroupsLegendLab = "Object", palette = "grDevices::rainbow", pointSize = 0.5, alpha = 0.7, legendPos = c("right", "top", "left", "bottom"), legendTextSize = 10, legendTitleSize = 10, axisTextSize = 12, axisTitleSize = 12, ... )dimPlot( scObj, groupBy = NULL, title = NULL, dimred = "umap", dims = c(1, 2), legendTitle = "Group", noGroupsLegendLab = "Object", palette = "grDevices::rainbow", pointSize = 0.5, alpha = 0.7, legendPos = c("right", "top", "left", "bottom"), legendTextSize = 10, legendTitleSize = 10, axisTextSize = 12, axisTitleSize = 12, ... )
scObj |
A |
groupBy |
Grouping variable. Must exist in the metadata/coldata of the single-cell expression object. |
title |
Plot title. |
dimred |
Dimensionality reduction. |
dims |
A numeric vector of size 2 representing the dimensions selected for the plot. |
legendTitle |
Legend title. |
noGroupsLegendLab |
Legend label to be used when no grouping is
provided ( |
palette |
Color palette. |
pointSize |
Point size. |
alpha |
Opaqueness level. |
legendPos |
Legend position. |
legendTextSize |
Legend text size. |
legendTitleSize |
Legend title size. |
axisTextSize |
Axis text size. |
axisTitleSize |
Axis title size. |
... |
Additional arguments passed to |
A dimensionality reduction plot.
scePath <- system.file('extdata', 'sceObj.qs2', package='scLang') sceObj <- qs2::qs_read(scePath) dimPlot(sceObj, groupBy='Donor')scePath <- system.file('extdata', 'sceObj.qs2', package='scLang') sceObj <- qs2::qs_read(scePath) dimPlot(sceObj, groupBy='Donor')
This function extracts the names of available dimensionality reductions
from a Seurat or SingleCellExperiment object.
## Default S3 method: dimredNames(scObj) ## S3 method for class 'Seurat' dimredNames(scObj) ## S3 method for class 'SingleCellExperiment' dimredNames(scObj) dimredNames(scObj)## Default S3 method: dimredNames(scObj) ## S3 method for class 'Seurat' dimredNames(scObj) ## S3 method for class 'SingleCellExperiment' dimredNames(scObj) dimredNames(scObj)
scObj |
A |
A character vector.
scePath <- system.file('extdata', 'sceObj.qs2', package='scLang') sceObj <- qs2::qs_read(scePath) dimredNames(sceObj)scePath <- system.file('extdata', 'sceObj.qs2', package='scLang') sceObj <- qs2::qs_read(scePath) dimredNames(sceObj)
This function creates a dimensionality reduction plot to represent a feature (gene expression or numeric metadata column).
featurePlot( scObj, feature = rownames(scObj)[1], title = feature, dimred = "umap", dims = c(1, 2), legendTitle = NULL, palette = paletteer_d("wesanderson::Royal1")[c(3, 2)], pointSize = 0.5, alpha = 0.6, legendPos = c("right", "top", "left", "bottom"), legendTextSize = 10, legendTitleSize = 10, axisTextSize = 12, axisTitleSize = 12, ... )featurePlot( scObj, feature = rownames(scObj)[1], title = feature, dimred = "umap", dims = c(1, 2), legendTitle = NULL, palette = paletteer_d("wesanderson::Royal1")[c(3, 2)], pointSize = 0.5, alpha = 0.6, legendPos = c("right", "top", "left", "bottom"), legendTextSize = 10, legendTitleSize = 10, axisTextSize = 12, axisTitleSize = 12, ... )
scObj |
A |
feature |
A gene name or metadata column name. |
title |
Plot title. |
dimred |
Dimensionality reduction. |
dims |
A numeric vector of size 2 representing the dimensions selected for the plot. |
legendTitle |
Legend title. |
palette |
Color palette. |
pointSize |
Point size. |
alpha |
Opaqueness level. |
legendPos |
Legend position. |
legendTextSize |
Legend text size. |
legendTitleSize |
Legend title size. |
axisTextSize |
Axis text size. |
axisTitleSize |
Axis title size. |
... |
Additional arguments passed to |
A feature plot.
scePath <- system.file('extdata', 'sceObj.qs2', package='scLang') sceObj <- qs2::qs_read(scePath) featurePlot(sceObj, 'Gene289')scePath <- system.file('extdata', 'sceObj.qs2', package='scLang') sceObj <- qs2::qs_read(scePath) featurePlot(sceObj, 'Gene289')
This function extracts the metadata from a Seurat or
SingleCellExperiment object as a data frame.
metadataDF(scObj) ## Default S3 method: metadataDF(scObj) ## S3 method for class 'Seurat' metadataDF(scObj) ## S3 method for class 'SingleCellExperiment' metadataDF(scObj)metadataDF(scObj) ## Default S3 method: metadataDF(scObj) ## S3 method for class 'Seurat' metadataDF(scObj) ## S3 method for class 'SingleCellExperiment' metadataDF(scObj)
scObj |
A |
A metadata data frame.
scePath <- system.file('extdata', 'sceObj.qs2', package='scLang') sceObj <- qs2::qs_read(scePath) df <- metadataDF(sceObj)scePath <- system.file('extdata', 'sceObj.qs2', package='scLang') sceObj <- qs2::qs_read(scePath) df <- metadataDF(sceObj)
This function extracts metadata names from a Seurat or SingleCellExperiment object. It can also be used to modify metadata names.
metadataNames(scObj)metadataNames(scObj)
scObj |
A |
The names of the metadata columns.
scePath <- system.file('extdata', 'sceObj.qs2', package='scLang') sceObj <- qs2::qs_read(scePath) colNames <- metadataNames(sceObj)scePath <- system.file('extdata', 'sceObj.qs2', package='scLang') sceObj <- qs2::qs_read(scePath) colNames <- metadataNames(sceObj)
This function extracts a metadata/coldata column from a Seurat or
SingleCellExperiment object.
scCol(scObj, col) scCol(scObj, col) <- value ## Default S3 method: scCol(scObj, col) ## Default S3 replacement method: scCol(scObj, col) <- value ## S3 method for class 'Seurat' scCol(scObj, col) ## S3 replacement method for class 'Seurat' scCol(scObj, col) <- value ## S3 method for class 'SingleCellExperiment' scCol(scObj, col) ## S3 replacement method for class 'SingleCellExperiment' scCol(scObj, col) <- valuescCol(scObj, col) scCol(scObj, col) <- value ## Default S3 method: scCol(scObj, col) ## Default S3 replacement method: scCol(scObj, col) <- value ## S3 method for class 'Seurat' scCol(scObj, col) ## S3 replacement method for class 'Seurat' scCol(scObj, col) <- value ## S3 method for class 'SingleCellExperiment' scCol(scObj, col) ## S3 replacement method for class 'SingleCellExperiment' scCol(scObj, col) <- value
scObj |
A |
col |
Column name. |
value |
A vector to be added to the metadata/coldata of the single-cell expression object. |
A vector.
scePath <- system.file('extdata', 'sceObj.qs2', package='scLang') sceObj <- qs2::qs_read(scePath) v <- scCol(sceObj, 'Cluster')scePath <- system.file('extdata', 'sceObj.qs2', package='scLang') sceObj <- qs2::qs_read(scePath) v <- scCol(sceObj, 'Cluster')
This function extracts per-group counts from the column of single-cell expression object.
scColCounts(scObj, col)scColCounts(scObj, col)
scObj |
A |
col |
Column as string. |
A frequency vector with the unique column values as names.
scePath <- system.file('extdata', 'sceObj.qs2', package='scLang') sceObj <- qs2::qs_read(scePath) scColCounts(sceObj, 'Cluster')scePath <- system.file('extdata', 'sceObj.qs2', package='scLang') sceObj <- qs2::qs_read(scePath) scColCounts(sceObj, 'Cluster')
This function extracts count information from two columns of a single-cell expression object.
scColPairCounts(scObj, col1, col2)scColPairCounts(scObj, col1, col2)
scObj |
A |
col1 |
Column as string. |
col2 |
Column as string. |
A data frame listing the counts of all combinations of pairs from two categorical columns.
scePath <- system.file('extdata', 'sceObj.qs2', package='scLang') sceObj <- qs2::qs_read(scePath) scColPairCounts(sceObj, 'Cluster', 'Donor')scePath <- system.file('extdata', 'sceObj.qs2', package='scLang') sceObj <- qs2::qs_read(scePath) scColPairCounts(sceObj, 'Cluster', 'Donor')
This function extracts percentage information from two columns of a single-cell expression object. For each i x j combination with i taken from column 1 and j taken from column 2, the function reports the percentage that j contributes to all combinations involving i.
scColPairPercs(scObj, col1, col2, sigDigits = 2)scColPairPercs(scObj, col1, col2, sigDigits = 2)
scObj |
A |
col1 |
Column as string. |
col2 |
Column as string. |
sigDigits |
Number of significant digits. |
A data frame listing the percentages of all combinations of pairs from two categorical columns.
scePath <- system.file('extdata', 'sceObj.qs2', package='scLang') sceObj <- qs2::qs_read(scePath) scColPairPercs(sceObj, 'Cluster', 'Donor')scePath <- system.file('extdata', 'sceObj.qs2', package='scLang') sceObj <- qs2::qs_read(scePath) scColPairPercs(sceObj, 'Cluster', 'Donor')
This function extracts observed-over-expected ratios from two columns of a single-cell expression object.
scColPairRatios(scObj, col1, col2, sigDigits = 2)scColPairRatios(scObj, col1, col2, sigDigits = 2)
scObj |
A |
col1 |
Column as string. |
col2 |
Column as string. |
sigDigits |
Number of significant digits. |
A data frame listing the observed-over-expected ratios of all combinations of pairs from two categorical columns.
scePath <- system.file('extdata', 'sceObj.qs2', package='scLang') sceObj <- qs2::qs_read(scePath) scColPairRatios(sceObj, 'Cluster', 'Donor')scePath <- system.file('extdata', 'sceObj.qs2', package='scLang') sceObj <- qs2::qs_read(scePath) scColPairRatios(sceObj, 'Cluster', 'Donor')
This function extracts a dimensionality reduction matrix from a
Seurat or SingleCellExperiment object.
## Default S3 method: scDimredMat(scObj, dimred) ## S3 method for class 'Seurat' scDimredMat(scObj, dimred) ## S3 method for class 'SingleCellExperiment' scDimredMat(scObj, dimred) scDimredMat(scObj, dimred)## Default S3 method: scDimredMat(scObj, dimred) ## S3 method for class 'Seurat' scDimredMat(scObj, dimred) ## S3 method for class 'SingleCellExperiment' scDimredMat(scObj, dimred) scDimredMat(scObj, dimred)
scObj |
A |
dimred |
Dimensionality reduction. |
A dimensionality reduction matrix.
scePath <- system.file('extdata', 'sceObj.qs2', package='scLang') sceObj <- qs2::qs_read(scePath) pcaMat <- scDimredMat(sceObj, 'pca')scePath <- system.file('extdata', 'sceObj.qs2', package='scLang') sceObj <- qs2::qs_read(scePath) pcaMat <- scDimredMat(sceObj, 'pca')
This function extracts an expression matrix from a Seurat or
SingleCellExperiment object. For additional flexibility, the input
can alternatively be provided as a dgCMatrix object
(and an option to densify it is also available) or as a matrix
object.
## Default S3 method: scExpMat(scObj, slot = NULL, genes = NULL, densify = TRUE) ## S3 method for class 'Seurat' scExpMat(scObj, slot = "data", genes = NULL, densify = TRUE) ## S3 method for class 'SingleCellExperiment' scExpMat(scObj, slot = "logcounts", genes = NULL, densify = TRUE) ## S3 method for class 'dgCMatrix' scExpMat(scObj, slot = NULL, genes = NULL, densify = TRUE) ## S3 method for class 'matrix' scExpMat(scObj, slot = NULL, genes = NULL, densify = TRUE) scExpMat(scObj, slot, genes = NULL, densify = TRUE)## Default S3 method: scExpMat(scObj, slot = NULL, genes = NULL, densify = TRUE) ## S3 method for class 'Seurat' scExpMat(scObj, slot = "data", genes = NULL, densify = TRUE) ## S3 method for class 'SingleCellExperiment' scExpMat(scObj, slot = "logcounts", genes = NULL, densify = TRUE) ## S3 method for class 'dgCMatrix' scExpMat(scObj, slot = NULL, genes = NULL, densify = TRUE) ## S3 method for class 'matrix' scExpMat(scObj, slot = NULL, genes = NULL, densify = TRUE) scExpMat(scObj, slot, genes = NULL, densify = TRUE)
scObj |
A |
slot |
Gene expression slot. Ignored if |
genes |
Selected genes. If |
densify |
Whether to convert to dense matrix. |
An expression matrix.
scePath <- system.file('extdata', 'sceObj.qs2', package='scLang') sceObj <- qs2::qs_read(scePath) mat <- scExpMat(sceObj, 'counts')scePath <- system.file('extdata', 'sceObj.qs2', package='scLang') sceObj <- qs2::qs_read(scePath) mat <- scExpMat(sceObj, 'counts')
This function extracts the expression of a single gene from a Seurat,
SingleCellExperiment, dgCMatrix or matrix object.
## Default S3 method: scGeneExp(scObj, gene, slot = NULL) ## S3 method for class 'Seurat' scGeneExp(scObj, gene, slot = "data") ## S3 method for class 'SingleCellExperiment' scGeneExp(scObj, gene, slot = "logcounts") ## S3 method for class 'dgCMatrix' scGeneExp(scObj, gene, slot = NULL) ## S3 method for class 'matrix' scGeneExp(scObj, gene, slot = NULL) scGeneExp(scObj, gene, slot)## Default S3 method: scGeneExp(scObj, gene, slot = NULL) ## S3 method for class 'Seurat' scGeneExp(scObj, gene, slot = "data") ## S3 method for class 'SingleCellExperiment' scGeneExp(scObj, gene, slot = "logcounts") ## S3 method for class 'dgCMatrix' scGeneExp(scObj, gene, slot = NULL) ## S3 method for class 'matrix' scGeneExp(scObj, gene, slot = NULL) scGeneExp(scObj, gene, slot)
scObj |
A |
gene |
Selected gene. |
slot |
Gene expression slot. Ignored if |
A gene expression vector.
scePath <- system.file('extdata', 'sceObj.qs2', package='scLang') sceObj <- qs2::qs_read(scePath) v <- scGeneExp(sceObj, 'Gene291')scePath <- system.file('extdata', 'sceObj.qs2', package='scLang') sceObj <- qs2::qs_read(scePath) v <- scGeneExp(sceObj, 'Gene291')
This function extracts the PCA matrix from a Seurat or SingleCellExperiment object.
scPCAMat(scObj)scPCAMat(scObj)
scObj |
A |
A PCA matrix.
scePath <- system.file('extdata', 'sceObj.qs2', package='scLang') sceObj <- qs2::qs_read(scePath) pcaMat <- scPCAMat(sceObj)scePath <- system.file('extdata', 'sceObj.qs2', package='scLang') sceObj <- qs2::qs_read(scePath) pcaMat <- scPCAMat(sceObj)
This function extracts the UMAP matrix from a Seurat or SingleCellExperiment object.
scUMAPMat(scObj)scUMAPMat(scObj)
scObj |
A |
A UMAP matrix.
scePath <- system.file('extdata', 'sceObj.qs2', package='scLang') sceObj <- qs2::qs_read(scePath) umapMat <- scUMAPMat(sceObj)scePath <- system.file('extdata', 'sceObj.qs2', package='scLang') sceObj <- qs2::qs_read(scePath) umapMat <- scUMAPMat(sceObj)
This function creates a violin plot to represent a feature (gene expression or numeric metadata column).
violinPlot( scObj, feature = rownames(scObj)[1], groupBy = metadataNames(scObj)[1], title = feature, legendTitle = NULL, xLab = "Identity", yLab = "Expression level", palette = "grDevices::rainbow", pointSize = 0.5, alpha = 0.8, legendPos = c("right", "top", "left", "bottom"), legendTextSize = 10, legendTitleSize = 10, axisTextSize = 12, axisTitleSize = 12, xLabAngle = 45, xLabVjust = 0.5, ... )violinPlot( scObj, feature = rownames(scObj)[1], groupBy = metadataNames(scObj)[1], title = feature, legendTitle = NULL, xLab = "Identity", yLab = "Expression level", palette = "grDevices::rainbow", pointSize = 0.5, alpha = 0.8, legendPos = c("right", "top", "left", "bottom"), legendTextSize = 10, legendTitleSize = 10, axisTextSize = 12, axisTitleSize = 12, xLabAngle = 45, xLabVjust = 0.5, ... )
scObj |
A |
feature |
A gene name or metadata column name. |
groupBy |
Grouping variable. Must exist in the metadata/coldata of the single-cell expression object. |
title |
Plot title. |
legendTitle |
Legend title. |
xLab |
x axis label. |
yLab |
y axis label. |
palette |
Color palette. |
pointSize |
Point size. |
alpha |
Opaqueness level. |
legendPos |
Legend position. |
legendTextSize |
Legend text size. |
legendTitleSize |
Legend title size. |
axisTextSize |
Axis text size. |
axisTitleSize |
Axis title size. |
xLabAngle |
x axis label angle. |
xLabVjust |
x axis label vertical justification in [0, 1]. |
... |
Additional arguments passed to |
A violin plot.
scePath <- system.file('extdata', 'sceObj.qs2', package='scLang') sceObj <- qs2::qs_read(scePath) violinPlot(sceObj, 'Gene289')scePath <- system.file('extdata', 'sceObj.qs2', package='scLang') sceObj <- qs2::qs_read(scePath) violinPlot(sceObj, 'Gene289')