By defualt, CytoSignal use built-in ligand-receptor interaction database from CellphoneDB V2. However, users can also provide their own ligand-receptor interactions in a user-defined format. This vignette demonstrates how to use user-customized ligand-receptor interactions in CytoSignal.
In this tutorial, we demonstrate how to add three new ligand-receptor
interactions to the CytoSignal object:
Angpt1-Tek, Angpt2-Tek, Angpt2-Itga5_Itgb1. We need to
prepare the following four data frames: 1.
interaction_type: A data frame containing the interaction
IDs and their types. The type can be either “diffusion-dependent” or
“contact-dependent”. 2. ligands: A data frame containing
the interaction IDs and their ligands. The ligands should be in
uppercase. 3. receptors: A data frame containing the
interaction IDs and their receptors. The receptors should be in
uppercase. If there are two receptors, they should be separated by an
underscore “_“. 4. gene_to_uniprot: A data frame containing
the gene names and their corresponding Uniprot IDs. The gene names
should be in uppercase.
library(cytosignal)
random_10_char_id <- function() {
chars <- c(letters, LETTERS, 0:9)
paste0(sample(chars, 10, replace = TRUE), collapse = "")
}
# Adding three new interactions: Angpt1-Tek, Angpt2-Tek, Angpt2-Itga5_Itgb1
n_intr = 3
# Generate random IDs for the new interactions
intr.cpi = paste0("CPI-CC", sapply(1:n_intr, function(x) random_10_char_id()))
# Sample input data
interaction_type <- data.frame(
interaction_id = intr.cpi,
type = c("diffusion-dependent", "contact-dependent", "diffusion-dependent")
)
ligands <- data.frame(
interaction_id = intr.cpi,
L1 = toupper(c("Angpt1", "Angpt2", "Angpt2"))
)
receptors <- data.frame(
interaction_id = intr.cpi,
R1 = toupper(c("Tek", "Tek", "Itga5")),
R2 = toupper(c(NA, NA, "Itgb1"))
)
gene_to_uniprot <- data.frame(
gene_name = toupper(c("Angpt1", "Tek", "Angpt2", "Itga5", "Itgb1")),
uniprot = c("O08538", "B1AWS8", "B9EHQ4", "P11688", "P09055")
)
Next, we can run formatLRDB to format the
ligand-receptor interaction database. The function will return a list of
three data frames: db.diff, db.cont, and
g_to_u. The first two data frames are the ligand-receptor
interaction databases for diffusion-dependent and contact-dependent
interactions, respectively. The third data frame is a mapping from gene
names to Uniprot IDs.
db.list <- formatLRDB(interaction_type, ligands, receptors, gene_to_uniprot)
Next, we can create a demo CytoSignal object using the same Slide-tags data from our default CytoSignal workflow.
## The RDS file will be loaded into a ready-to-use object
dge <- readRDS("SCP2170_annotated_dgCMatrix.rds")
## The cluster annotation need to be presented as a factor object
cluster <- read.csv("SCP2170_cluster.csv")
cluster <- factor(cluster$cell_type)
names(cluster) <- colnames(dge)
## The spatial coordinates need to be presented as a matrix object
spatial <- as.matrix(read.csv("SCP2170_spatial.csv", row.names = 1))
## Please make sure that the dimension names are lower case "x" and "y"
colnames(spatial) <- c("x", "y")
Then a CytoSignal object can be created with new ligand-receptor interaction databased we just created.
cs <- createCytoSignal(raw.data = dge, cells.loc = spatial, clusters = cluster)
cs <- addIntrDB(cs, gene_to_uniprot, db.list$db.diff, db.list$db.cont, db.list$intr.index)