Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
hanjunlee21 committed Feb 14, 2024
1 parent 298f691 commit 369920e
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 0 deletions.
63 changes: 63 additions & 0 deletions HiChIP/loopClassification.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
clear all;

cases = ["EE"; "EP"; "PP"];

opts = delimitedTextImportOptions("NumVariables", 8);

% Specify range and delimiter
opts.DataLines = [1, Inf];
opts.Delimiter = " ";

% Specify column names and types
opts.VariableNames = ["VarName1", "VarName2", "Var3", "Var4", "Var5", "Var6", "Var7", "Var8"];
opts.SelectedVariableNames = ["VarName1", "VarName2"];
opts.VariableTypes = ["string", "string", "string", "string", "string", "string", "string", "string"];

% Specify file level properties
opts.ExtraColumnsRule = "ignore";
opts.EmptyLineRule = "read";
opts.LeadingDelimitersRule = "ignore";

% Specify variable properties
opts = setvaropts(opts, ["VarName1", "VarName2", "Var3", "Var4", "Var5", "Var6", "Var7", "Var8"], "WhitespaceRule", "preserve");
opts = setvaropts(opts, ["VarName1", "VarName2", "Var3", "Var4", "Var5", "Var6", "Var7", "Var8"], "EmptyFieldRule", "auto");

EE = readmatrix(strcat("Merged.loops.Q0.01.",cases(1,1),".count"),opts);
EP = readmatrix(strcat("Merged.loops.Q0.01.",cases(2,1),".count"),opts);
PP = readmatrix(strcat("Merged.loops.Q0.01.",cases(3,1),".count"),opts);

loops = readmatrix(strcat("Merged.loops.Q0.01.list"),'Delimiter','\t','FileType','text','OutputType','string');

mat = strings(size(loops,1),5);
mat(:,1) = loops;

for i = 1:size(loops,1)
for j = 1:size(cases,1)
if j == 1
det = EE(strcmp(EE(:,2),loops(i,1)),:);
elseif j == 2
det = EP(strcmp(EP(:,2),loops(i,1)),:);
elseif j == 3
det = PP(strcmp(PP(:,2),loops(i,1)),:);
end

if size(det,1) > 0
mat(i,j+2) = det(1,1);
else
mat(i,j+2) = "0";
end
end

tuple = str2double(mat(i,3:5).');
if sum(tuple) == 0
mat(i,2) = "NA";
else
[~,idx] = max(tuple);
mat(i,2) = cases(idx,1);
end
end

for j = 1:size(cases,1)
submat = mat(strcmp(mat(:,2),cases(j,1)),1);
writematrix(submat,strcat("Merged.loops.Q0.01.",cases(j,1),".bedpe"),'FileType','text','Delimiter','\t');
end
25 changes: 25 additions & 0 deletions HiChIP/pairToPeak.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

bed="../bed"
pair="../pair"
loop="../loop"

thres="100000"

mkdir -p ${pair}/H3K27ac

task() {
awk '{printf "%s\t%s\t%s\t%s\t%s\t%s\t%s\t.\t%s\t%s\n", $2,$3,$3+1,$5,$6,$6+1,$1,$4,$7}' ${pair}/${1}/${1}.allValidPairs > ${pair}/${1}.validPairs.bedpe
pairToBed -type both -a ${pair}/${1}.validPairs.bedpe -b ${bed}/H3K27ac.bed > ${pair}/H3K27ac/${1}.H3K27ac.validPairs.bedpe
pairToBed -type both -a ${pair}/H3K27ac/${1}.H3K27ac.validPairs.bedpe -b ${bed}/H3K27ac.Enhancer.bed > ${pair}/H3K27ac/${1}.H3K27ac.EE.validPairs.bedpe
pairToBed -type xor -a ${pair}/H3K27ac/${1}.H3K27ac.validPairs.bedpe -b ${bed}/H3K27ac.Enhancer.bed > ${pair}/H3K27ac/${1}.H3K27ac.EP.validPairs.bedpe
pairToBed -type both -a ${pair}/H3K27ac/${1}.H3K27ac.validPairs.bedpe -b ${bed}/H3K27ac.Promoter.bed > ${pair}/H3K27ac/${1}.H3K27ac.PP.validPairs.bedpe
}

for file in WTCI KOCI
do
task "${file}" &
done
printf "Running...\n"
wait
printf "Completed\n"

0 comments on commit 369920e

Please sign in to comment.