Hierarchially-cluster distance matrix using flashClust package.

dist2hclust(d.mat, method = "average", ...)

Arguments

d.mat

distance matrix

method

hierarchial-clustering method. Default is "average". See flashClust for options.

...

Additional arguments passed to flashClust flashClust package

Value

hclust object

See also

flashClust

Author

Nicholas Mikolajewicz

Examples


# Get expression matrix
which.data <- "scale"

# variable gene only matrix
use.var <- T
if (use.var){
  exp.mat <- getExpressionMatrix(so.query, only.variable = use.var, which.data = which.data, use.additional.genes = NA)
} else {
  exp.mat <- exp.mat.complete
}
#> Error in DefaultAssay(so): object 'so.query' not found


# transpose expressio matrix (genes are columns)
t.exp.mat <- t(exp.mat)
#> Error in t(exp.mat): object 'exp.mat' not found
datExpr <- as.matrix(t.exp.mat)
#> Error in as.matrix(t.exp.mat): object 't.exp.mat' not found
SubGeneNames=colnames(datExpr)
#> Error in is.data.frame(x): object 'datExpr' not found

# capture output used to hide undesired print statement
print2hide <- capture.output(allowWGCNAThreads())
#> Error in allowWGCNAThreads(): could not find function "allowWGCNAThreads"

# transform matrix if necessary
if (min(datExpr) < 0) {
  datExpr.noz <- datExpr + abs(min(datExpr))
} else {
  datExpr.noz <- datExpr
}
#> Error in eval(expr, envir, enclos): object 'datExpr' not found

# run WGCNA
output.all <- runWGCNA(datExpr.noz, cor.metric = "rho_p", soft.power = 2, use.TOM = T)
#> 2022-08-03 14:42:07: Computing similarity matrix...
#> Error in loadNamespace(x): there is no package called 'dismay'

# unpack output
s.mat <- output.all[["s.mat"]] # similar matrix
#> Error in eval(expr, envir, enclos): object 'output.all' not found
a.mat <- output.all[["a.mat"]] # adjacency matrix
#> Error in eval(expr, envir, enclos): object 'output.all' not found
w.mat <- output.all[["w.mat"]] # topological overlap matix
#> Error in eval(expr, envir, enclos): object 'output.all' not found
d.mat <- output.all[["d.mat"]] # disimilarity matix
#> Error in eval(expr, envir, enclos): object 'output.all' not found

geneTree <- dist2hclust(d.mat)
#> Error in stopifnot(any(class(d.mat) == "matrix")): object 'd.mat' not found