Skip to content

Commit

Permalink
Cleaned coda trees
Browse files Browse the repository at this point in the history
  • Loading branch information
VPetukhov committed Mar 17, 2022
1 parent 3dbe16f commit dab8cb5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 201 deletions.
33 changes: 2 additions & 31 deletions R/coda_tree_new.R → R/coda_tree.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#' @import ape
NULL

#' Construct the canonical tree
#'
Expand Down Expand Up @@ -36,9 +38,6 @@ constructTree <- function(cnts, groups, partition.thresh = 0){
# Get cell types from opposite sides of the principal balance
cells.plus <- cells.tmp[can.loadings > partition.thresh]
cells.minus <- cells.tmp[can.loadings < partition.thresh]
#
# print(cells.plus)
# print(cells.minus)

sbp.cda[cells.minus, id.bal] <- -1
sbp.cda[cells.plus, id.bal] <- 1
Expand Down Expand Up @@ -208,33 +207,6 @@ getNodeBalances <- function(log.f, sbp.my){
return(balances)
}

#' @keywords internal
hclustSbp <- function(freqs, groups){
cell.types <- colnames(freqs)

mx <- matrix(0, nrow = length(cell.types), ncol = length(cell.types),
dimnames = list(cell.types, cell.types))
for(i in 1:length(cell.types)){
for(j in 1:length(cell.types)){
if (j <= i) next

ratio <- log(apply(freqs[,cell.types[i],drop=F], 1, psych::geometric.mean )) -
log(apply(freqs[,cell.types[j],drop=F], 1, psych::geometric.mean ))
# print('---')
# print(freqs)
# print(ratio)
# print(groups)
mod <- lm(groups ~ ratio)
res <- summary(mod)
pval <- res$coefficients[2,4]
mx[i, j] <- pval
mx[j, i] <- pval
}
}

hclust(dist(mx))
}

#' @keywords internal
bestPartition <- function(freqs.tmp, groups){

Expand Down Expand Up @@ -363,5 +335,4 @@ sbpInNodes <- function(tree){
sbp <- t(sbp)

return(sbp)

}
170 changes: 0 additions & 170 deletions R/coda_trees.R

This file was deleted.

0 comments on commit dab8cb5

Please sign in to comment.