% ==== 固定参数(按需改动路径) ====
repo = 'F:\Matlab.workspace\4DNvestigator';
juicerJar = fullfile(repo, 'juicer_tools.jar'); % 建议 Juicer Tools 2.20.00
hicFile = 'E:\workspace\FenshuChrVar\48.heart.HiC\Erothschildi.heart.hic';
outDir = 'E:\workspace\FenshuChrVar\48.heart.HiC\VNE_allchr_fixed';
bpFrag = 'BP';
normName = 'KR';
binSize = 1e5; % 固定分辨率:100 kb
% ==== 环境 ====
cd(repo); addpath(genpath(repo));
if ~exist(outDir,'dir'), mkdir(outDir); end
% ==== 主流程:Chr1..Chr31,整条染色体一次性计算 ====
chroms = 1:29;
VNE = nan(numel(chroms),1);
for idx = 1:numel(chroms)
c = chroms(idx);
chrArg = sprintf('Chr%d', c); % 你的 .hic 命名为 ChrN
dumpTxt = fullfile(outDir, sprintf('dump_%s_%dkb.txt', chrArg, binSize/1000));
cmd = sprintf('java -jar "%s" dump oe %s "%s" %s %s %s %d "%s"', ...
juicerJar, upper(normName), hicFile, chrArg, chrArg, upper(bpFrag), binSize, dumpTxt);
st = system(cmd);
if st~=0 || ~exist(dumpTxt,'file') || dir(dumpTxt).bytes==0
% 若极少数样本并非 ChrN 命名,可试备用命名(chrN)
chrArg2 = sprintf('chr%d', c);
dumpTxt = fullfile(outDir, sprintf('dump_%s_%dkb.txt', chrArg2, binSize/1000));
cmd = sprintf('java -jar "%s" dump oe %s "%s" %s %s %s %d "%s"', ...
juicerJar, upper(normName), hicFile, chrArg2, chrArg2, upper(bpFrag), binSize, dumpTxt);
st = system(cmd);
if st~=0 || ~exist(dumpTxt,'file') || dir(dumpTxt).bytes==0
warning('Chr%d 无法导出(命名或分辨率不存在),VNE=NaN', c);
VNE(idx) = NaN; continue
end
end
M = readmatrix(dumpTxt);
if isempty(M) || size(M,2)<3
warning('Chr%d dump 文件异常,VNE=NaN', c);
VNE(idx) = NaN; continue
end
i0 = double(M(:,1)); j0 = double(M(:,2)); v = double(M(:,3));
if max([i0; j0]) > 1e7
% dump 输出为坐标,转为 bin 索引
i = floor(i0./binSize) + 1;
j = floor(j0./binSize) + 1;
else
% dump 输出为 0-based bin 索引,转 1-based
i = i0 + 1;
j = j0 + 1;
end
nBins = max([i; j]);
if nBins < 2
warning('Chr%d nBins<2,VNE=NaN', c);
VNE(idx) = NaN; continue
end
S = sparse(i, j, v, nBins, nBins);
S = S + S.' - spdiags(diag(S), 0, nBins, nBins); % 对称化
% 4DNvestigator 默认:先做相关矩阵,再算 VNE
H = full(S); % 注意:这里会占用 O(nBins^2) 内存
VNE(idx) = hicEntropy(H, [], [], 'corr');
fprintf('Chr%d 完成,%dkb,nBins=%d,VNE=%.4f\n', c, binSize/1000, nBins, VNE(idx));
end
T = table(chroms(:), VNE, 'VariableNames', {'chrom','VNE'});
outTsv = fullfile(outDir, sprintf('VNE_allchr_%dkb.tsv', binSize/1000));
writetable(T, outTsv, 'FileType','text','Delimiter','\t');
disp('完成,结果表:'); disp(outTsv);
仅作个人笔记 使用4DNvestigator计算VNE
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
相关阅读更多精彩内容
- 仅作为个人笔记使用 bgzip -c input.vcf > input.vcf.gztabix -p vcf i...
- RepeatMask 2.让我们转战R 分歧度 = 突变率 * 分化时间e. g. () 括号里面的是单位8.15...
- 服装业是一个永续产业,在经历了产业化、品牌化的改造后,中国服装业迎来了一个新的发展机遇期。随着经济发展以及二...