Skip to content

Commit

Permalink
Merge branch 'f-top5pct-overexpressed'
Browse files Browse the repository at this point in the history
-- converts up_ and down_ genes outlier analysis output files to blobs2
-- adds top5% overexpressed outlier analysis file
  • Loading branch information
e-t-k committed Jul 22, 2016
2 parents 3def33d + d2de7f2 commit 9fda00a
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 15 deletions.
4 changes: 4 additions & 0 deletions config/ekephart/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export MONGO_URL="mongodb://localhost:27017/MedBook"
export MEDBOOK_FILESTORE=/tmp/filestore

meteor --port 3003 --settings ../config/ekephart/settings.json
12 changes: 12 additions & 0 deletions config/ekephart/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"sh": "/bin/sh",
"rscript": "Rscript",
"limma_path": "/Users/ekephart/code/jobrunner/external-tools/limma/limma_ng.R",
"outlier_analysis": "/Users/ekephart/code/jobrunner/external-tools/OutlierAnalysis/outlier-analysis.sh",
"calculate_outlier_genes": "/Users/ekephart/code/jobrunner/external-tools/OutlierAnalysis/calculate_outlier_genes.R",
"genomic_expression_export": "/Users/ekephart/code/jobrunner/external-tools/exporters/genomic_expression_export.py",
"gene_set_collection_export": "/Users/ekephart/code/jobrunner/external-tools/exporters/gene_set_collection_export.py",
"limma_phenotype_export": "/Users/ekephart/code/jobrunner/external-tools/exporters/limma_phenotype_export.py",
"gsea_path": "/Users/ekephart/code/jobrunner/external-tools/gsea/rgGSEA.py",
"gsea_jar_path": "/Users/ekephart/code/jobrunner/external-tools/gsea/gsea2-2.2.2.jar"
}
60 changes: 46 additions & 14 deletions webapp/server/classes/UpDownGenes.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,17 +129,37 @@ UpDownGenes.prototype.run = function () {
// calculate the paths for the output files
upPath = path.join(workDir, "up_outlier_genes")
downPath = path.join(workDir, "down_outlier_genes")
top5Path = path.join(workDir, "top_5_percent_most_highly_expressed_genes.tsv")

// insert blobs into mongo
var output = {
up_blob_id: Blobs.insert(upPath)._id,
down_blob_id: Blobs.insert(downPath)._id,

// Save output files as Blobs2 "synchronously" with wrapAsync

var output = {};
var associated_job_object = {
collection_name: "Jobs",
mongo_id: self.job._id,
};
var createBlob2Sync = Meteor.wrapAsync(Blobs2.create);

try{
var upGenesBlob = createBlob2Sync(upPath, associated_job_object, {});
var downGenesBlob = createBlob2Sync(downPath, associated_job_object, {});
var top5blob = createBlob2Sync(top5Path, associated_job_object, {});
output["up_blob_id"] = upGenesBlob._id;
output["down_blob_id"] = downGenesBlob._id;
output["top5percent_blob_id"] = top5blob._id;
}catch(error){
// Log the error and throw it again to properly fail the outlier analysis job
console.log("Error storing output files for Outlier Analysis:", error);
throw(error);
}


// parse strings
_.each([
{ name: "up_genes", fileString: fs.readFileSync(upPath, "utf8") },
{ name: "down_genes", fileString: fs.readFileSync(downPath, "utf8") },
{ name: "up_genes", fileString: fs.readFileSync(upGenesBlob.getFilePath(), "utf8") },
{ name: "down_genes", fileString: fs.readFileSync(downGenesBlob.getFilePath(), "utf8") },
{ name: "top5percent_genes", fileString: fs.readFileSync(top5blob.getFilePath(), "utf8") },
], function (outlier) {
var lineArray = outlier.fileString.split("\n");
var filteredLines = _.filter(lineArray, function (line) {
Expand All @@ -148,19 +168,31 @@ UpDownGenes.prototype.run = function () {

// loop for each line
output[outlier.name] = _.map(filteredLines, function (line) {
var tabSplit = line.split(" ");
return {
gene_label: tabSplit[0],
background_median: parseFloat(tabSplit[1]),
sample_value: parseFloat(tabSplit[2]),
};
// Populate the found genes.
// The top5percent overexpressed file has a different format from the
// other files so split its columns separately.
if(outlier.name == "top5percent_genes"){
var tabSplit = line.split("\t");
return {
gene_label: tabSplit[0],
sample_value: parseFloat(tabSplit[1]),
// no background_median
}
}else{
var tabSplit = line.split(" ");
return {
gene_label: tabSplit[0],
background_median: parseFloat(tabSplit[1]),
sample_value: parseFloat(tabSplit[2]),
};
}
});
});

deferred.resolve(output);
}, deferred.reject))
// NOTE: Meteor.bindEnvironment returns immidiately, meaning we can't
// quite use the nice promise syntax of chainging .thens
// NOTE: Meteor.bindEnvironment returns immediately, meaning we can't
// quite use the nice promise syntax of chaining .thens
.catch(deferred.reject);
return deferred.promise;
};
Expand Down

0 comments on commit 9fda00a

Please sign in to comment.