Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@
.Rbuildignore
SPAROscore.Rproj
inst/doc
/vignettes/*.html
/vignettes/*.R

50 changes: 27 additions & 23 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
Package: SPAROscore
Type: Package
Title: A package to compute gene signature scores from transcriptomics data
Package: SPAROscore
Title: A package to compute gene signature scores from transcriptomics
data
Version: 0.99.0
Authors@R: c(
person(
"Venkatesh", "Kamaraj",
email = "venkatesh.kamaraj@adelaide.edu.au",
role = c("aut", "cre"),
comment = c(ORCID = "0009-0008-7309-9810")
)
)
Description: SPAROscore is a gene signature scoring method designed to be
robust across diverse gene expression datasets. SPAROscore adapts to
varying levels of sparsity, allowing signature scores to be efficiently
computed across bulk, single-cell, and spatial transcriptomic datasets.
biocViews: GeneExpression, SingleCell, Spatial, Transcriptomics,
GeneSetEnrichment, Pathways, Software
Authors@R:
person("Venkatesh", "Kamaraj", , "venkatesh.kamaraj@adelaide.edu.au", role = c("aut", "cre"),
comment = c(ORCID = "0009-0008-7309-9810"))
Description: SPAROscore is a gene signature scoring method designed to be
robust across diverse gene expression datasets. SPAROscore adapts to
varying levels of sparsity, allowing signature scores to be
efficiently computed across bulk, single-cell, and spatial
transcriptomic datasets. The resulting scores quantify the relative
expression of a gene signature compared with the background expression
of each sample/cell/domain, making the scores straightforward to
interpret biologically. Internally, SPAROscore ranks genes within
each column and computes the Spearman footrule distance between the
observed ranks of the signature genes and a background gene expression
rank estimated from the geometric mean expression of the sample, cell,
or spatial domain.
License: GPL-3
Encoding: UTF-8
RoxygenNote: 7.3.3
URL: https://github.com/MangiolaLaboratory/SPAROscore
BugReports: https://github.com/MangiolaLaboratory/SPAROscore/issues
Imports:
DelayedArray,
DelayedMatrixStats,
Expand All @@ -37,18 +39,20 @@ Suggests:
GSEABase,
knitr,
msigdbr,
muscData,
rmarkdown,
scater,
Seurat,
SeuratData,
SingleCellExperiment,
SpatialExperiment,
spatialLIBD,
SummarizedExperiment,
testthat (>= 3.0.0),
tidyr
VignetteBuilder: knitr
VignetteBuilder:
knitr
biocViews: GeneExpression, SingleCell, Spatial, Transcriptomics,
GeneSetEnrichment, Pathways, Software
Config/testthat/edition: 3
Remotes: satijalab/seurat-data
URL: https://github.com/MangiolaLaboratory/SPAROscore
BugReports: https://github.com/MangiolaLaboratory/SPAROscore/issues
Encoding: UTF-8
RoxygenNote: 7.3.3
2 changes: 1 addition & 1 deletion R/get_scores_generic.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
#' Defaults to NULL.
#'
#' When down_signatures is not NULL,
#' Final Score = Score(signatures) - Score(down_signatures)
#' Final Score <- Score(signatures) - Score(down_signatures)
#'
#'
#' @param prefix Character string to be appended before the headers of the
Expand Down
2 changes: 1 addition & 1 deletion R/helper_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ append_to_matrix_like_object <- function(matrix_like_object, numeric_vector){
#'
#'
#' @examples
#' \dontrun{
#' \donttest{
#' counts <- matrix(
#' c(0, 5, 10,
#' 2, 0, 20,
Expand Down
6 changes: 3 additions & 3 deletions R/sparoscore_generic.R
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
#' Defaults to NULL.
#'
#' When down_signatures is not NULL,
#' Final Score = Score(signatures) - Score(down_signatures)
#' Final Score <- Score(signatures) - Score(down_signatures)
#'
#'
#' @param prefix Character string to be appended before the headers of the
Expand Down Expand Up @@ -218,7 +218,7 @@
#' # Seurat object
#' # ------------------------------------------------------------------
#'
#' \dontrun{
#' \donttest{
#' seurat_object <- sparoscore(
#' data = seurat_object,
#' signatures = c("CCR7", "IL7R", "LTB")
Expand Down Expand Up @@ -257,7 +257,7 @@
#' # SingleCellExperiment / SummarizedExperiment
#' # ------------------------------------------------------------------
#'
#' \dontrun{
#' \donttest{
#' sce <- sparoscore(
#' data = sce,
#' signatures = c("CCR7", "IL7R", "LTB")
Expand Down
2 changes: 0 additions & 2 deletions vignettes/.gitignore

This file was deleted.

33 changes: 17 additions & 16 deletions vignettes/sparoscore_data_structures.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ vignette: >
%\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
```{r global-options, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
Expand Down Expand Up @@ -97,7 +97,7 @@ as well as the hallmark inflammatory response genes taken from the
Molecular Signatures Database (MSigDB).

### Load the gene expression dataset
```{r}
```{r load-data}
# load the airway dataset
data(airway)

Expand All @@ -109,7 +109,7 @@ metadata <- as.data.frame(colData(airway))
```

### Load the gene signatures
```{r}
```{r load-signature}
# set the glucocorticoid response markers from the original study as a signature
response_genes <- c("ENSG00000112936", "ENSG00000170606", "ENSG00000120129",
"ENSG00000152795", "ENSG00000211445", "ENSG00000163884",
Expand All @@ -131,7 +131,7 @@ inflammation_genes <- msigdbr(species = "Homo sapiens", collection = "H") %>%
# Gene expression as matrix-like data structures

## Dense matrix
```{r}
```{r matrix}
# load gene expression data as dense matrix
counts_matrix <- as.matrix(counts_data)

Expand All @@ -147,7 +147,7 @@ Note that one signature gene is absent from the input expression data,
and SPAROscore reports this as a warning during scoring.

## SparseMatrix
```{r}
```{r smatrix}
# load gene expression data as sparseMatrix
counts_sparse <- as(counts_matrix, "sparseMatrix")

Expand All @@ -164,7 +164,7 @@ them to dense matrices, reducing memory usage and improving computational
efficiency.

## DelayedArrays
```{r}
```{r dmatrix}
# load gene expression data as delayedArray
counts_delayed <- DelayedArray(counts_matrix)

Expand All @@ -180,7 +180,7 @@ Note that the gene ranking is performed natively on the DelayedArray object,
enabling improved computational efficiency.

## Data frame
```{r}
```{r dataframe}
# load gene expression data as delayedArray
counts_df <- as.data.frame(counts_matrix)

Expand All @@ -197,7 +197,7 @@ because matrix operations are more efficient for this step.

### Verify if the output scores are the same with differing input formats

```{r}
```{r check-results}
identical(scores_matrix, scores_sparse)
identical(scores_matrix, scores_delayed)
identical(scores_matrix, scores_df)
Expand All @@ -206,7 +206,7 @@ identical(scores_matrix, scores_df)
# Gene signature representations

## Single signature as a character vector
```{r}
```{r character}
# compute scores from a character vector signature
scores_for_vector <- sparoscore(data = counts_matrix,
signatures = response_genes)
Expand All @@ -217,20 +217,21 @@ scores_for_vector


## Single signature as a GeneSet object
```{r}
```{r geneset}
# get a GeneSet object
response_geneset <- GeneSet(response_genes)

# compute scores from a GeneSet object
scores_for_geneset <- sparoscore(data = counts_sparse,
signatures = response_geneset, prefix = "hello")
signatures = response_geneset,
prefix = "hello")

# view scores
scores_for_geneset
```

## Multiple signatures as a named list
```{r}
```{r list}
# create a named list of vectors to score for both signatures simultaneously
gene_signatures <- list("glucocorticoid_response" = response_genes,
"inflammation_response" = inflammation_genes)
Expand All @@ -244,7 +245,7 @@ scores_for_list
```

## Multiple signatures as a GeneSetCollection object
```{r}
```{r genesetcollection}
# create a GeneSetCollection object to score for both signatures simultaneously
gene_set_collection <- GeneSetCollection(
mapply(function(g, n) GeneSet(unique(g), setName = n),
Expand All @@ -268,7 +269,7 @@ named `ranks`.

In this example, let us work with a SingleCellExperiment object

```{r}
```{r sce}
# convert airways to a SingleCellExperiment object
airway_sce <- as(airway, "SingleCellExperiment")

Expand Down Expand Up @@ -309,7 +310,7 @@ For Seurat objects, after scoring, SPAROscore returns a Seurat object
with the scores and the rank caps appended to the metadata. The ranks are stored
in a layer named `ranks` in the same assay as the counts.

```{r}
```{r seurat}
# convert airway to a seurat object
airway_seurat <- CreateSeuratObject(
counts = assay(airway),
Expand Down Expand Up @@ -364,6 +365,6 @@ For examples of in-depth transcriptomics analyses using SPAROscore, refer here:
For examples of additional options and advanced usage, see:
[Advanced options](sparoscore_advanced_options.html)

```{r}
```{r session-info}
sessionInfo()
```
10 changes: 5 additions & 5 deletions vignettes/sparoscore_getting_started.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ vignette: >
%\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
```{r global-options, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
Expand Down Expand Up @@ -61,7 +61,7 @@ reported in the [original study](https://doi.org/10.1371/journal.pone.0099625).
The expression matrix contains genes in rows and samples in columns.
The accompanying metadata indicates whether each sample received dexamethasone
treatment (trt) or served as an untreated control (untrt).
```{r}
```{r load-dataset}
# load the airway dataset
data(airway)

Expand All @@ -87,7 +87,7 @@ head(signature_genes %in% rownames(counts_data))
```

## Compute signature scores using SPAROscore
```{r}
```{r compute-scores}
scores <- sparoscore(data = counts_data, signatures = signature_genes)

# view the scores
Expand All @@ -99,7 +99,7 @@ scores
Since dexamethasone activates glucocorticoid signalling, treated samples are
expected to exhibit higher glucocorticoid response scores than untreated
controls.
```{r}
```{r visualise-results}
# add the signature scores to the metadata
metadata$SPAROscore <- scores[, 1]

Expand Down Expand Up @@ -159,6 +159,6 @@ For examples of additional options and more advanced usage, see:
[Advanced options](sparoscore_advanced_options.html)


```{r}
```{r session-info}
sessionInfo()
```
Loading
Loading