Run WGCNA analysis on scRNAseq expression matrix, using WGCNA R package.

runWGCNA(
  e.mat,
  s.mat = NULL,
  cor.metric = "rho_p",
  soft.power = 2,
  use.TOM = T,
  network.type = "signed",
  TOM.type = "unsigned",
  rescale.adjacency = F,
  verbose = T,
  ...
)

Arguments

e.mat

Expression matrix. Row entries are cells, column entries are genes. Colnames and rownames are expected.

s.mat

Similarity matrix (optional). If not provided, will be computed using method specfiied by cor.metric. If provided, s.mat is not recomputed.

cor.metric

Correction measure to use. Default is "rho_p". See "dismay" package for additional options.

soft.power

Soft power used to scale s.mat to a.mat (e.g., a.mat = s.mat ^ soft.power)

use.TOM

Logical flag specifying whether to compute topoligical overlap matrix. If false, w.mat = a.mat.

network.type

Network type. Allowed values are (unique abbreviations of) "unsigned", "signed" (default), "signed hybrid"

TOM.type

TOM type. Allowed values are "unsigned" (default) or "signed"

rescale.adjacency

Logical indicate whether adjacency matrix is rescaled to [0,1]. Default is False.

verbose

Print progress. Default is TRUE

...

Additional arguments passessed to TOMsimilarity WGCNA package

Value

List containing similarity matrix (s.mat), adacency matrix (a.mat), topological overlap matrix (w.mat) and disimilarity matrix (d.mat)

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 h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 't': object 'exp.mat' not found
datExpr <- as.matrix(t.exp.mat)
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'as.matrix': 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())

# 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:38: Computing similarity matrix...
#> Error in loadNamespace(x): there is no package called 'dismay'