ClusterDepth

Comparison to permuco R implementation

The implementation to Permuco is similar, but ClusterDepth.jl is more barebone - that is, we dont offer many permutation schemes, focus on the ClusterDepth Algorithm, and don't provide the nice wrappers like clusterLM.

Timing wise, a simple test on 50 subjects, 100 repetitions, 5000 permutations shows the following results:

timepointsClusterDepth.jlpermucojulia-speedup
400.03s2.9s~100x
4000.14s22s~160x
40001.88s240s~120x
ClusterDepth.calc_clusterdepthMethod

calc_clusterdepth(data,τ)

returns tuple with three entries: 1:maxLength, maximal clustervalue per clusterdepth head, same for tail

We assume data and τ have already been transformed for one/two sided testing, so that we can do d0.>τ for finding clusters

ClusterDepth.clusterMethod

finds neighbouring clusters in the vector and returns start + length vectors

if the first and last cluster start on the first/last sample, we dont know their real depth

Input is assumed to be a thresholded Array with only 0/1
ClusterDepth.clusterdepthMethod

clusterdepth(rng,data::AbstractArray;τ=2.3, statFun=x->abs.(studentt(x)),permFun=signpermute!,nperm=5000,pvaltype=:troendle)

calculate clusterdepth of given datamatrix.

  • data: statFun will be applied on second dimension of data (typically this will be subjects)

Optional

  • τ: Cluster-forming threshold
  • statFun: default the one-sample studenttest, can be any custom function on a Matrix returning a Vector
  • permFun: default to sign-flip (for one-sample case)
  • nperm: number of permutations, default 5000
  • pval_type: how to calculate pvalues within each cluster, default :troendle, see ?pvals
ClusterDepth.multicol_minimumMethod
calculates the minimum in `X` along `dims=2` in the columns specified by àrrayOfIndicearrays` which could be e.g. `[[1,2],[5,6],[3,4,7]]`
ClusterDepth.pvalsMethod

pvals(data;kwargs...) = pvals(data[2:end],data[1];kwargs...)

pvals(data::AbstractVector,stat::Real;type=:twosided)

calculates pvalues based on permutation results

if called with stat, first entry is assumed to be the observation

ClusterDepth.troendleMethod

function troendle(perm::AbstractMatrix,stat::AbstractVector;type=:twosided)

Multiple Comparison Correction as in Troendle 1995

perm with size ntests x nperms

stat with size ntests

type can be :twosided (default), :lesser, :greater

Heavily inspired by the R implementation in permuco from Jaromil Frossard

Note: While permuco is released under BSD, the author Jaromil Frossard gave us an MIT license for the troendle and the clusterdepth R-functions.