sc_StatisticalSupportByReplacementWithInSilicoCellsReplicates {sincell} | R Documentation

## Statistical support of cell-state hierarchies by random cell substitution with in silico-generated cell replicate

### Description

Function to provide statistical support to the connected graph in SincellObject[["cellstateHierarchy"]] assessed by function sc_GraphBuilderObj() representing a cell-state hierarchy. sc_StatisticalSupportByReplacementWithInSilicoCellsReplicates() performs "num_it" times a random replacement of a given fraction "fraction.cells.to.replace" cells on the original gene expression matrix with a randomly selected set of in-silico replicates. Then, for each set of substitutions "num_it", a new connected graph of cells is calculated using the same parameters as for the hierarchy being tested. In each "num_it", the similarity between the resulting connected graph and the original one is assessed as the Spearman rank correlation between the two graphs of the shortest distance for all pairs of cells. The distribution of spearman rank correlation values of all iterations is stored as a vector in SincellObject[["StatisticalSupportByReplacementWithInSilicoCellReplicates"]] and a summary is printed in the standard output.

### Usage

    sc_StatisticalSupportByReplacementWithInSilicoCellsReplicates(SincellObject,
      method="own", num_it=100, fraction.cells.to.replace=0.15,
      cores=ifelse(detectCores()>=4, 4, detectCores()))

### Arguments

`SincellObject` | A SincellObject named list, with a member "cellstateHierarchy" containing a connected graph representing a cell-state hierarchy, a member "expressionmatrix" containing a numeric matrix that represents a gene expression matrix gathering the expression levels of each single-cell in the experiment (displayed by columns) for each detected gene (displayed by rows) and a member "InSilicoCellsReplicates" containing the in silico cells replicates as generated by function sc_InSilicoCellsReplicatesObj()
`method` | The parameter "method" controls for the maximum order of neighborhood k from which in silico cell replicates will be randomly chosen for substitution. When k=0 (or k="own", default value), a cell will be replaced by a replicate from itself (this is the behavior by default). If k=2, a cell will be replaced by a replicate from itself or from any neighbor of order 2 in the graph. If k="all", a cell will be replaced by a replicate from itself or from any other cell in the graph.
`num_it` | number of iterations in which a random replacement of a given fraction "fraction.cells.to.replace" cells on the original gene expression matrix with a randomly selected set of in-silico replicates is performed
`fraction.cells.to.replace` | fraction of cells on the original gene expression matrix to randomly replace with a randomly selected in-silico replicate
`cores` | Number of threads used to paralyze the computation. Under Unix platforms, by default the function uses all cores up to 4 (to avoid possilbe issues while running on a cluster with the default parameter) detected by the operating system. Under non Unix based platforms, this parameter will be automatically set to 1.

### Value

The SincellObject named list provided as input where following list members are added: SincellObject[["StatisticalSupportByReplacementWithInSilicoCellReplicates"]]. Each element of SincellObject[["StatisticalSupportByReplacementWithInSilicoCellReplicates"]] represents the similarity between the original graph and the graph resulting in each "num_it" iteration from a randon substitution of "fraction.cells.to.replace" with in silico replicates. That similarity is assessed as the spearman rank correlation between the two graphs of the shortest distance for all pairs of cells.

### Examples

    ## Generate some random data
    Data <- matrix(abs(rnorm(3000, sd=2)),ncol=10,nrow=30)

    ## Initializing SincellObject named list
    mySincellObject <- sc_InitializingSincellObject(Data)

    ## Assessmet of cell-to-cell distance matrix after dimensionality reduction with
    ## Principal Component Analysis (PCA)
    mySincellObject <- sc_DimensionalityReductionObj(mySincellObject, method="PCA",dim=2)

    ## Cluster
    mySincellObject <- sc_clusterObj (mySincellObject, clust.method="max.distance",
      max.distance=0.5)

    ## Assessment of cell-state hierarchy
    mySincellObject<- sc_GraphBuilderObj(mySincellObject, graph.algorithm="SST",
      graph.using.cells.clustering=TRUE)

    ## In silico generation of replicates of individual cells
    mySincellObject <- sc_InSilicoCellsReplicatesObj(mySincellObject,
      method="variance.deciles", multiplier=100, no_expr=0.5)

    ## Assessment of statistical support by replacement with in silico cells replicates
    mySincellObject<-sc_StatisticalSupportByReplacementWithInSilicoCellsReplicates(
      mySincellObject, method="own", num_it=100, fraction.cells.to.replace=0.15)

    ## To access the distribution of Spearman rank correlations:
    StatisticalSupportByReplacementWithInSilicoCellReplicates<-
      mySincellObject[["StatisticalSupportByReplacementWithInSilicoCellReplicates"]]
    summary(StatisticalSupportByReplacementWithInSilicoCellReplicates)

[Package sincell version 1.18.0 Index]