A wrapper around pickSoftThreshold, allowing assessment and automatic selection of soft-thresholding power. Extends the function to accept a SummarizedExperiment as input and additionally considers mean connectivity when selecting the soft-thresholding power to recommend.
Usage
assessSoftThreshold(
X,
assay_name = "normal",
powerVector = 1:30,
RsquaredCut = 0.85,
max_mean_connectivity = 100,
cor_type = "pearson",
networkType = "signed",
maxBlockSize = 30000,
verbose = 0,
...
)
Arguments
- X
Either a SummarizedExperiment object or a matrix containing data to be subject to WGCNA.
X
should have rows as features and columns as samples.- assay_name
If
X
is a SummarizedExperiment, then this should be the name of the assay to be subject to WGCNA.- powerVector
a vector of soft thresholding powers for which the scale free topology fit indices are to be calculated.
- RsquaredCut
desired minimum scale free topology fitting index \(R^2\).
- max_mean_connectivity
The maximal mean connectivity required. Used to select the soft-thresholding power.
- cor_type
The type of correlation to be used to generate a correlation matrix during network formation. One of "pearson" (cor) and "bicor" (bicor).
- networkType
network type. Allowed values are (unique abbreviations of)
"unsigned"
,"signed"
,"signed hybrid"
. Seeadjacency
.- maxBlockSize
The chunk size (in terms of the number of features/genes) to process the data. The default (30000) should process standard transcriptomic datasets in a single chunk. Results may differ if the number of features exceeds the chunk size. Lower values of this parameter will use less memory to calculate networks.
- verbose
integer level of verbosity. Zero means silent, higher values make the output progressively more and more verbose.
- ...
Additional arguments to be passed to pickSoftThreshold.
Value
Returns a data.frame
,
generated by pickSoftThreshold,
with scale free topology fitting indices and connectivity statistics.
Additionally contains a column, estimated_power
, indicating the
recommended power to use (see details
). We suggest manually considering
suitability of the soft-thresholding power rather than solely relying on this
automated approach.
Details
The pickSoftThreshold function estimates the power by
selecting the lowest value with
a minimum scale free topology fitting index exceeding RsquaredCut
.
The assessSoftThreshold
function mirrors this behaviour when
max_mean_connectivity
is NULL
. When max_mean_connectivity
is
specified, however, we additionally require that the selected power
does not exceed this connectivity threshold.
Examples
# Get the airway data as a SummarizedExperiment (with a subset of features)
set.seed(2)
airway_se <- ReducedExperiment:::.getAirwayData(n_features = 500)
# Select soft-thresholding power to use (use capture.output to hide WGCNA's prints)
WGCNA::disableWGCNAThreads()
invisible(capture.output(fit_indices <- assessSoftThreshold(airway_se)))
print(fit_indices)
#> Power SFT.R.sq slope truncated.R.sq mean.k. median.k. max.k.
#> 1 1 0.97373476 4.37497452 0.97678336 352.16501 368.52191 407.89860
#> 2 2 0.96672406 1.97495579 0.96850130 267.60081 285.69185 347.56577
#> 3 3 0.95407607 1.11961826 0.96858471 212.93835 228.34352 303.88615
#> 4 4 0.92107951 0.67926991 0.96309461 174.88667 187.58621 270.38006
#> 5 5 0.64040489 0.39015719 0.67067877 146.99822 156.13856 244.08807
#> 6 6 0.55393693 0.20891195 0.68490811 125.76897 131.81807 222.61195
#> 7 7 0.04975859 0.05998254 -0.09435530 109.13153 113.32451 204.66870
#> 8 8 0.03477835 -0.04475320 -0.16599602 95.78809 97.72627 189.41085
#> 9 9 0.23180822 -0.13236151 0.05033018 84.88341 84.57444 176.25088
#> 10 10 0.40374249 -0.20119402 0.24259351 75.83150 73.65680 164.76664
#> 11 11 0.50107959 -0.27259016 0.35909683 68.21778 64.75420 154.64567
#> 12 12 0.61205559 -0.32960549 0.50133220 61.74095 56.98575 145.65091
#> 13 13 0.69143122 -0.36241104 0.60405527 56.17697 50.58051 137.59872
#> 14 14 0.81028643 -0.41264178 0.75612467 51.35598 45.23948 130.34429
#> 15 15 0.75508298 -0.47587523 0.69052525 47.14692 40.60976 123.77166
#> 16 16 0.79615137 -0.50472005 0.74533115 43.44718 36.38722 117.78672
#> 17 17 0.79264269 -0.53107137 0.74662031 40.17535 32.70747 112.31221
#> 18 18 0.76375938 -0.55977847 0.71727822 37.26604 29.54991 107.28404
#> 19 19 0.79368221 -0.57892685 0.76154459 34.66619 26.77611 102.64857
#> 20 20 0.82457975 -0.59926603 0.80373387 32.33233 24.33024 98.36052
#> 21 21 0.85011396 -0.62487423 0.83003406 30.22852 22.16597 94.38142
#> 22 22 0.87166503 -0.66149098 0.85969089 28.32482 20.33878 90.67833
#> 23 23 0.87011894 -0.68490231 0.85491230 26.59612 18.57022 87.22290
#> 24 24 0.86993071 -0.69988608 0.85715562 25.02117 17.00559 83.99059
#> 25 25 0.86721411 -0.72728045 0.85218514 23.58195 15.64122 80.96004
#> 26 26 0.87407690 -0.74146784 0.86897256 22.26303 14.49898 78.11257
#> 27 27 0.86160255 -0.75851008 0.85600744 21.05115 13.36425 75.43178
#> 28 28 0.87390039 -0.77026627 0.87160140 19.93487 12.41631 72.90321
#> 29 29 0.88325452 -0.78451767 0.87682193 18.90425 11.47621 70.51406
#> 30 30 0.90406958 -0.79794556 0.90343208 17.95063 10.65704 68.25295
#> estimated_power
#> 1 FALSE
#> 2 FALSE
#> 3 FALSE
#> 4 FALSE
#> 5 FALSE
#> 6 FALSE
#> 7 FALSE
#> 8 FALSE
#> 9 FALSE
#> 10 FALSE
#> 11 FALSE
#> 12 FALSE
#> 13 FALSE
#> 14 FALSE
#> 15 FALSE
#> 16 FALSE
#> 17 FALSE
#> 18 FALSE
#> 19 FALSE
#> 20 FALSE
#> 21 TRUE
#> 22 FALSE
#> 23 FALSE
#> 24 FALSE
#> 25 FALSE
#> 26 FALSE
#> 27 FALSE
#> 28 FALSE
#> 29 FALSE
#> 30 FALSE
print(paste0("Estimated power: ", fit_indices$Power[fit_indices$estimated_power]))
#> [1] "Estimated power: 21"