-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathsc_grn.m
More file actions
72 lines (68 loc) · 2.55 KB
/
sc_grn.m
File metadata and controls
72 lines (68 loc) · 2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
function A = sc_grn(X, type, varargin)
%SC_GRN Construct single-cell gene regulatory network (scGRN)
%
% A = sc_grn(X) uses default type 'pcrnet'.
% A = sc_grn(X, type) where type is one of:
% 'pcrnet' - principal component regression (parallel by default)
% 'pcrnet_batch' - PCR (batch pagesvd)
% 'pcrnet_denoised' - tensor-denoised PCR (robust, slow)
% 'genie3' - random forest ensemble (slow)
% 'pearson' - thresholded Pearson correlation
% 'xicor' - Chatterjee's xi correlation (nonlinear)
% 'distcorr' - distance correlation (nonlinear, symmetric)
% 'mi' - mutual information (parallel)
% 'grnformer' - GRNFormer graph transformer (Hegde & Cheng 2026)
%
% For 'grnformer', additional arguments are required / supported:
% A = sc_grn(X, 'grnformer', tf_idx)
% A = sc_grn(X, 'grnformer', tf_idx, 'GroundTruth', GT, ...)
% where tf_idx is a logical or integer index vector of TF genes, and
% remaining name-value pairs are forwarded to net.grnformer.
%
% All methods are implemented in the +net/ package.
% See also: net.pcrnet, net.genie3, net.xicornet, net.grnformer
arguments
X {mustBeNumeric}
type (1,1) string = "pcrnet"
end
arguments (Repeating)
varargin
end
type = lower(string(type));
validTypes = ["pcrnet" "pcrnet_batch" "pcrnet_denoised" ...
"genie3" "pearson" "xicor" "distcorr" "mi" "grnformer"];
if ~ismember(type, validTypes)
error("sc_grn:InvalidType", ...
"Type must be one of: %s", strjoin(validTypes, ", "));
end
switch type
case "pcrnet"
A = net.pcrnet(X, 3, false, true, false, false, pkg.i_usegpu(X));
case "pcrnet_batch"
A = net.pcrnet_batch(X);
case "pcrnet_denoised"
A = net.pcrnet_denoised(X);
case "genie3"
A = net.genie3(X, [], true);
case "pearson"
A = net.pearsonnet(X);
case "xicor"
A = net.xicornet(X);
case "distcorr"
A = net.distcorrnet(X);
case "mi"
A = net.minet(X);
case "grnformer"
if isempty(varargin)
error("sc_grn:MissingTFIdx", ...
"grnformer requires tf_idx as the third argument.\n" + ...
" Usage: sc_grn(X, 'grnformer', tf_idx, ...)");
end
tf_idx = varargin{1};
extra = varargin(2:end);
A = net.grnformer(X, tf_idx, extra{:});
otherwise
% Should not reach here — type is validated by ismember check above
error('sc_grn:InvalidType', 'Unknown GRN type: %s', type);
end
end