Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Combined scores into a single Triangulation Score.
Code for UI to be integrated shortly.
  • Loading branch information
ajt06004 committed Jul 5, 2018
1 parent cda6001 commit 82808cf
Show file tree
Hide file tree
Showing 12 changed files with 956 additions and 141 deletions.
6 changes: 5 additions & 1 deletion src/edu/uconn/tripoint/export/PathwayGeneCytoscapeNode.java
Expand Up @@ -39,7 +39,11 @@ public class PathwayGeneCytoscapeNode extends CytoscapeNode {
sb.append("\"impact_pval\" : "+_tg.getImpactPValue(_pathway)+",\n");
sb.append("\"impact_qval\" : "+_tg.getImpactFDR(_pathway)+",\n");
sb.append("\"noncoding_count\" : "+_noncodingcount+",\n");
sb.append("\"noncoding_count_pval\" : "+_ncp+"\n");
sb.append("\"noncoding_count_pval\" : "+_ncp+",\n");
sb.append("\"triangulation\" : "+_tg.getTriangulationScore(_pathway)+",\n");
sb.append("\"triangulation_pval\" : "+_tg.getTriangulationPValue(_pathway)+",\n");
sb.append("\"triangulation_qval\" : "+_tg.getTriangulationFDR(_pathway)+"\n");

sb.append("}\n");
sb.append("}\n");
return sb.toString();
Expand Down
21 changes: 8 additions & 13 deletions src/edu/uconn/tripoint/export/TriangulationExport.java
Expand Up @@ -32,9 +32,9 @@ public class TriangulationExport {
"Support Score"+"\t"+"Support p-value"+"\t"+"Support q-value"+"\t"+
"Consistency Score"+"\t"+"Consistency p-value"+"\t"+"Consistency q-value"+"\t"+
"Impact Score"+"\t"+"Impact p-value"+"\t"+"Impact q-value"+"\t"+
//"Supporting Triangulation Score"+"\t"+"Supporting Triangulation p-value"+"\t"+"Supporting Triangulation q-value"+"\t"+
//"Inconsistent Triangulation Score"+"\t"+"Inconsistent Triangulation p-value"+"\t"+"Inconsistent Triangulation q-value"+"\t"+
"Number of NonCoding Targets"+"\t"+"NonCoding Poisson p-value"+"\n");
"Number of NonCoding Targets"+"\t"+"NonCoding Poisson p-value"+"\t"+
"Triangulation Score"+"\t"+"Triangulation p-value"+"\t"+"Triangulation q-value"+"\t"+"\n");

for(Iterator<TriangulatedGene> it = genes.iterator(); it.hasNext();){
TriangulatedGene next = it.next();
for(Iterator<Pathway> it2 = genepathways.get(next.getGene()).iterator(); it2.hasNext();){
Expand Down Expand Up @@ -70,13 +70,9 @@ public class TriangulationExport {
double imp = g.getImpactPValue(pid);
double imfdr = g.getImpactFDR(pid);

//double stris = g.getSupportTriangulationScore(pid);
//double strip = g.getSupportTriangulationPValue(pid);
//double strifdr = g.getSupportingTriangulationFDR(pid);

//double itris = g.getInconsistentTriangulationScore(pid);
//double itrip = g.getInconsistentTriangulationPValue(pid);
//double itrifdr = g.getInconsistentTriangulationFDR(pid);
double tris = g.getTriangulationScore(pid);
double trip = g.getTriangulationPValue(pid);
double trifdr = g.getTriangulationFDR(pid);

List<Location> l = noncoding.get(gene);
int nccount = l != null ? l.size() : 0;
Expand All @@ -88,9 +84,8 @@ public class TriangulationExport {
ss+"\t"+sp+"\t"+sfdr+"\t"+
cs+"\t"+cp+"\t"+cfdr+"\t"+
ims+"\t"+imp+"\t"+imfdr+"\t"+
//stris+"\t"+strip+"\t"+strifdr+"\t"+
//itris+"\t"+itrip+"\t"+itrifdr+"\t"+
nccount+"\t"+ncp+"\n");
nccount+"\t"+ncp+"\t"+
tris+"\t"+trip+"\t"+trifdr+"\n");
}

}
25 changes: 17 additions & 8 deletions src/edu/uconn/tripoint/integration/PoissonNonCoding.java
Expand Up @@ -26,16 +26,25 @@ public class PoissonNonCoding {
average += size;
max = Math.max(max, size);
}
average /= m.size();

BigDecimal[] distr = getCumulativePoisson(max,average);

Map<Gene,Double> rv = new TreeMap<Gene, Double>();
for(Iterator<Entry<Gene, List<Location>>> it = m.entrySet().iterator(); it.hasNext();){
Entry<Gene, List<Location>> e = it.next();
rv.put(e.getKey(), getPoissonPValue(distr, e.getValue().size(), average));
if(max == 0){
Map<Gene,Double> rv = new TreeMap<Gene, Double>();
for(Iterator<Entry<Gene, List<Location>>> it = m.entrySet().iterator(); it.hasNext();){
Entry<Gene, List<Location>> e = it.next();
rv.put(e.getKey(), 1d);
}
return rv;
}
else{
average /= m.size();
BigDecimal[] distr = getCumulativePoisson(max,average);
Map<Gene,Double> rv = new TreeMap<Gene, Double>();
for(Iterator<Entry<Gene, List<Location>>> it = m.entrySet().iterator(); it.hasNext();){
Entry<Gene, List<Location>> e = it.next();
rv.put(e.getKey(), getPoissonPValue(distr, e.getValue().size(), average));
}
return rv;
}
return rv;
}

/**
Expand Down
49 changes: 46 additions & 3 deletions src/edu/uconn/tripoint/triangulation/ProgramParameters.java
Expand Up @@ -7,7 +7,7 @@ import java.io.IOException;

public class ProgramParameters {

public final double VERSION = 1.0;
public final double VERSION = 1.1;
//required
private String _expfile;
private String _db;
Expand All @@ -28,7 +28,50 @@ public class ProgramParameters {
private String _chrinter;
private String _nct;
private int _prox = 50000;


public ProgramParameters(String expfile, String db, String outdir,
String nct, String ci, String refflat, Integer prox,
double down, double up, double w, double p, double r, int perm, long rstate){
_down = -0.05;
_up = 0.05;
_w = 0.2;
_p = 0.25;
_r = 0.25;
_gid = "SYMBOL";
_perm = 10000;
_rstate = System.currentTimeMillis();


_expfile = expfile;
_db = db;
_outdir = outdir;

if(nct != null && !nct.equals("")){
_nct = nct;
}

if(ci != null && !ci.equals("")){
_chrinter = ci;
}

if(refflat != null && !refflat.equals("")){
_refflat = refflat;
}

if(prox != null){
_prox = prox;
}

_down = down;
_up = up;
_w = w;
_p = p;
_r = r;
_perm = perm;
_rstate = rstate;
}


public ProgramParameters(String[] args){
//set default values;
Expand Down Expand Up @@ -172,13 +215,13 @@ public class ProgramParameters {
public String getConsoleManual(){
StringBuilder sb = new StringBuilder();
sb.append("Version: "+VERSION+"\n");
sb.append("Usage:\t\t\tjava -jar tripoint.jar <expression file> -db <pathway database> -o <output directory>\n\n");
sb.append("Usage:\t\t\tjava -jar tripoint.jar <expression file> -db <pathway database> -o <entire output directory path>\n\n");
sb.append("-db\t\t\tSets pathway database to import pathways from GRAPHITE. Values available: \"kegg\", \"reactome\", \"biocarta\", \"humancyc\", \"nci\", \"panther\" \n\n");
sb.append("-o\t\t\tSets output directory for saving result files. REQUIRED\n\n");
sb.append("-gid\t\t\tSets the conversion method for gene identifiers. Refer to 'convertIdentifiers' in GRAPHITE. Default: \"SYMBOL\" (Currently other identifiers are not recommended)\n\n");
sb.append("-up\t\t\tSets the up-regulated gene threshold. Default: 0.05\n\n");
sb.append("-down\t\t\tSets the down-regulated gene threshold. Default: -0.05\n\n");
sb.append("-w\t\t\tSets the weak activation/inhibition factor. Default: 0.5\n\n");
sb.append("-w\t\t\tSets the weak activation/inhibition factor. Default: 0.2\n\n");
sb.append("-p\t\t\tControls the impact of gene expression when calculating measures. Default: 0.25\n\n");
sb.append("-r\t\t\tControls the rate of exponential decay to control edge distance in impact score calculation. Default: 0.25\n\n");
sb.append("-perm\t\t\tSets the number of permutations for p-value calculations. Default: 10000\n\n");
Expand Down
35 changes: 20 additions & 15 deletions src/edu/uconn/tripoint/triangulation/Run.java
Expand Up @@ -28,6 +28,7 @@ public class Run {
}

public void run(String[] args){
long timestart = System.currentTimeMillis();
ProgramParameters params = new ProgramParameters(args);
if(params.hasRequired()){
//Step 1: Import the pathways from Graphite (needs Rserve started to work)
Expand All @@ -53,18 +54,13 @@ public class Run {
e.printStackTrace();
}

//Step 3: Run Triangulation.
Triangulation t = new Triangulation();
t.runTriangulation(globalpathway, pathways, g.values(), params.getDownThresh(), params.getUpThresh(), params.getW(), params.getP(), params.getR());

System.out.println("Running permutations:");
//Step 4: Run Permutations
t.runPermutations(g.values(), params.getNumPermutations(), params.getRandomState(), globalpathway, pathways, params.getDownThresh(), params.getUpThresh(), params.getW(), params.getP(), params.getR());


//Optional & Output Steps:
Map<Gene,List<Location>> m = new TreeMap<Gene,List<Location>>();
Map<Gene,Double> ncp = new TreeMap<Gene,Double>();
PoissonNonCoding pnc = new PoissonNonCoding();
if(params.hasNonCoding()){

Util u = new Util();
Map<Gene, List<Location>> refflat = null;
try {
Expand All @@ -89,20 +85,28 @@ public class Run {
Proximal p = new Proximal(params.getNonCodingTargets(), params.getProximityDistance());
m = p.getNoncodingTargets(g.values(), refflat);
}
//Export Noncoding Targets
}


//Step 3: Run Triangulation.
Triangulation t = new Triangulation();
t.runTriangulation(globalpathway, pathways, g.values(), params.getDownThresh(), params.getUpThresh(), params.getW(), params.getP(), params.getR(), m);

System.out.println("Running permutations:");
//Step 4: Run Permutations
t.runPermutations(g.values(), params.getNumPermutations(), params.getRandomState(), globalpathway, pathways, params.getDownThresh(), params.getUpThresh(), params.getW(), params.getP(), params.getR(), m);

if(params.hasNonCoding()){
NonCodingRegulatorExport ncte = new NonCodingRegulatorExport();
try {
ncte.ExportNonCodingTargets(globalpathway, pathways, t.getTriangulatedGenes(), m, params.getOutputDirectory(), params.getPathwayDB());
} catch (IOException e) {
e.printStackTrace();
}
ncp = pnc.getPoissonPValues(m);
}


Map<Gene,Double> ncp = new TreeMap<Gene,Double>();
PoissonNonCoding pnc = new PoissonNonCoding();
ncp = pnc.getPoissonPValues(m);



//Export Triangulation
TriangulationExport te = new TriangulationExport();
try {
Expand All @@ -128,6 +132,7 @@ public class Run {
else{
System.out.println(params.getConsoleManual());
}
System.out.println(System.currentTimeMillis()-timestart+" milliseconds.");
}


Expand Down

0 comments on commit 82808cf

Please sign in to comment.