Title: | What the Package Does (One Line, Title Case) |
---|---|
Description: | What the package does (one paragraph). |
Authors: | Jialin Liu [aut, cre], Yichen Wang [aut] |
Maintainer: | Jialin Liu <[email protected]> |
License: | GPL (>= 3) |
Version: | 0.2.0 |
Built: | 2024-11-19 06:16:52 UTC |
Source: | https://github.com/welch-lab/cytosignal |
#' Compute the LR velo for specific ligand-receptor imputation obj pairs #' #' @param object A Cytosignal object #' @param lig.slot The ligand slot to use #' @param recep.slot The receptor slot to use #' @param intr.db.name The intr database name to use #' @param nn.use The neighbor index as niche #' #' @return A Cytosignal object #' @export #' inferVeloLR <- function( object, ... ) UseMethod(generic = 'inferVeloLR', object = object)
.inferVeloLR.matrix_like( dge.lig, dge.recep, dge.lig.velo, dge.recep.velo, lig.fac, recep.fac )
.inferVeloLR.matrix_like( dge.lig, dge.recep, dge.lig.velo, dge.recep.velo, lig.fac, recep.fac )
Fast expression for getting and setting metadata variables in a mergedCytoSignal object.
## S3 method for class 'mergedCytoSignal' x$name ## S3 replacement method for class 'mergedCytoSignal' x$name <- value
## S3 method for class 'mergedCytoSignal' x$name ## S3 replacement method for class 'mergedCytoSignal' x$name <- value
Add interaction database to CytoSignal object
addIntrDB( object, gene_to_uniprot, intr.db.diff_dep, intr.db.cont_dep, inter.index )
addIntrDB( object, gene_to_uniprot, intr.db.diff_dep, intr.db.cont_dep, inter.index )
object |
CytoSignal object |
gene_to_uniprot |
df, gene to uniprot symbols mapping |
intr.db.diff_dep |
intr.db for diffusable ligands + non-diffusable receptors |
intr.db.cont_dep |
intr.db for contact dependent ligands + receptors |
inter.index |
df, collection of intraction information |
a CytoSignal object
Add velocity data to CytoSignal object
addVelo(object, velo.s, velo.u)
addVelo(object, velo.s, velo.u)
object |
CytoSignal object |
velo.s |
matrix of spliced velo |
velo.u |
matrix of unspliced velo |
Subset genes to those available in g_to_u
, the gene name to
UNIPROT ID databse provided with addIntrDB
changeUniprot(object, ...) ## S3 method for class 'matrix_like' changeUniprot(object, gene_to_uniprot, verbose = TRUE, ...) ## S3 method for class 'CytoSignal' changeUniprot(object, verbose = TRUE, ...)
changeUniprot(object, ...) ## S3 method for class 'matrix_like' changeUniprot(object, gene_to_uniprot, verbose = TRUE, ...) ## S3 method for class 'CytoSignal' changeUniprot(object, verbose = TRUE, ...)
object |
A CytoSignal object or a matrix. |
... |
Parameters passed to S3 methods. |
gene_to_uniprot |
Please use |
verbose |
Whether to show information of the progress. |
CytoSignal object with subset matrix updated in counts
slot,
or the subset matrix.
Create a CytoSignal object
createCytoSignal( raw.data, cells.loc, clusters = NULL, name = NULL, parameters = NULL, log = NULL )
createCytoSignal( raw.data, cells.loc, clusters = NULL, name = NULL, parameters = NULL, log = NULL )
raw.data |
raw data matrix |
cells.loc |
cells location matrix |
clusters |
cluster information |
name |
name of the dataset |
parameters |
parameters used |
log |
log of the processing |
a CytoSignal object
The CytoSignal object is created from one spatial transcriptomic dataset. A
CytoSignal object can be created with createCytoSignal
.
counts
Raw gene expression count matrix, sparse dgCMatrix, gene x cell.
cell.loc
Matrix of cell locations, cell by axis.
clusters
cluster assignments, named factor.
imputation
List of imputation objects.
lrscore
List of lrScore objects.
velo
List of velo objects.
intr.valid
List of interaction database. Added with
addIntrDB
.
cell.data
data.frame of cell data.
parameters
List of parameters for gaussian imputation
log
Log of each main steps
version
Version of package used to create object. Should not be modified by users.
The referencing database that contains the list of curated interactions, the
meta-information of each interaction, the ligand and receptor of each
interaction, the protein components of both part of each interaction. The
protein components are presented with UNIPROT ID, so we also provide
g_to_u
that maps UNIPROT ID to gene names.
db.diff db.cont inter.index g_to_u
db.diff db.cont inter.index g_to_u
db.diff
and db.cont
are lists of factor objects.
db.diff
is for diffusion dependent interactions and db.cont
is
for contact dependent interactions. Both lists have the following three
entries of the same format:
$ligands
- A factor object where the values are IDs of
interactions and names are UNIPROT IDs of the ligand protein components that
match to the interaction.
$receptors
- A factor object of the same format as
$ligands
but for the receptor part of the interactions.
$combined
- The concatenation of the two factors above.
inter.index
is a data.frame object with the meta-information of each
interaction.
g_to_u
is a data.frame object that map gene names to UNIPROT ID of
their protein product.
An object of class list
of length 3.
An object of class data.frame
with 1396 rows and 11 columns.
An object of class data.frame
with 977 rows and 3 columns.
CellphoneDB V2
Only returns nrow(x) which indicates the number of spots/cells
## S3 method for class 'mergedCytoSignal' dim(x)
## S3 method for class 'mergedCytoSignal' dim(x)
x |
A mergedCytoSignal object |
A numeric vector with the number of spots/cells and NA
This is a wrapper function of findNNGauEB
,
findNNDT
and findNNRaw
. We use a Gaussian Epsilon
ball to identify the nearest neighbors that can contribute to the diffusible
ligands. And then uses a Delaunay triangulation to identify the nearest
neighbors that can contribute to the contact-dependent ligands. The
identified nearest neighbors will then be used for imputing the or
value for each location.
findNN( object, eps = NULL, sigma = NULL, diff.weight = "auto", dt.weight = 2, max.r = NULL )
findNN( object, eps = NULL, sigma = NULL, diff.weight = "auto", dt.weight = 2, max.r = NULL )
object |
A CytoSignal object. |
eps |
Gaussian Epsilon Ball method parameter. A numeric scalar. The
radius of the Gaussian Epsilon ball. Default |
sigma |
Gaussian Epsilon Ball method parameter. The |
max.r |
Delaunay Triangulation method parameter. A numeric scalar for
the maximum radius of the edges. Default |
self.weight |
Gaussian Epsilon Ball method parameter. Weight of the
index cell. Use a number between 0-1 or a string |
weight |
Delaunay Triangulation method parameter. A numeric scalar for
the sum of the weights of the edges of the Delaunay Triangulation. Default
|
A CytoSignal object updated. object@imputation
slot will be updated with three new entries: object@imputation$GauEps
,
object@imputation$DT
and object@imputation$Raw
.
## Not run: object <- findNN(object) ## End(Not run)
## Not run: object <- findNN(object) ## End(Not run)
Find the direct connected neighbor of each cell, using Delaunay triangulation
findNNDT(object, ...) ## S3 method for class 'matrix' findNNDT(object, weight.sum = 2, max.r = NULL, ...) ## S3 method for class 'CytoSignal' findNNDT(object, weight = 2, max.r = NULL, ...)
findNNDT(object, ...) ## S3 method for class 'matrix' findNNDT(object, weight.sum = 2, max.r = NULL, ...) ## S3 method for class 'CytoSignal' findNNDT(object, weight = 2, max.r = NULL, ...)
object |
A CytoSignal object or a matrix of cell location. |
... |
Arguments passed to other S3 methods |
weight.sum |
The sum of the weights |
max.r |
The maximum radius of the edges, by default is the r.diffuse.scale, |
For CytoSignal object, the original object with result updated. For matrix object, a list of neighbors.
Find the neighbors of each cell in the Epsilon Ball
findNNGauEB(object, eps = NULL, sigma = NULL, self.weight = "auto", ...) ## S3 method for class 'matrix' findNNGauEB(object, eps, sigma = 0.15, self.weight = "auto", ...) ## S3 method for class 'CytoSignal' findNNGauEB( object, eps = NULL, sigma = NULL, self.weight = "auto", tag = NULL, ... )
findNNGauEB(object, eps = NULL, sigma = NULL, self.weight = "auto", ...) ## S3 method for class 'matrix' findNNGauEB(object, eps, sigma = 0.15, self.weight = "auto", ...) ## S3 method for class 'CytoSignal' findNNGauEB( object, eps = NULL, sigma = NULL, self.weight = "auto", tag = NULL, ... )
object |
A CytoSignal object or a matrix object for the cell spatial location. |
eps |
The radius of the epsilon ball. For CytoSignal object, by default
use parameter inferred with |
sigma |
The sigma of the Gaussian kernel. Default |
self.weight |
weight of the index cell. Use a number between 0-1, or
choose from |
... |
Arguments passed to other S3 methods. |
tag |
Name prefix of the analysis. |
For CytoSignal object, the orignal object with result updated. For matrix object, a list of neighbors and their distances.
Create a ImpData object using raw data without imputation
findNNRaw(object)
findNNRaw(object)
object |
A Cytosignal object |
A Cytosignal object
Format a CytosignalIntrDEG object to string
## S3 method for class 'CytosignalIntrDEG' format(x, ...)
## S3 method for class 'CytosignalIntrDEG' format(x, ...)
x |
A |
... |
Passed to other methods |
A string representation of the object
Compute the LR score for specific ligand-receptor imputation obj pairs
graphNicheLR(object, ...)
graphNicheLR(object, ...)
object |
A Cytosignal object |
lig.slot |
The ligand slot to use |
recep.slot |
The receptor slot to use |
intr.db.name |
The intr database name to use |
nn.use |
The neighbor index as niche |
A Cytosignal object
Sub function for graphNicheLR, input a CytoSignal object
Sub function for graphNicheLR, input a CytoSignal object
## S3 method for class 'CytoSignal' graphNicheLR(object, lig.slot, recep.slot, intr.db.name, nn.use = NULL) ## S3 method for class 'CytoSignal' graphNicheLR(object, lig.slot, recep.slot, intr.db.name, nn.use = NULL)
## S3 method for class 'CytoSignal' graphNicheLR(object, lig.slot, recep.slot, intr.db.name, nn.use = NULL) ## S3 method for class 'CytoSignal' graphNicheLR(object, lig.slot, recep.slot, intr.db.name, nn.use = NULL)
object |
A Cytosignal object |
lig.slot |
The ligand slot to use |
recep.slot |
The receptor slot to use |
intr.db.name |
The intr database name to use |
nn.use |
slot that the neighbor index should be taken from, by default is the same as the recep.slot. For example, if score.obj = GauEps-DT, then nn.use = "DT". nn.use could also be a user-defind factor. |
A Cytosignal object
A Cytosignal object
Sub function for graphNicheLR, input a sparse matrix
## S3 method for class 'dgCMatrix' graphNicheLR(dge.lig, dge.recep, nb.id.fac, lig.fac, recep.fac)
## S3 method for class 'dgCMatrix' graphNicheLR(dge.lig, dge.recep, nb.id.fac, lig.fac, recep.fac)
dge.lig |
A sparse matrix for ligand |
dge.recep |
A sparse matrix for receptor |
nb.id.fac |
A factor of neighbor indices |
lig.fac |
A factor of ligand indices |
recep.fac |
A factor of receptor indices |
A sparse matrix
Create a heatmap for an interaction on GO terms by significant genes, colored
by the coefficients of the genes in the regression model returned by
inferIntrDEG
. The GO term enrichment can be done with any tools
available. The input data.frame GO
must contain fields for 1. term
description, character, pointed to by description.col
, 2. p-value,
numeric, pointed to by pval.col
, 3. gene hit string, character,
pointed to by gene.col
. The gene hit string for each term must be form
in a way that function gene.split.fun
can split it into a character
vector of gene names. For example, if a gene hit string is "gene1, gene2, gene3",
then gene.split.fun
should be function(x) unlist(strsplit(x, ", "))
,
so that a split result c("gene1", "gene2", "gene3")
can be correctly
obtained.
heatmap_GO( intrDEG, GO, intr, description.col = "description", pval.col = "pval", gene.col = "genes", gene.split.fun = function(x) unlist(strsplit(x, ",")), term.topN = 20, gene.topN = 20, binary_sign = FALSE, text.size = 10 )
heatmap_GO( intrDEG, GO, intr, description.col = "description", pval.col = "pval", gene.col = "genes", gene.split.fun = function(x) unlist(strsplit(x, ",")), term.topN = 20, gene.topN = 20, binary_sign = FALSE, text.size = 10 )
intrDEG |
A |
GO |
A data.frame object for GO enrichment analysis result. |
intr |
A single interaction ID (starts with "CPI") or its numeric index
within the range of |
description.col , pval.col , gene.col
|
The column names of the data.frame
|
term.topN |
Use this number of top GO terms, ranked by p-values. Default
|
gene.topN |
Use this number of top genes, ranked by absolute value of
coefficients. Default |
binary_sign |
Whether to convert coefficient value to binary sign value.
Default |
color_num |
Number of colors in the heatmap. Can only use |
These functions implement aesthetic mapping to hexagon size (area), in addition to the existing colour-mapping functionality. The key change is the addition of a new fourth variable (var4) to hex_bin(), which complements the inbuilt hexagon binning functionality. The 'frequency.to.area' argument enables the default mappings of binned data to colour and var4 to size to be interchanged. The hmin/hmax arguments 0,1 set area mapping constraints (hmax can exceed 1). xlim/xlat enable hexagon tesselation to be constrained independently of data range. There may be some bugs in the implementation. A legend for hexagon size has not been implemented. Bin data into hexagons (2d).
hex_bin( x, y, weight = NULL, var4 = NULL, width = NULL, height = NULL, xbins = 20, ybins = 20, var4.to.color = FALSE, na.rm = FALSE, hmin = 0, hmax = 1, xlim = NULL, ylim = NULL, ... )
hex_bin( x, y, weight = NULL, var4 = NULL, width = NULL, height = NULL, xbins = 20, ybins = 20, var4.to.color = FALSE, na.rm = FALSE, hmin = 0, hmax = 1, xlim = NULL, ylim = NULL, ... )
x |
a numeric vector of x positions |
y |
a numeric vector of y positions |
weight |
|
var4 |
|
width |
width of each hexagon, if |
height |
height of each hexagon, if |
xbins |
number of horizontal bins, if |
ybins |
number of vertical bins, if |
na.rm |
If |
A data frame with columns x
, y
and freq
,
and attributes width
and height
.
hex_pos
for algorithm that finds hexagon center
closest to each point and hex_coord
that generates
coordinates of each hexagon.
plot(hex_bin(runif(1e4), runif(1e4))) plot(hex_bin(rnorm(1e4), rnorm(1e4))) data(baseball, package = "plyr") bin <- hex_bin(baseball$g, baseball$ab)
plot(hex_bin(runif(1e4), runif(1e4))) plot(hex_bin(rnorm(1e4), rnorm(1e4))) data(baseball, package = "plyr") bin <- hex_bin(baseball$g, baseball$ab)
The ImpData object is created from one ST dataset. User could choose a preferred imputation method and the class stores the imputed data, the imputed normalized data, the intr database, the intr database.
The key slots used in the ImpData object are described below.
method
imputation method
imp.data
imputed data
imp.norm.data
imputed normalized data
intr.data
imputed normalized data subsetted by intr database
intr.data.null
permuted imputed normalized data subsetted by intr database
nn.id
nearest neighbor id
nn.dist
nearest neighbor distance
log
Log of each main steps
or
value from the nearest neighbors of each
locationAfter running findNN
, we can impute the or
value from the nearest neighbors of each location basing on the types of
nearest neighbors.
imputeLR(object, weights = c("none", "mean", "counts", "dist"))
imputeLR(object, weights = c("none", "mean", "counts", "dist"))
object |
A CytoSignal object, with |
weights |
The method to transform distances to weights. Choose from |
A CytoSignal object updated. Entries in
object@imputation
slot will be updated with the imputation values.
## Not run: object <- findNN(object) object <- imputeLR(object) ## End(Not run)
## Not run: object <- findNN(object) object <- imputeLR(object) ## End(Not run)
Impute the data
imputeNiche(object, weights = c("mean", "counts", "dist", "none"), ...) ## S3 method for class 'dgCMatrix' imputeNiche( object, nb.id.fac, nb.dist.fac, weights = c("mean", "counts", "dist", "none"), ... ) ## S3 method for class 'CytoSignal' imputeNiche( object, nn.type = NULL, weights = c("mean", "counts", "dist", "none"), ... )
imputeNiche(object, weights = c("mean", "counts", "dist", "none"), ...) ## S3 method for class 'dgCMatrix' imputeNiche( object, nb.id.fac, nb.dist.fac, weights = c("mean", "counts", "dist", "none"), ... ) ## S3 method for class 'CytoSignal' imputeNiche( object, nn.type = NULL, weights = c("mean", "counts", "dist", "none"), ... )
object |
A Cytosignal object or a dgCMatrix object of raw gene expression matrix |
weights |
The weight of the Delaunay triangulation. Choose from
|
... |
Arguments passed to other S3 methods |
nb.id.fac |
A factor of neighbors |
nb.dist.fac |
A factor of weights |
nn.type |
The type of neighbors. The |
For CytoSignal object, the original object with imputation result updated. For dgCMatrix object, a sparse N x N graph presented as another dgCMatrix object.
Impute the velocity mtx using the specified method
imputeNicheVelo(object, ...)
imputeNicheVelo(object, ...)
object |
A Cytosignal object |
... |
Other parameters |
method |
The method to use for imputation |
A Cytosignal object
Sub function for imputeNicheVelo, input a Cytosignal object
## S3 method for class 'CytoSignal' imputeNicheVelo(object, nn.type = NULL)
## S3 method for class 'CytoSignal' imputeNicheVelo(object, nn.type = NULL)
object |
A Cytosignal object |
nn.type |
The type of neighbors |
A Cytosignal object
or
from the nearest neighbors of
each locationAfter running findNN
, we can impute the temporal or
change from the nearest neighbors of each location basing on the
types of nearest neighbors.
imputeVeloLR(object)
imputeVeloLR(object)
object |
A CytoSignal object, with |
A CytoSignal object updated. Entries in
object@imputation
slot will be updated with the imputation values.
## Not run: object <- findNN(object) object <- imputeVeloLR(object) ## End(Not run)
## Not run: object <- findNN(object) object <- imputeVeloLR(object) ## End(Not run)
Min-max the LRscores, substract the significant ones, sum and average.
inferCorrScore(object, correctBy = c("cell", "intr"), slot.use = NULL)
inferCorrScore(object, correctBy = c("cell", "intr"), slot.use = NULL)
object |
A Cytosignal object |
correctBy |
Spatial FDR correction method. Choose from |
slot.use |
Which LR score to use. Use the name specified with |
A Cytosignal object
Infer the parameters of the Gaussian kernel
inferEpsParams(object, scale.factor = NULL, r.eps.real = 200, thresh = 0.001)
inferEpsParams(object, scale.factor = NULL, r.eps.real = 200, thresh = 0.001)
object |
A Cytosignal object |
r.eps.real |
The radius of the epsilon ball in tech resolution in um, default 200 um |
thresh |
The total signal out of the epsilon ball |
scale.facor |
1 spatial coord unit equals to how many µm |
A Cytosignal object
This function performs wilcoxon one-sided test for each cell type, between cells enriched with an interaction against other cells. The top significant genes are selected for each interaction. The expression profile of the selected genes, together with the cell type variable, are then feeded into a regression model for further refinement. This analysis infers the significant genes for each interaction, and refines the LRScore using the selected genes.
inferIntrDEG( object, intr = NULL, slot.use = NULL, signif.use = NULL, num.per.choose = 50, alpha.test = seq(0.5, 1, 0.1), seed = 1, minCell = 50, verbose = TRUE )
inferIntrDEG( object, intr = NULL, slot.use = NULL, signif.use = NULL, num.per.choose = 50, alpha.test = seq(0.5, 1, 0.1), seed = 1, minCell = 50, verbose = TRUE )
object |
A |
intr |
Specify interactions to be used. A vector of either the unique
ID of interactions or the numeric rank indices. Available IDs can be shown
with |
slot.use |
The LRscore type to be used. See vignette for explanation. |
signif.use |
The significance metric to be used. See vignette for explanation. |
num.per.choose |
The maximum number of genes to be chosen for each
wilcoxon test. A test happens for each interaction and each cell type.
Default |
alpha.test |
A sequence of alpha values to be tested for the elastic net
regression model. The best alpha value will be chosen based on the smallest
loss. Larger alpha values result in less final selection. Default
|
seed |
Random seed for controlling the cross validation. Default
|
minCell |
Minimum number of cells where a gene is expressed to be
considered. Default |
verbose |
Whether to print progress messages. Default |
list object, each element is the result for each interaction. Each interaction result is a list object containing the following entries:
glmnet_model
- A "cv.glmnet" object, the regression model.
score_refine
- A 1-column matrix of refined LR scores of this
interaction in each cell.
coef
- A matrix of coefficients of the regression model.
sign_clusters
- A character vector of significant clusters in
selected by the model.
sign_genes
- A character vector of significant genes selected by
the model.
alpha
- The alpha value used for the final chosen model.
slot.use
- The LRScore type used for this analysis.
signif.use
- The significance metric used for this analysis.
After running imputeLR
, we can calculate the LR score for each
location. The LR score is calculated as the product of the imputed
and
values. With the LR score inferred, we subsequently perform
permutation tests to construct the null distribution for testing the
significance of the interactions.
inferIntrScore( object, recep.smooth = FALSE, intr.type = c("diff", "cont"), perm.size = 1e+05, norm.method = c("default", "cpm", "none", "scanpy"), numCores = 1 )
inferIntrScore( object, recep.smooth = FALSE, intr.type = c("diff", "cont"), perm.size = 1e+05, norm.method = c("default", "cpm", "none", "scanpy"), numCores = 1 )
object |
A CytoSignal object, with |
recep.smooth |
A logical scalar. Whether to use the smoothed |
intr.type |
A character vector. The type of interactions to calculate
the LR score. Choose from one or both of |
perm.size |
A numeric scalar. The number of permutations to perform.
Default |
norm.method |
The normalization method to apply to the imputed L and R |
numCores |
SPARK::sparkx parameter. The number of cores to use. Default
|
A CytoSignal object updated. Entries in
object@lrscore
slot will be updated with the LR scores and the
significance inferrence. When recep.smooth
is by default FALSE
,
the object@lrscore
slot will be updated with
object@lrscore$`GauEps-Raw`
and object@lrscore$`DT-Raw`
. When
recep.smooth
is TRUE
, the object@lrscore
slot will be
updated with object@lrscore$`GauEps-DT`
and
object@lrscore$`DT-DT`
.
## Not run: object <- findNN(object) object <- imputeLR(object) object <- inferIntrScore(object) ## End(Not run)
## Not run: object <- findNN(object) object <- imputeLR(object) object <- inferIntrScore(object) ## End(Not run)
or
valuesAfter running imputeVeloLR
, we can calculate the interaction
velocity for each location. Please refer to the manualscript for detail of
the calculation.
inferIntrVelo(object, recep.smooth = FALSE, norm.method = "scanpy")
inferIntrVelo(object, recep.smooth = FALSE, norm.method = "scanpy")
object |
A CytoSignal object, with
|
recep.smooth |
A logical scalar. Whether to use the smoothed |
norm.method |
The normalization method to apply to the velocity data,
need to be consistent with the normalization method used when generating the
input RNA velocity. Please consult the tool used for it, e.g. scVelo,
VeloVAE. Default is |
A CytoSignal object updated. Entries in
object@lrvelo
slot will be updated with the velocity scores. When
recep.smooth
is by default FALSE
, the object@lrvelo
slot will be updated with object@lrvelo$`GauEps-Raw`
and
object@lrvelo$`DT-Raw`
. When recep.smooth
is TRUE
, the
object@lrvelo
slot will be updated with
object@lrvelo$`GauEps-DT`
and object@lrvelo$`DT-DT`
.
## Not run: object <- addVelo(object, velo.s, velo.u) object <- findNN(object) object <- imputeVeloLR(object) object <- inferIntrVelo(object) ## End(Not run)
## Not run: object <- addVelo(object, velo.s, velo.u) object <- findNN(object) object <- imputeVeloLR(object) object <- inferIntrVelo(object) ## End(Not run)
This function is a follow-up function of inferScoreLR. It computes the NULL LR-scores using the NULL imputation results and stores the results in the LR score object. The null distribution of the LR scores can be used to test the significance of the LR scores.
inferNullScoreLR(object, slot.use = NULL)
inferNullScoreLR(object, slot.use = NULL)
object |
A Cytosignal object |
slot.use |
Which LR score to use. Use the name specified with |
A Cytosignal object
Compute the LR score for specific ligand-receptor imputation pairs
inferScoreLR( object, lig.slot, recep.slot, norm.method = c("default", "cpm", "none", "scanpy"), intr.db.name = c("diff_dep", "cont_dep"), tag = paste0(lig.slot, "-", recep.slot) )
inferScoreLR( object, lig.slot, recep.slot, norm.method = c("default", "cpm", "none", "scanpy"), intr.db.name = c("diff_dep", "cont_dep"), tag = paste0(lig.slot, "-", recep.slot) )
object |
A Cytosignal object |
lig.slot |
The ligand slot to use |
recep.slot |
The receptor slot to use |
norm.method |
Method to normalize the data. Default is "default". |
intr.db.name |
The intr database name to use |
tag |
Name of the result to be stored in object. |
A Cytosignal object
Infer significance of LR scores
inferSignif( object, fdr.method = c("spatialFDR", "fdr"), p.value = 0.05, reads.thresh = 100, sig.thresh = 100, slot.use = NULL, nn.use = NULL )
inferSignif( object, fdr.method = c("spatialFDR", "fdr"), p.value = 0.05, reads.thresh = 100, sig.thresh = 100, slot.use = NULL, nn.use = NULL )
object |
A Cytosignal object |
fdr.method |
The false discovery rate method to use. Choose from
|
p.value |
A numeric scalar. The p-value threshold to use for filtering
significant interactions. Default |
reads.thresh |
A numeric scalar. The minimum number of reads for a
ligand-receptor interaction to be considered. Default |
sig.thresh |
A numeric scalar. The minimum number of of beads for a
ligand-receptor interaction to be considered. Default |
slot.use |
Which LR score to use. Use the name specified with |
nn.use |
Which imputation to use. Default the imputation used for
deriving the LRScore specified with |
A Cytosignal object
Use DT neighbors to impute the p-value and LR-score for each cell, then compute the pearson correlation between the imputed LR-score and p-value.
inferSpatialCorr(object, correctBy = c("cell", "intr"), slot.use = NULL)
inferSpatialCorr(object, correctBy = c("cell", "intr"), slot.use = NULL)
object |
A Cytosignal object |
correctBy |
Spatial FDR correction method. Choose from |
slot.use |
Which LR score to use. Use the name specified with |
A Cytosignal object
Sub function for inferVeloLR, input a CytoSignal object
inferVeloLR( object, lig.slot, recep.slot, intr.db.name, norm.method = "scanpy", tag = NULL )
inferVeloLR( object, lig.slot, recep.slot, intr.db.name, norm.method = "scanpy", tag = NULL )
object |
A Cytosignal object |
lig.slot |
The ligand slot to use |
recep.slot |
The receptor slot to use |
intr.db.name |
The intr database name to use |
norm.method |
The normalization method to apply to the counts, need to be consistent with the normalization method used for the RNA velocity method. Default is "scanpy". |
nn.use |
slot that the neighbor index should be taken from, by default is the same as the recep.slot. For example, if velo.obj = GauEps-DT, then nn.use = "DT". nn.use could also be a user-defind factor. |
A Cytosignal object
The lrScores object is created from one ST dataset. User could choose two imputation methods to calculate the ligand-receptor scores. The class stores the ligand, receptor, and interaction database, the ligand-receptor scores, the ligand-receptor scores for permuted data, the ligand-receptor scores for permuted data, and the log of each main steps.
The key slots used in the lrScores object are described below.
lig.slot
ligand database
recep.slot
receptor database
intr.slot
interaction database
intr.list
list of interaction database
score
ligand-receptor scores
score.null
permuted ligand-receptor scores
res.list
list of results
log
Log of each main steps
The lrvelo object is created from one ST dataset. User could choose two imputation methods to calculate the ligand-receptor scores. The class stores the index of ligand, receptor, and interaction database, inferred lrvelo for each interaction, and the log of each main steps.
The key slots used in the lrVelo object are described below.
lig.slot
ligand database
recep.slot
receptor database
intr.slot
interaction database
intr.list
list of interaction database
velo.s
A matrix of spliced velo for each gene
velo.u
A matrix of unspliced velo for each gene
velo.intr
A sparse matrix of velo for each intr
nn.id
A factor of nearest neighbor id. Re-do findNN since the order of cells may change!
nn.dist
A factor of nearest neighbor distance. Re-do findNN since the order of cells may change!
log
Log of each main steps
This function accepts a list of CytoSignal objects together with a metadata
data.frame
that provides dataset level metadata covariates, which will
be required for the cross-dataset analysis.
The function will preprocess each CytoSignal object with cross-dataset analysis specific steps, including imputing diffusible LR values using Gaussion Epsilon model with weight 1.
mergeCytoSignal( objList, metadata = NULL, name.by = NULL, counts.thresh = 0, scale.factor = NULL )
mergeCytoSignal( objList, metadata = NULL, name.by = NULL, counts.thresh = 0, scale.factor = NULL )
objList |
A list of CytoSignal objects or paths to CytoSignal objects stored as RDS format. Can be mixed of two types. |
metadata |
A data.frame object of dataset level metadata, containing
information like gender, age, treatment and etc. Default |
name.by |
A column name in |
counts.thresh |
A number indicating the threshold for removing low-quality spots. Default 0. |
scale.factor |
A number indicating 1 spatial coord unit equals to how many µm. |
A mergedCytoSignal object preprocessed.
An object that holds necessary information from multiple CytoSignal objects that is required for performing cross-dataset analysis. Results from the cross-dataset analysis will also be held in this object.
Please use mergeCytoSignal()
to create a
mergedCytoSignal
object
metadata
A data.frame with spot/cell level metadata covariates. Column name "dataset", "originalID", "clusters", "x" and "y" are reserved for downstream analysis and object validity.
diff.lrscore
A sparse matrix (dgCMatrix) of LR scores for diffusion-dependent interactions, across all datasets.
diff.results
A list of data.frame objects, each containing the results of NEBULA analysis for a specific covariate as specified when running the analysis.
cont.lrscore
A sparse matrix (dgCMatrix) of LR scores for contact-dependent interactions, across all datasets.
cont.results
A list of data.frame objects, each containing the results of NEBULA analysis for a specific covariate as specified when running the analysis.
cov.use
A list that organizes the covariates being used for the modeling. Each element is named by a variable name selected from metadata, and is a list with the following structure
"type": "factor" or "numeric" etc. Original class of the variable
"levels" (if a factor): levels of the factor that'll be found in the model.matrix outcome
"range" (if numeric): range of the variable
Allows getting and setting dataset names of a mergedCytoSignal object.
## S3 method for class 'mergedCytoSignal' names(x) ## S3 replacement method for class 'mergedCytoSignal' names(x) <- value
## S3 method for class 'mergedCytoSignal' names(x) ## S3 replacement method for class 'mergedCytoSignal' names(x) <- value
x |
A mergedCytoSignal object |
value |
A character vector of up to the same length as x to rename datasets. or NULL to reset to default names. |
For names
, a character vector of dataset names.
For names<-
, a mergedCytoSignal object with dataset names updated
in both metadata and the rownames of lrscore matrices
This function permutes the imputation methods from which a given LR score is calculated. Note that all rounds of permutation will use the same shuffle and sample index.
permuteLR(object, slot.use = NULL, norm.method = "default", perm.size = 1e+05)
permuteLR(object, slot.use = NULL, norm.method = "default", perm.size = 1e+05)
object |
A CytoSignal object with |
slot.use |
Which LR score to use. Use the name specified with |
perm.size |
Size of the permutation test. Defult |
norm.me |
Normalization method. See |
A CytoSignal object
Plotting edge for a given interaction from a CytoSignal object
plotEdge( object, intr, type = c("receiver", "sender"), slot.use = NULL, signif.use = NULL, colors.list = NULL, return.plot = TRUE, plot_dir = "csEdgePlot/", filename = NULL, plot.fmt = c("png", "pdf", "svg"), title = NULL, edge.size = 500, use.shape = 16, line.width = 0.01, use.phi = 30, use.theta = -17, z.scaler = 0.03, box = TRUE, z.pt.interval = 1, pt.size = 0.1, pt.sig.size = NULL, pt.stroke = 0.2, width = 5, height = 5, set.res = 300, verbose = TRUE )
plotEdge( object, intr, type = c("receiver", "sender"), slot.use = NULL, signif.use = NULL, colors.list = NULL, return.plot = TRUE, plot_dir = "csEdgePlot/", filename = NULL, plot.fmt = c("png", "pdf", "svg"), title = NULL, edge.size = 500, use.shape = 16, line.width = 0.01, use.phi = 30, use.theta = -17, z.scaler = 0.03, box = TRUE, z.pt.interval = 1, pt.size = 0.1, pt.sig.size = NULL, pt.stroke = 0.2, width = 5, height = 5, set.res = 300, verbose = TRUE )
object |
|
intr |
Interaction to plot. See available options with
|
type |
Type of plot, either |
slot.use |
Slot to use for plotting |
signif.use |
Significance level to use for plotting |
colors.list |
List of colors to use for plotting |
return.plot |
Whether to return "plist" object for figure organization.
|
plot_dir |
Path where the figure will be saved when
|
filename |
Filename of the figure inside |
plot.fmt |
Format of plot, either |
title |
Title of plot |
use.shape |
Shape of points |
line.width |
Width of lines |
use.phi |
Angle of 3D plot |
use.theta |
Angle of 3D plot |
z.scaler |
Scaling factor for z-axis |
z.pt.interval |
Interval of points on z-axis |
pt.stroke |
Width of points |
set.res |
Resolution of plot |
use.cex |
Size of points |
u_width |
Width of plot |
u_hgt |
Height of plot |
plist
object when return.plot = TRUE
, no in memory
object is returned when return.plot = FALSE
but the figure will be
saved on disk.
This visualization method uses the result for either diffusion-dependent or
contact-dependent interactions from NEBULA analysis to generate a dot plot.
Each dot represents an interaction. The x axis is grouped by covariate levels
and jittered to avoid overlap. Therefore, each interaction appears in all the
covariate groups. The y axis is the logFC value of the interaction. The size
of the dots represents the significance () of an
interaction evaluated on a covariate level. Transparency of the dots shows
overall significance combining the FDR threshold and logFC threshold.
plotNebulaAll( object, intr.type = c("diff", "cont"), fdrThresh = 0.05, logfcThresh = 1, title = NULL, titleSize = 16, xTextSize = 10, xTextAngle = 40, yTextSize = 10, yTitleSize = 12, legendTextSize = 12, legendTitleSize = 12, stripTitleSize = 12 )
plotNebulaAll( object, intr.type = c("diff", "cont"), fdrThresh = 0.05, logfcThresh = 1, title = NULL, titleSize = 16, xTextSize = 10, xTextAngle = 40, yTextSize = 10, yTitleSize = 12, legendTextSize = 12, legendTitleSize = 12, stripTitleSize = 12 )
object |
A mergedCytoSignal object, with
|
intr.type |
A character string specifying the type of interaction to
plot. Choose from |
fdrThresh |
A numeric value to set the FDR threshold for significance.
FDR value higher than this threshold will be considered as not significant.
Default |
logfcThresh |
A numeric value to set the threshold on the absolute value
of logFC. Absoluate logFC value lower than this threshold will be considered
as not significant. Default |
title |
A character string to set the title of the plot. Default
|
titleSize |
A numeric value to set the size of the title of the plot.
Default |
xTextSize |
A numeric value to set the size of the text on x-axis.
Default |
xTextAngle |
A numeric value to set the angle (in degree) to rotate the
x-axis text labels. Default |
yTextSize |
A numeric value to set the size of the text on y-axis.
Default |
yTitleSize |
A numeric value to set the size of the title on y-axis.
Default |
legendTextSize |
A numeric value to set the size of the text in the
legend. Default |
legendTitleSize |
A numeric value to set the size of the title in the
legend. Default |
stripTitleSize |
A numeric value to set the size of the title in the
strip on top of each grid for the covariate groups. Default |
A ggplot figure (gg
, ggplot
object).
This function allows drawing a volcano plot for the Nebula analysis on a
single covariate level, for either diffusion-dependent or contact-dependent
interactions. Either static ggplot figure or interactive plotly figure can
be generated. Interactions of interests can be labeled with: 1. choosing
specific interactions by name or index. 2. choosing top N interactions ranked
by significance (FDR and abs(logFC)). A non-NULL highlight
argument is
considered before topN
. When both are not specified, highlight all
significant interactions.
plotNebulaVolcano( object, covariate, intr.type = c("diff", "cont"), highlight = NULL, topN = NULL, fdrThresh = 0.05, logfcThresh = 1, interactive = TRUE, dotSize = 1.3, dotAlpha = 0.8, xTextSize = 10, xTitleSize = 12, yTextSize = 10, yTitleSize = 12, legendTextSize = 12, legendTitleSize = 12, labelTextSize = 4, titleSize = 16 )
plotNebulaVolcano( object, covariate, intr.type = c("diff", "cont"), highlight = NULL, topN = NULL, fdrThresh = 0.05, logfcThresh = 1, interactive = TRUE, dotSize = 1.3, dotAlpha = 0.8, xTextSize = 10, xTitleSize = 12, yTextSize = 10, yTitleSize = 12, legendTextSize = 12, legendTitleSize = 12, labelTextSize = 4, titleSize = 16 )
object |
A mergedCytoSignal object, with
|
covariate |
A character string of the covariate to plot. Must be
available in |
intr.type |
A character string specifying the type of interaction to
plot. Choose from |
highlight |
A character vector of interaction names, a numeric or
logical vector of indices to select specific interactions to highlight; or
a single |
topN |
An integer to select top N interactions to highlight ranked by
significance. Rank by FDR first and abs(logFC) then. Default |
fdrThresh |
A numeric value to set the FDR threshold for significance.
FDR value higher than this threshold will be considered as not significant.
Default |
logfcThresh |
A numeric value to set the threshold on the absolute value
if logFC. Absoluate logFC value lower than this threshold will be considered
as not significant. Default |
interactive |
Logical, whether to generate an interactive plotly figure.
Default |
dotSize |
A numeric value to set the size of the dots in the plot.
Default |
dotAlpha |
A numeric value to set the transparency of the dots in the
plot. Default |
xTextSize |
A numeric value to set the size of the text on x-axis.
Default |
xTitleSize |
A numeric value to set the size of the title on x-axis.
Default |
yTextSize |
A numeric value to set the size of the text on y-axis.
Default |
yTitleSize |
A numeric value to set the size of the title on y-axis.
Default |
legendTextSize |
A numeric value to set the size of the text in the
legend. Default |
legendTitleSize |
A numeric value to set the size of the title in the
legend. Default |
labelTextSize |
A numeric value to set the size of the text on the
highlight labels. Default |
titleSize |
A numeric value to set the size of the main title of the
plot. Default |
A plotly figure (plotly
, htmlwidget
object) if interactive = TRUE
.
A ggplot figure (gg
, ggplot
object) if interactive = FALSE
.
Plot the refined score of each interaction after regression model refinement
plotRefinedScore( object, intrDEGRes, intr = NULL, pt.size = 0.5, pt.stroke = 0.1 )
plotRefinedScore( object, intrDEGRes, intr = NULL, pt.size = 0.5, pt.stroke = 0.1 )
object |
A |
intrDEGRes |
The direct output object of |
intr |
A vector of unique interaction IDs that are available in
|
pt.size |
Size of the points in the plot. Default |
pt.stroke |
Stroke size of the points in the plot. Default |
List of ggplot objects, each shows the refined LR score of each selected interaction.
Create scatter plot from REVIGO result
plotREVIGO( rvg, labelBy = c("Name", "TermID"), labelIdx = NULL, labelSize = 4, max.overlaps = 5 )
plotREVIGO( rvg, labelBy = c("Name", "TermID"), labelIdx = NULL, labelSize = 4, max.overlaps = 5 )
rvg |
A data.frame from |
labelBy |
From which field of the revigo result to retrieve label text.
Choose from |
labelIdx |
Index matching to rows of |
labelSize |
Size of text label for marked dots. Default |
max.overlaps |
|
A ggplot object
rvg <- revigo(c("GO:0003002", "GO:0007389", "GO:0007423", "GO:0009653"), speciesTaxon = 10090) plotREVIGO(rvg)
rvg <- revigo(c("GO:0003002", "GO:0007389", "GO:0007423", "GO:0009653"), speciesTaxon = 10090) plotREVIGO(rvg)
By default ranked by the number of significant cells in each cluster
plotSigCluster( object, plot_dir, cluster.list = NULL, intr.num = 10, type = c("sender", "receiver"), slot.use = NULL, signif.use = NULL, colors.list = NULL, plot.fmt = "png", edge.size = 2000, all.in.one = T, plot.all.sig = F, use.cex = 0.1, use.shape = 16, line.width = 0.02, use.phi = 30, use.theta = -17, z.scaler = 0.03, z.pt.interval = 1, pt.stroke = 0.2, u_width = 6, u_hgt = 6, set.res = 400, return.plot = F )
plotSigCluster( object, plot_dir, cluster.list = NULL, intr.num = 10, type = c("sender", "receiver"), slot.use = NULL, signif.use = NULL, colors.list = NULL, plot.fmt = "png", edge.size = 2000, all.in.one = T, plot.all.sig = F, use.cex = 0.1, use.shape = 16, line.width = 0.02, use.phi = 30, use.theta = -17, z.scaler = 0.03, z.pt.interval = 1, pt.stroke = 0.2, u_width = 6, u_hgt = 6, set.res = 400, return.plot = F )
object |
A |
plot_dir |
Directory to save plots |
cluster.list |
A list of clusters to plot |
intr.num |
Number of interactions to plot |
type |
Either "sender" or "receiver" |
slot.use |
Slot to use for plotting |
signif.use |
Significance threshold to use for plotting |
colors.list |
A list of colors to use for each cluster |
plot.fmt |
Plot format |
edge.size |
Number of edges to plot |
all.in.one |
Plot all clusters in one plot |
plot.all.sig |
Plot all significant edges |
use.shape |
Shape of points |
line.width |
Width of lines |
use.phi |
Angle of view |
use.theta |
Angle of view |
z.scaler |
Scale of z-axis |
z.pt.interval |
Interval of z-axis |
pt.stroke |
Stroke of points |
u_width |
Width of plot |
u_hgt |
Height of plot |
set.res |
Resolution of plot |
return.plot |
Return plot object |
pt.size |
Size of points |
... |
Other arguments |
A list of plots
Plot significant interactions ranked by the user-specified metric
plotSignif( object, num.plot = NULL, res_dir, plot.details = T, slot.use = NULL, signif.use = NULL, plot.clusters = T, plot.velo = F, colors.list = NULL, pt.size = 0.1, pt.stroke = 0.2, u_width = 6, u_hgt = 5, set.res = 200, return.plot = F )
plotSignif( object, num.plot = NULL, res_dir, plot.details = T, slot.use = NULL, signif.use = NULL, plot.clusters = T, plot.velo = F, colors.list = NULL, pt.size = 0.1, pt.stroke = 0.2, u_width = 6, u_hgt = 5, set.res = 200, return.plot = F )
object |
A cytosignal object |
num.plot |
Number of interactions to plot |
res_dir |
Directory to save the plots |
plot.details |
Whether to plot NULL imputed values and scores |
slot.use |
The LRscore slot to use for plotting |
signif.use |
The metric used to rank the interactions, by default "result.hq.pear" |
plot.clusters |
Whether to plot the clusters |
plot.velo |
Whether to plot the velocity |
colors.list |
A list of colors to use for plotting |
pt.size |
Size of the points |
pt.stroke |
Stroke of the points |
u_width |
Width of the plot |
u_hgt |
Height of the plot |
set.res |
Resolution of the plot |
return.plot |
Whether to return the plot |
A plot if return.plot is TRUE. Otherwise, plots are saved to the specified directory.
Plot significant interactions ranked by the user-specified metric
plotSignif2( object, intr, edge = FALSE, velo = FALSE, slot.use = NULL, signif.use = NULL, colors.list = NULL, pt.size = 0.1, pt.stroke = 0.2, return.plot = FALSE, plot_dir = "csSignifPlot/", plot.fmt = c("png", "pdf", "svg"), raster = NULL, resolution = 300, verbose = FALSE )
plotSignif2( object, intr, edge = FALSE, velo = FALSE, slot.use = NULL, signif.use = NULL, colors.list = NULL, pt.size = 0.1, pt.stroke = 0.2, return.plot = FALSE, plot_dir = "csSignifPlot/", plot.fmt = c("png", "pdf", "svg"), raster = NULL, resolution = 300, verbose = FALSE )
object |
A cytosignal object |
intr |
Specify interactions to be plotted. A vector of either the unique
ID of interactions or the numeric indices. Available IDs can be shown with
|
edge , velo
|
Logical, whether to plot edge or velocity, respectively. |
slot.use |
The LRscore slot to use for plotting |
signif.use |
The metric used to rank the interactions, by default "result.hq.pear" |
colors.list |
A list of colors to use for plotting |
pt.size |
Size of the points |
pt.stroke |
Stroke of the points |
return.plot |
Whether to return the plot |
plot_dir |
Directory to save the plots |
plot.fmt |
Format of output file. "png", "pdf", or "svg". |
resolution |
Resolution of the output figure. |
verbose |
Logical, whether to show progress. |
A plot if return.plot is TRUE. Otherwise, plots are saved to the specified directory.
Plot 3D LR-velo ranked by the user-specified metric
plotVelo( object, intr, return.plot = TRUE, plot_dir = "csVeloPlot/", filename = NULL, plot.fmt = c("png", "pdf"), slot.use = NULL, signif.use = NULL, use.clusters = NULL, colors.list = NULL, z.scaler = 0.03, title = NULL, pt.size = 0.1, use.shape = 16, use_xbins = 15, use_ybins = 15, arrow.line.width = 0.6, arrow.width = 0.06, pt.stroke = 0.2, use.phi = 30, use.theta = -17, box = TRUE, axis.arrow.len = 1, width = 6, height = 6, set.res = 300, verbose = TRUE )
plotVelo( object, intr, return.plot = TRUE, plot_dir = "csVeloPlot/", filename = NULL, plot.fmt = c("png", "pdf"), slot.use = NULL, signif.use = NULL, use.clusters = NULL, colors.list = NULL, z.scaler = 0.03, title = NULL, pt.size = 0.1, use.shape = 16, use_xbins = 15, use_ybins = 15, arrow.line.width = 0.6, arrow.width = 0.06, pt.stroke = 0.2, use.phi = 30, use.theta = -17, box = TRUE, axis.arrow.len = 1, width = 6, height = 6, set.res = 300, verbose = TRUE )
object |
A cytosignal object |
return.plot |
Whether to return the plot |
slot.use |
The LRscore slot to use for plotting |
signif.use |
The metric used to rank the interactions, by default "result.hq.pear" |
use.clusters |
Plot only selected clusters. Default |
colors.list |
A list of colors to use for plotting |
z.scaler |
Scaling factor for the z-axis |
pt.size |
Point size. Default 0.1 |
use.shape |
Point shape. Default 16 |
use_xbins |
Number of bins for the x-axis. Default 15 |
use_ybins |
Number of bins for the y-axis. Default 15 |
arrow.line.width |
Width of the arrow line. Default 0.6 |
arrow.width |
Width of the arrow. Default 0.06 |
pt.stroke |
Stroke of the points |
use.phi |
Set view angel: phi the colatitude. Default 30 |
use.theta |
Set view angel: theta gives the azimuthal direction. Default -17 |
box |
Whether to show a box panel for the 3D region. Default TRUE |
axis.arrow.len |
When box = FALSE, set the length of the axis arrows. |
width |
Width of the plot. Default 6 |
height |
Height of the plot. Default 6 |
set.res |
Resolution of the plot. Default 300. |
num.plot |
Number of interactions to plot |
res_dir |
Directory to save the plots |
plot.velo |
Whether to plot the velocity |
A plot if return.plot is TRUE. Otherwise, plots are saved to the specified directory.
Print the CytosignalIntrDEG object representation to screen
## S3 method for class 'CytosignalIntrDEG' print(x, ...)
## S3 method for class 'CytosignalIntrDEG' print(x, ...)
x |
A |
... |
Passed to other methods |
Remove imputed data and normalized imputed data from CytoSignal object to save disk space
purgeBeforeSave(object, purge.raw = TRUE, purge.null = FALSE)
purgeBeforeSave(object, purge.raw = TRUE, purge.null = FALSE)
object |
CytoSignal object |
a CytoSignal object
This function utilizes SPARK package to calculate the spatial variability of the high-quality interactions, using their LR scores. Please refer to Jiaqiang Zhu, et al., 2021, Genome Biology for more details of the method.
rankIntrSpatialVar(object, slot.use = NULL, numCores = 1, verbose = FALSE)
rankIntrSpatialVar(object, slot.use = NULL, numCores = 1, verbose = FALSE)
object |
A CytoSignal object, with
|
slot.use |
Which LR score to use. Use the name specified with |
numCores |
SPARK::sparkx parameter, an integer specifying the number of threads. |
verbose |
SPARK::sparkx parameter, a logical value indicating whether to print details for debug purpose |
The input CytoSignal object with the spatially variable
high-quality interaction list updated at
object@lrscore[[slot.use]]@res.list$result.spx
## Not run: object <- findNN(object) object <- imputeLR(object) object <- inferScoreLR(object, lig.slot = "GauEps", recep.slot = "Raw", intr.db.name = "diff_dep") object <- permuteLR(object) object <- inferNullScoreLR(object) object <- inferSignif(object) object <- rankIntrSpatialVar(object) ## End(Not run)
## Not run: object <- findNN(object) object <- imputeLR(object) object <- inferScoreLR(object, lig.slot = "GauEps", recep.slot = "Raw", intr.db.name = "diff_dep") object <- permuteLR(object) object <- inferNullScoreLR(object) object <- inferSignif(object) object <- rankIntrSpatialVar(object) ## End(Not run)
Remove low quality cells and genes from raw counts
removeLowQuality(object, counts.thresh = 300, gene.thresh = 50)
removeLowQuality(object, counts.thresh = 300, gene.thresh = 50)
object |
CytoSignal object |
counts.thresh |
threshold for cell counts |
gene.thresh |
threshold for gene counts |
a CytoSignal object
This function gets an input of vector of GO terms and submit query to REVIGO via HTTP, and retrieves the result from the job. The code is based on example provided by REVIGO, originally located at http://revigo.irb.hr/FAQ
Please visit http://revigo.irb.hr/ for the web-based interactive tool, and please see https://doi.org/10.1371/journal.pone.0021800 for detailed introduction to the functionality.
revigo( GOterms, cutoff = 0.7, value = NULL, valueType = c("PValue", "Higher", "Lower", "HigherAbsolute", "HigherAbsLog2"), speciesTaxon = "0", measure = c("SIMREL", "LIN", "RESNIK", "JIANG"), removeObsolete = TRUE )
revigo( GOterms, cutoff = 0.7, value = NULL, valueType = c("PValue", "Higher", "Lower", "HigherAbsolute", "HigherAbsLog2"), speciesTaxon = "0", measure = c("SIMREL", "LIN", "RESNIK", "JIANG"), removeObsolete = TRUE )
GOterms |
Character vector of GO term IDs. |
cutoff |
Size of the result, between 0.4 to 0.9. Larger value returns
more result. Default |
value |
A vector of additional information for each GO term. Default
|
valueType |
Type of |
speciesTaxon |
Taxon ID of the species. Default |
measure |
The semantic similarity measure to use. Default
|
removeObsolete |
Logical. Whether to remove obsolete GO terms. Default
|
A data.frame with many information
rvg <- revigo(c("GO:0003002", "GO:0007389", "GO:0007423", "GO:0009653"), speciesTaxon = 10090)
rvg <- revigo(c("GO:0003002", "GO:0007389", "GO:0007423", "GO:0009653"), speciesTaxon = 10090)
After merging multiple CytoSignal objects and adding metadata covariates as needed for modeling the comparison, this function runs NEBULA's association analysis to identify significant interactions between cells from different datasets and of different covariate levels.
runNEBULA(object, covariates, ncore = 1L, verbose = TRUE)
runNEBULA(object, covariates, ncore = 1L, verbose = TRUE)
object |
A mergedCytoSignal object |
covariates |
A character vector of metadata covariates to include in the model. |
ncore |
Integer, number of cores to use for parallel computation.
Default |
verbose |
Logical, print progress messages. Default |
Input object
with slot diff.results
and
cont.results
updated with the results from NEBULA analysis.
Identify spatially significant interactions using std-corrected pearson correlation Normal Moran's I test is not applicable here since the total number of the cell is too large, causing unnacceptable computation cost. Here we use a modified version of Moran's I test, which is to take only the top KNNs to compute the Moran's I test.
runPears.std(object, k = 10, weight = 2, score.slot = NULL)
runPears.std(object, k = 10, weight = 2, score.slot = NULL)
object |
A Cytosignal object |
k |
The number of nearest neighbors to use |
weight |
The weight of the nearest neighbors |
score.slot |
Which LR score to use. Use the name specified with |
A Cytosignal object
show method for CytoSignal
## S4 method for signature 'CytoSignal' show(object)
## S4 method for signature 'CytoSignal' show(object)
object |
CytoSignal object |
show method for cytosignal obj
## S4 method for signature 'ImpData' show(object)
## S4 method for signature 'ImpData' show(object)
Show method for mergedCytoSignal object
## S4 method for signature 'mergedCytoSignal' show(object)
## S4 method for signature 'mergedCytoSignal' show(object)
object |
A mergedCytoSignal object |
Show a message with object summary, no return value
Show available covariate levels used in NEBULA analysis
showCov(object, intr.type = NULL)
showCov(object, intr.type = NULL)
object |
A mergedCytoSignal object |
intr.type |
A character string specifying the type of interaction to
show covariate levels for. Choose from |
A character vector
show method for ImpData
showImp(object, slot.use = NULL)
showImp(object, slot.use = NULL)
object |
CytoSignal object |
slot.use |
slot to use |
show method for CytoSignal
showIntr(object, ...) ## S3 method for class 'CytoSignal' showIntr(object, slot.use = NULL, signif.use = NULL, return.name = FALSE, ...) ## S3 method for class 'mergedCytoSignal' showIntr(object, intr.type, ...)
showIntr(object, ...) ## S3 method for class 'CytoSignal' showIntr(object, slot.use = NULL, signif.use = NULL, return.name = FALSE, ...) ## S3 method for class 'mergedCytoSignal' showIntr(object, intr.type, ...)
object |
A CytoSignal or mergedCytoSignal object |
... |
S3 method options for different classes. |
slot.use |
The LR score slot to use. Choose from
|
signif.use |
Which level of significance inference to use for the
LR score slot selected. Choose from
|
return.name |
Whether to return interaction name that comes with the
form of "ligand-receptor", instead of showing the unique IDs.
Default |
intr.type |
Which type of interactions to show. Choose from
|
For CytoSignal object, a character vector of unique IDs of the
interactions available to the specified slot. When
return.name = TRUE
, a named character vector where the names are the
IDs and the values are interaction names with the form of
"ligand-receptor".
For mergedCytoSignal object, a character vector "ligand-receptor" pair names.
show all current logs
showLog(object)
showLog(object)
object |
CytoSignal object |
show method for lrScores
showScore(object, slot.use = NULL)
showScore(object, slot.use = NULL)
object |
CytoSignal object |
slot.use |
slot to use |
show intr.data in ImpData
showUnpt(object, slot.use = NULL)
showUnpt(object, slot.use = NULL)
object |
CytoSignal object |
slot.use |
slot to use |
show method for lrVelo
showVelo(object, slot.use = NULL)
showVelo(object, slot.use = NULL)
object |
CytoSignal object |
slot.use |
slot to use |
This function is used to estimate the scaling facor of real units to spatial units. Returns the top 5 possible scaling factors, users can choose to which to use.
suggestScaleFactor(object, cell.intervel = NULL)
suggestScaleFactor(object, cell.intervel = NULL)
object |
CytoSignal object |
cell.intervel |
Distance between two cell in physical units |
a vector of possible scaling factors
ggsci:::ggsci_db$igv$default
Generate character vector of unique color hex codes
Base color palette adopts ggsci:::ggsci_db$igv$default
uniqueColors(n)
uniqueColors(n)
n |
Number of unique colors to generate. When not exceeding existing
number of colors, just return the first |