Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

diagonal of adjacency matrix is not zero any more after tensor decomposition #6

Open
ccshao opened this issue Oct 7, 2020 · 1 comment

Comments

@ccshao
Copy link

ccshao commented Oct 7, 2020

Dear dev,

In the intial outputs of network construction, the diagonal of the square adjacency matrix is 0, whic makes sense.

However, after tensor decomposition, the diagonal of returned consensus matrix is not zero any more. It is difficult
for me to intepret those value on the diagonal, as the value are made up by cp. It seems these value are used in the later steps in manifoldAlignment without setting back to 0 or other preprocessing.

An non zero value on the diagonal would normally suggest self-regulation. How do you think of the resulted regulation network by tensor decomposition?

See an example taken from the package.

nCells = 2000
nGenes = 100
set.seed(1)
X <- rnbinom(n = nGenes * nCells, size = 20, prob = 0.98)
X <- round(X)
X <- matrix(X, ncol = nCells)
rownames(X) <- c(paste0('ng', 1:90), paste0('mt-', 1:10))

# Computing 3 single-cell gene regulatory networks each one from a subsample of 500 cells
mnOutput <- makeNetworks(X = X,
                         nNet = 3, 
                         nCells = 500, 
                         nComp = 3, 
                         scaleScores = TRUE, 
                         symmetric = FALSE, 
                         q = 0.95
                         )

# Computing a K = 3 CANDECOMP/PARAFAC (CP) Tensor Decomposition
tdOutput <- tensorDecomposition(mnOutput, K = 3, maxError = 1e5, maxIter = 1e3)

# All 0 for all matrix in mnOutput
diag(as.matrix(mnOutput[[1]]))
  ng1   ng2   ng3   ng4   ng5   ng6   ng7   ng8   ng9  ng10  ng11  ng12  ng13 
    0     0     0     0     0     0     0     0     0     0     0     0     0 
 ng14  ng15  ng16  ng17  ng18  ng19  ng20  ng21  ng22  ng23  ng24  ng25  ng26 
    0     0     0     0     0     0     0     0     0     0     0     0     0 
 ng27  ng28  ng29  ng30  ng31  ng32  ng33  ng34  ng35  ng36  ng37  ng38  ng39 
    0     0     0     0     0     0     0     0     0     0     0     0     0 
 ng40  ng41  ng42  ng43  ng44  ng45  ng46  ng47  ng48  ng49  ng50  ng51  ng52 
    0     0     0     0     0     0     0     0     0     0     0     0     0 
 ng53  ng54  ng55  ng56  ng57  ng58  ng59  ng60  ng61  ng62  ng63  ng64  ng65 
    0     0     0     0     0     0     0     0     0     0     0     0     0 
 ng66  ng67  ng68  ng69  ng70  ng71  ng72  ng73  ng74  ng75  ng76  ng77  ng78 
    0     0     0     0     0     0     0     0     0     0     0     0     0 
 ng79  ng80  ng81  ng82  ng83  ng84  ng85  ng86  ng87  ng88  ng89  ng90  mt-1 
    0     0     0     0     0     0     0     0     0     0     0     0     0 
 mt-2  mt-3  mt-4  mt-5  mt-6  mt-7  mt-8  mt-9 mt-10 
    0     0     0     0     0     0     0     0     0 

#- now the value are non zero.
diag(as.matrix(tdOutput[[1]]))
  ng1   ng2   ng3   ng4   ng5   ng6   ng7   ng8   ng9  ng10  ng11  ng12  ng13 
  0.2   0.0   0.0   0.3   0.0   0.0   0.2   0.3   0.0   0.0   0.0   0.0   0.1 
 ng14  ng15  ng16  ng17  ng18  ng19  ng20  ng21  ng22  ng23  ng24  ng25  ng26 
  0.0   0.0   0.0   0.0   0.1   0.0   0.1   0.0   0.1   0.0   0.0   0.0   0.0 
 ng27  ng28  ng29  ng30  ng31  ng32  ng33  ng34  ng35  ng36  ng37  ng38  ng39 
  0.0   0.0   0.0   0.1   0.0   0.1   0.2   0.0   0.0   0.0   0.0   0.0   0.4 
 ng40  ng41  ng42  ng43  ng44  ng45  ng46  ng47  ng48  ng49  ng50  ng51  ng52 
  0.0   0.0   0.1   0.3   0.0   0.3   0.2   0.1   0.0   0.0   0.0   0.2   0.3 
 ng53  ng54  ng55  ng56  ng57  ng58  ng59  ng60  ng61  ng62  ng63  ng64  ng65 
  0.4   0.0   0.3   0.0   0.0   0.0   0.0   0.0   0.5   0.0   0.0   0.0   0.0 
 ng66  ng67  ng68  ng69  ng70  ng71  ng72  ng73  ng74  ng75  ng76  ng77  ng78 
  0.0   0.0   0.0   0.0   0.0   0.0   0.2   0.0   0.0   0.3   0.0   0.0   0.0 
 ng79  ng80  ng81  ng82  ng83  ng84  ng85  ng86  ng87  ng88  ng89  ng90  mt-1 
  0.0   0.0   0.0   0.0   0.0   0.0   0.4   0.1   0.3   0.2   0.0   0.0   1.0 
 mt-2  mt-3  mt-4  mt-5  mt-6  mt-7  mt-8  mt-9 mt-10 
  0.0   0.0   0.0   0.0   0.0   0.0   0.0   0.4   0.3 

@wshaoYa
Copy link

wshaoYa commented Jan 22, 2024

@ccshao hello.

I have the same problem now, I want to directly use the gene regulatory network (GRN) generated by the scTenifoldNet function, but I find that the diagonal is not 0, I am not sure if I can directly and violently set the diagonal to 0.

How did you solve it?

Looking forward to your reply!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants