% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/CatsCradleLigandReceptorAnalysis.R
\name{performLigandReceptorAnalysis}
\alias{performLigandReceptorAnalysis}
\title{Given a seurat object, a spatial graph, clusters and
species this function identifies ligand-receptor
interactions between neighbouring cells, identifies
ligand-receptor interactions within and between clusters
and calculates whether these are observed more frequently
than expected by chance.}
\usage{
performLigandReceptorAnalysis(
  obj,
  spatialGraph,
  species,
  clusters,
  nSim = 1000,
  lrn = getLigandReceptorNetwork(species),
  verbose = TRUE
)
}
\arguments{
\item{obj}{\itemize{
\item a Seurat object
}}

\item{spatialGraph}{\itemize{
\item a data frame of neighbouring
cell pairs.
}}

\item{species}{\itemize{
\item either 'human' or 'mouse'
}}

\item{clusters}{\itemize{
\item named vector of clusters where names are each cell and
clusters are a factor
}}

\item{nSim}{\itemize{
\item number of simulations to perform for p value calculation.
}}

\item{lrn}{\itemize{
\item a ligand-receptor network, i.e., a
data frame with columns from and to.  By default, it
retrieves the nichenetr ligand receptor network
}}

\item{verbose}{\itemize{
\item whether to print trace, defaults to TRUE
}}
}
\value{
A list containing:
interactionsOnEdges - a data frame whose first two columns give
the neighbouring cells and next two columns give their corresponding
clusters. Each of the remaining columns is a logical
corresponding to a ligand-receptor pair telling whether the ligand
is expressed in the first cell and the receptor is expressed in the
second cell.
totalInteractionsByCluster - a dataframe where the first column gives a
directed (sender-receiver) pair of clusters. The second column gives the
total number of edges between those clusters. The remaining columns give the
total numbers of edges on which particular ligand receptor interactions are
present.
meanInteractionsByCluster - a dataframe where the first column gives a
directed (sender-receiver) pair of clusters. The second column gives the
total number of edges between those clusters. The remaining columns give the
total numbers of edges on which particular ligand receptor interactions are
present (for that cluster pair) divided by the total number of edges between
those clusters.
simResults - a dataframe where the rownames are sender-receiver cluster pairs
and column names are ligand receptor pairs. Values give the number of
simulations for which observed values are greater than simulated values.
pValues - a dataframe where the rownames are sender-receiver cluster pairs
and column names are ligand receptor pairs. Entries are uppertail pvalues
describing whether a particular ligand receptor interaction is observed more
frequently between 2 clusters than expected.
}
\description{
Given a seurat object, a spatial graph, clusters and
species this function identifies ligand-receptor
interactions between neighbouring cells, identifies
ligand-receptor interactions within and between clusters
and calculates whether these are observed more frequently
than expected by chance.
}
\examples{
getExample = make.getExample()
smallXenium = getExample('smallXenium')
delaunayNeighbours = getExample('delaunayNeighbours')
clusters = getExample('clusters')
performLigandReceptorAnalysis(smallXenium, delaunayNeighbours, 
                                      "mouse", clusters, nSim = 10,
                                       verbose=FALSE)
}
