knitr::opts_chunk$set(
    collapse = TRUE,
    comment = "#>",
    crop = NULL 
)
## Track time spent on making the vignette
startTime <- Sys.time()

Introduction

Cell-type-specific Spatially Variable gene detection, or CTSV, is an R package for identifying cell-type-specific spatially variable genes in bulk sptial transcriptomics data. In this Vignette, we will introduce a standard workflow of CTSV. By utilizing single-cell RNA sequencing data as reference, we got cell type proportions in each spot. Then we take the cell type proportion, location coordinates and spatial expression data as input to CTSV.

Usage guide

Install CTSV

r Biocpkg("CTSV") is an R package available via the Bioconductor repository for packages. It requires installing the R open source statistical programming language, which can be accessed on any operating system from CRAN. After which you can install r Biocpkg("CTSV") by using the following commands in your R session:

if (!requireNamespace("BiocManager", quietly = TRUE)) {
      install.packages("BiocManager")
  }

BiocManager::install("CTSV")

## Check that you have a valid Bioconductor installation
BiocManager::valid()

If there are any issues with the installation procedure or package features, the best place would be to file an issue at the GitHub repository.

Load example data

In order to run RCTD, the first step is to get cell-type proportions. There are some deconvolution methods such as RCTD, SPOTlight and SpatialDWLS. We provide an example data including observed raw count bulk ST data, location coordinate matrix, cell-type proportion matrix and the true SV gene patterns.

suppressPackageStartupMessages(library(CTSV))
suppressPackageStartupMessages(library(SpatialExperiment))
data("CTSVexample_data", package="CTSV")
spe <- CTSVexample_data[[1]]
W <- CTSVexample_data[[2]]
gamma_true <- CTSVexample_data[[3]]
Y <- assay(spe)
# dimension of bulk ST data
dim(Y)
# dimension of cell-type proportion matrix:
dim(W)
# SV genes in each cell type:
colnames(Y)[which(gamma_true[,1] == 1)]
colnames(Y)[which(gamma_true[,2] == 1)]
# Number of SV genes at the aggregated level:
sum(rowSums(gamma_true)>0)

Running CTSV

We are now ready to run CTSV on the bulk ST data using ctsv function.

result <- CTSV(spe,W,num_core = 8)

CTSV results

The results of CTSV are located in a list.

# View on q-value matrix
head(result$qval)

Then we want to extra SV genes with an FDR level at 0.05 using SVGene function. We regard the q-value matrix return by CTSVPval and an threhold of 0.05 as input. The result of the SVGene is a list containing two elements, the first of which is a $G\times 2K$ 0-1 matrix indicating SV genes in each cell type and axis.

re <- svGene(result$qval,0.05)
# SV genes in each cell type:
re$SVGene

Session information

sessionInfo()


jingeyu/CTSV documentation built on July 11, 2022, 4:54 a.m.