orderCluster: Clustering cells according to pseudotime.

Description Usage Arguments Value Examples

View source: R/orderCluster.R

Description

This function returned cluster-level data.

Usage

1

Arguments

M

M is a matrix. Rows for genes, and columns for cells.

k

k is the cluster number.

Value

Returned value 'N' is cluster-level data, a m*k dimension matrix.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (M, k)
{
    n <- ncol(M)
    N <- matrix(0, nrow(M), k)
    distance <- dist(t(M))
    distance <- as.matrix(distance)
    distance <- diag(distance[2:n, 1:(n - 1)])
    link <- rank(distance) <= n - k
    j <- 1
    N[, 1] <- M[, 1]
    for (i in c(1:(n - 1))) {
        if (link[i] == 1) {
            N[, j] <- N[, j] + M[, i + 1]
        }
        else {
            j <- j + 1
            N[, j] <- M[, i]
        }
    }
    shre <- !link
    shre <- which(shre == 1)
    shre <- c(0, shre, n)
    cluNumber <- shre[2:length(shre)] - shre[1:(length(shre) -
        1)]
    for (i in c(1:k)) {
        N[, i] <- N[, i]/cluNumber[i]
    }
    return(N)
  }

xzheng-ac/scPADGRN documentation built on July 26, 2020, 12:41 a.m.