Skip to content

Commit

Permalink
synced with private copy
Browse files Browse the repository at this point in the history
  • Loading branch information
benslice committed Jul 13, 2019
1 parent 3761da5 commit 62dac31
Show file tree
Hide file tree
Showing 13 changed files with 17,453 additions and 278 deletions.
36 changes: 36 additions & 0 deletions IO/load_smf.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
function [file_smfit, file_smfit_std] = load_smf(smfitnessfile, sgadata, lfid)
% function [file_smfit, file_smfit_std] = load_smf(smfitnessfile, sgadata, lfid)

smf_fid = fopen(smfitnessfile, 'r');
fitness_data = struct();
fitness_data.raw = textscan(smf_fid, '%s%f%f', 'Delimiter', '\t', 'ReturnOnError', false);
fclose(smf_fid);
fitness_data.ORF = fitness_data.raw{1};
fitness_data.SMF = fitness_data.raw{2};
fitness_data.STD = fitness_data.raw{3};
fitness_report_header = {'Exact match', 'Partial Match', 'Not Found', 'NaN in file'};
fitness_report_counts = zeros(1,4);
fitness_hash = hash_strings(fitness_data.ORF);

file_smfit = zeros(length(sgadata.orfnames),1) + NaN;
file_smfit_std = zeros(length(sgadata.orfnames),1) + NaN;
for i=1:length(sgadata.orfnames)
if fitness_hash.containsKey(sgadata.orfnames{i})
file_smfit(i) = fitness_data.SMF(fitness_hash.get(sgadata.orfnames{i}));
file_smfit_std(i) = fitness_data.STD(fitness_hash.get(sgadata.orfnames{i}));
fitness_report_counts(1) = fitness_report_counts(1)+1;
elseif fitness_hash.containsKey(strip_annotation(sgadata.orfnames{i}, 'last'))
file_smfit(i) = fitness_data.SMF(fitness_hash.get(strip_annotation(sgadata.orfnames{i}, 'last')));
file_smfit_std(i) = fitness_data.STD(fitness_hash.get(strip_annotation(sgadata.orfnames{i}, 'last')));
fitness_report_counts(2) = fitness_report_counts(2)+1;
else
fitness_report_counts(3) = fitness_report_counts(3)+1;
end
end
fitness_report_counts(4) = sum(isnan(file_smfit)) - fitness_report_counts(3);

log_printf(lfid, 'Fitness file report:\n');
for i=1:length(fitness_report_header)
log_printf(lfid, '\t%s\t: %d\n', fitness_report_header{i}, fitness_report_counts(i));
end
end
26 changes: 13 additions & 13 deletions IO/output_interaction_data.m
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
%%
% OUTPUT_INTERACTION_DATA - prints out the calculated genetic interactions into a tab delimited text file.
% OUTPUT_INTERACTION_DATA - prints out the calculated genetic interactions
% into a tab delimited text file.
%
%
% Inputs:
% Authors: Chad Myers ([email protected]),
% Anastasia Baryshnikova ([email protected])
% Benjamin VanderSluis ([email protected])
%
% Authors: Chad Myers ([email protected]), Anastasia Baryshnikova ([email protected])
%
% Last revision: 2010-07-19
% Last revision: 2017-12-12
%
%%

function output_interaction_data(outputfile,orfnames,escores,escores_std,background_mean,background_std,smfit,smfit_std,dm_expected,dm_actual,dm_actual_std,lfid)

pvals = sqrt(normcdf(-abs(escores./escores_std)) .* normcdf(-abs(log((background_mean + escores)./background_mean) ./ log(background_std) )));
function output_interaction_data(outputfile, orfnames, escores, escores_std, ...
pvals, smfit, smfit_std, dm_expected, dm_actual, dm_actual_std, lfid)

log_printf(lfid, ['Printing output file...\n|' blanks(50) '|\n|']);

Expand All @@ -21,26 +21,26 @@ function output_interaction_data(outputfile,orfnames,escores,escores_std,backgro
for j = 1:length(escores)
if ~isnan(escores(i,j))
fprintf(fid,'%s\t%s\t%f\t%f\t%e\t%f\t%f\t%f\t%f\t%f\t%f\t%f\n', ...
orfnames{i}, orfnames{j}, escores(i,j), escores_std(i,j), pvals(i,j), ...
orfnames{i}, orfnames{j}, escores(i,j), escores_std(i,j), ...
pvals(i,j), ...
smfit(i), smfit_std(i), smfit(j), smfit_std(j), ...
dm_expected(i,j), dm_actual(i,j), dm_actual_std(i,j));
end
end

% Print progress
print_progress(lfid, length(escores), i);

end
fclose(fid);

% only output an orf if it has scores
% bad arrays are appearing otherwise
% output the list of strains, but only if they have scores
% otherwise bad arrays appear
valid_queries = orfnames(sum(~isnan(escores),2)>0);
valid_arrays = orfnames(sum(~isnan(escores),1)>0);
valid_orfs = union(valid_queries, valid_arrays);
fid = fopen([outputfile '.orf'], 'w');
for i=1:length(valid_orfs)
fprintf(fid, '%s\n', valid_orfs{i});
fprintf(fid, '%s\n', valid_orfs{i});
end
fclose(fid);

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ SAFE-ENTRY points
The script has a number of places marked:
`% SAFE ENTRY`
Which means "The only variables which change after this point, are created after this point."
These have been determined by manual inspection and are by no means exhaustive. They are used to resme
These have been determined by manual inspection and are by no means exhaustive. They are used to resume
the script mid-execution to save time when testing changes. I generally use this procedure:
- Locate the position of the change you wish to test (line XXX)
- Locate the first SAFE ENTRY above XXX, (line YYY)
Expand Down
Loading

0 comments on commit 62dac31

Please sign in to comment.