# This package provides methods for analysing spatial transcriptomics data and for discovering gene clusters

## Documentation for package ‘CatsCradle’ version 1.0.0

- DESCRIPTION file.
- User guides, package vignettes and other documentation.
- Package NEWS.

## Help Pages

aggregateFeatureMatrix | This function takes a matrix where rows are features and columns are cells, and a neighbourhood list, and creates an matrix where columns are the neighbourhoods, the rows are are the features and the values are aggregated expression values for cells in each neighbourhood.
aggregateGeneExpression | This function takes a Seurat object and a list of neighbourhoods and creates a Seurat object where the columns are the neighbourhoods, the rows are are the genes and the values are gene expression totals for the cells in each neighbourhood
annotateGeneAsVector | This function returns a numeric indicating which gene sets it does and does not belong to. This vector can be normalised to account for the sizes of the sets.
annotateGenesByGeneSet | This function annotates genes with terms
annotateLRInteractionCounts | This takes a data frame of interaction counts as found by countLRInteractionsPerCell(), the underlying Seurat object and the neighbourhood Seurat object and annotates the counts with the cell type and the neighbourhood type corresponding to the cells of the interaction counts.
cellTypesPerCellTypeGraphFromCellMatrix | This function converts a matrix as found by cellTypesPerCellTypeMatrix into a directed igraph whose vertices correspond to seurat_clusters and whose edge correspond to occupancy fraction.
cellTypesPerCellTypeGraphFromNbhdMatrix | This function takes a neighbourhood-by-cell type matrix and produces a directed igraph showing the fractions of cells of each type in the neighbourhoods around cells of each type.
collapseExtendedNBHDs | This function takes an expanded neighbourhood list and collapses it to a nearest neighbourhood graph where all neighbours of degree <= n in the original graph are considered first neighbours.
combinatorialSpheres | Discovers the combinatorial ball of a given radius around a fixed set of genes in the nearest neighbor graph of a Seurat object.
computeCellTypesPerCellTypeMatrix | For each cell type, this function looks at the neighbourhoods around cells of that type and discovers the fractions of those cells of each type.
computeEdgeGraph | This function takes a spatial graph and computes a new spatial graph where edges become nodes and A-B edges (in the original graph) become connected to all A- edges and all B- edges.
computeEdgeObject | This function takes interactionResults and creates a seurat object where each point represents an edge between cells, and spatial coordinates are the centroids of edges between cells. The "expression matrix" is the binarised presence/absence of an interaction (ligand receptor pair) on an edge.
computeGraphEmbedding | This function adds a force directed graph embedding to a seurat object
computeMoransI | This function takes a matrix where rows are features and columns are cells, and a neighbourhood list, and computes Moran's I.
computeNBHDByCTMatrix | This function computes a matrix where neighbourhoods are rows and cell types are columns. The values in the matrix indicate the number of cells of a given type within a neighbourhood.
computeNBHDVsCTObject | This function creates a seurat object using a neighbourhood by cell type matrix
computeNeighbourEnrichment | This function calculates P values for whether cell types are more frequently neighbours than expected by chance. It does this by comparison to randomised neighbour graphs where edges are randomised but the degree of each node is preserved.
computeNeighboursDelaunay | This function computes a spatial graph where neighbors are identified based on Delaunay triangulation.
computeNeighboursEuclidean | This function computes a spatial graph where neighbors are identified based on euclidean distance and a user defined threshold.
countLRInteractionsPerCell | This function takes a listing of the neighbouring cells together with the presence or absence of each ligand-receptor pair on each edge and produces a count showing for each cell, how many neighbours it has with that interaction either as source or as target
cullEdges | This subsets edges by our chosen critera
desymmetriseNN | This function takes the data frame of neighbor genes and reduces it so that each undirected edge is represented by only one directed edge. This ensures that randomisation does not magically split undirected edges into two edges.
directedHausdorfDistance | This finds the directed Hausdorf distance from A to B
edgeCutoffsByClustering | This finds proposed cutoffs for edge lengths by clustering the lengths of the edges for each cell type pair using k-means clustering with k = 2
edgeCutoffsByPercentile | This finds edge cutoffs by percentile
edgeCutoffsByWatershed | This finds proposed cutoffs for edge lengths by computing the histogram of edge lengths for each cell type pair and then using the watershed algorithm to find the hump of the histogram containing the median.
edgeCutoffsByZScore | This finds edge cutoffs by z-score
edgeLengthPlot | edgeLengthPlot
edgeLengthsAndCellTypePairs | This function annotates edges with their distance and the types of cells they connect
exampleObjects | This returns the names of available example objects.
exSeuratObj | exSeuratObj
geneSetsVsGeneClustersPValueMatrix | This compares the gene clusters to other gene sets e.g., GO, Hallmark, and determines the p-value for their overlaps when compared to a set of background genes.
getAverageExpressionDF | This converts an average gene expression matrix to a data frame.
getAverageExpressionMatrix | This computes average expression of each gene cluster in each cell cluster and returns the result as a matrix
getBinarisedMatrix | This functions retrieves an expression matrix from a seurat object or SingleCellExperiment and binarises it.
getClusterOrder | This gets the clusters in their cannonical order
getExtendedNBHDs | This function takes a nearest neighbour graph and a radius and calculates nth degree neighbour graphs where max(n) == radius
getFeatureZScores | This gets z-scores for the values of features
getGeneClusterAveragesPerCell | This produces a matrix giving the average expression of gene clusters in cells. By default, it uses all cells and all gene clusters.
getGeneNeighbors | This function gets the neighbors of a given gene using either the gene Seurat object or its nearest neighbor graph returned from getNearestNeighbourLists
getInteractionsOnEdges | This function takes a binarised expression matrix, a set of ligand receptor pairs and a set of edges denoting neighbouring cells and annotates these with the ligand receptor interactions taking place on those edges in each direction.
getLigandReceptorNetwork | This function retrieves the Nichenetr ligand- receptor network for mouse or human.
getLigandReceptorPairsInPanel | This functions takes an Seurat object, its species and a ligand receptor network and subsets the ligand receptor network to those pairs that occur in the panel
getNearbyGenes | Nearby genes
getNearestNeighbourLists | This function extracts a shared nearest neighbor network from a Seurat object
getObjectSubsetClusteringPValue | This function computes a p-value for the geometric clustering of a gene set (in UMAP or PCA reduction) based on the median distance from its complement to the set.
getObjectSubsetClusteringStatistics | This function computes statistics for the geometric clustering of a gene set (in UMAP or PCA reduction) based on the median distance from its complement to the set.
humanLRN | humanLRN
ligandReceptorResults | ligandReceptorResults
make.getExample | This function makes the function whichretrieves and makes example data objects.
makeLRInteractionHeatmap | This function takes ligandReceptorResults and plots a heatmap of -log10(pvalues).
makeSummedLRInteractionHeatmap | This function takes ligandReceptorResults and plots a heatmap of the total number of ligand receptor interactions between clusters.
meanGeneClusterOnCellUMAP | Mean gene cluster on cell umap
meanZPerCluster | This finds the mean z-score for features in subsets of cells e.g., in each of the seurat_clusters
meanZPerClusterOnUMAP | This collects together mean z-score data together with UMAP coordinates from the gene seurat object for plotting.
medianComplementDistance | This takes a set S of n points in dimension d given by an n x d matrix and a subset A given by a logical and returns the median distance from the complement to the given subset.
medianComplementPValue | This takes a set S of n points in dimension d and a subset A and computes a p-value for the co-localization of the subset by comparing the median complement distance for the given set to values of the median complement distance computed for random subsets of the same size.
moransI | moransI
moransILigandReceptor | moransILigandReceptor
mouseLRN | mouseLRN
nbhdsAsEdgesToNbhdsAsList | nbhdsAsEdgesToNbhdsAsList
neighbourhoodDiameter | neighbourhoodDiameter
orderGeneSetPValues | This orders the gene set p-values (or -log10 p-values) and applies a cutoff (if given) to show only the significant gene sets for each gene cluster
performLigandReceptorAnalysis | 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.
permuteMatrix | This function permutes the rows of a matrix.
predictAnnotation | This function makes annotation predictions for a set of genes based on gene sets (e.g., hallmark) and a CatsCradle object by considering the annotations of its neighboring genes.
predictAnnotationAllGenes | This function predicts the functions of all genes based on the functions of their neighbours.
predictGeneAnnotationImpl | This function is the implementation for predicting the functions of a gene based on the functions of its neighbours.
randomiseGraph | This function performs degree-preserving randomisation of neighbour graphs.
randomiseNodeIndices | This function generates random indices for node B
readGmt | This function reads in gene sets in .gmt format
runGeometricClusteringTrials | This runs random trials to determine the statistical significance of the clustering of a set of points within a larger set.
runMoransI | This function takes a matrix where rows are features and columns are cells, and a neighbourhood list, and computes Moran's I.
sankeyFromMatrix | This makes a sankey graph from a matrix of average expression. Our "Cat's Cradle".
seuratCells | seuratCells
seuratGenes | seuratGenes
smallXenium | smallXenium
stripGeneSet | This function strips out non-gene information from the beginning of GO sets, etc.
symmetriseNN | This symmetrises a nearest neighbors graph.
symmetryCheckNN | Tests whether a nearest neighbor graph is symmetric
tagRowAndColNames | This gussies up the rownames and colnames of M
transposeObject | Create the transpose of a Seurat object
xeniumCells | xeniumCells