[med-svn] [Git][med-team/chromhmm][upstream] New upstream version 1.26+dfsg
Dylan Aïssi (@daissi)
gitlab at salsa.debian.org
Mon Feb 3 21:09:20 GMT 2025
Dylan Aïssi pushed to branch upstream at Debian Med / chromhmm
Commits:
d70bc9da by Dylan Aïssi at 2025-02-03T21:58:33+01:00
New upstream version 1.26+dfsg
- - - - -
4 changed files:
- README.md
- edu/mit/compbio/ChromHMM/ChromHMM.java
- edu/mit/compbio/ChromHMM/StateAnalysis.java
- versionlog.txt
Changes:
=====================================
README.md
=====================================
@@ -1,2 +1,2 @@
-See https://ernstlab.biolchem.ucla.edu/ChromHMM/ for more information on ChromHMM.
+See https://ernstlab.github.io/ChromHMM/ for more information on ChromHMM.
========
=====================================
edu/mit/compbio/ChromHMM/ChromHMM.java
=====================================
@@ -5977,6 +5977,13 @@ public class ChromHMM
if (objMaxCoord != null)
{
nlastcoordinate = Math.min((numtime_nseq+noffset)*nbinsize,((Integer) objMaxCoord).intValue());
+
+ if (nstart*nbinsize >= nlastcoordinate)
+ {
+ //v1.26
+ throw new IllegalArgumentException("Start of interval "+(nstart*nbinsize+1)+" (1-based) is past the end of the chromosome "+nlastcoordinate+
+ "; Check if chromosome length file given to LearnModel is the same used for the binarization");
+ }
}
else
{
@@ -6114,6 +6121,13 @@ public class ChromHMM
if (objMaxCoord != null)
{
nlastcoordinate = Math.min((numtime_nseq+noffset)*nbinsize,((Integer) objMaxCoord).intValue());
+
+ if (nstart*nbinsize >= nlastcoordinate)
+ {
+ //v1.26
+ throw new IllegalArgumentException("Start of interval "+(nstart*nbinsize+1)+" (1-based) is past the end of the chromosome "+nlastcoordinate+
+ "; Check if chromosome length file given to LearnModel is the same used for the binarization");
+ }
}
else
{
@@ -7061,13 +7075,20 @@ public class ChromHMM
if (objMaxCoord != null)
{
nlastcoordinate = Math.min((numtime_nseq+noffset)*nbinsize,((Integer) objMaxCoord).intValue());
+
+ if (nstart*nbinsize >= nlastcoordinate)
+ {
+ //v1.26
+ throw new IllegalArgumentException("Start of interval "+(nstart*nbinsize+1)+" (1-based) is past the end of the chromosome "+nlastcoordinate+
+ "; Check if chromosome length file given to LearnModel is the same used for the binarization");
+ }
}
else
{
nlastcoordinate = (numtime_nseq+noffset)*nbinsize;
}
//pwbed.println(chromSeq[nordered_nseq]+"\t"+(nstart*nbinsize)+"\t"+nlastcoordinate+"\t"+chorder+(nmaxstateprev+1));
-
+
String szout = szactualchrom+"\t"+(nstart*nbinsize)+"\t"+nlastcoordinate+"\t"+chorder+(nmaxstateprev+1)+"\n";
byte[] btformat = szout.getBytes();
pwbedzip.write(btformat,0,btformat.length);
@@ -7197,6 +7218,13 @@ public class ChromHMM
if (objMaxCoord != null)
{
nlastcoordinate = Math.min((numtime_nseq+noffset)*nbinsize,((Integer) objMaxCoord).intValue());
+
+ if (nstart*nbinsize >= nlastcoordinate)
+ {
+ //v1.26
+ throw new IllegalArgumentException("Start of interval "+(nstart*nbinsize+1)+" (1-based) is past the end of the chromosome "+nlastcoordinate+
+ "; Check if chromosome length file given to LearnModel is the same used for the binarization");
+ }
}
else
{
@@ -13359,7 +13387,7 @@ public class ChromHMM
if (szcommand.equalsIgnoreCase("Version"))
{
- System.out.println("This is Version 1.25 of ChromHMM (c) Copyright 2008-2012 Massachusetts Institute of Technology");
+ System.out.println("This is Version 1.26 of ChromHMM (c) Copyright 2008-2012 Massachusetts Institute of Technology");
}
else if ((szcommand.equals("BinarizeBam"))||(szcommand.equalsIgnoreCase("BinarizeBed")))
{
@@ -14537,6 +14565,8 @@ public class ChromHMM
boolean blowmem = false;
boolean bprintimage = true;
+ boolean blogpvals = true;
+
int nr=ChromHMM.DEFAULTCOLOR_R;
int ng=ChromHMM.DEFAULTCOLOR_G;
int nb=ChromHMM.DEFAULTCOLOR_B;
@@ -14586,6 +14616,10 @@ public class ChromHMM
{
szinputcoordlist = args[++nargindex];
}
+ else if (args[nargindex].equals("-nopvals"))
+ {
+ blogpvals = false;
+ }
else if (args[nargindex].equals("-signal"))
{
busesignal = true;
@@ -14661,18 +14695,18 @@ public class ChromHMM
if (blowmem)
{
StateAnalysis.enrichmentMaxLowMem(szinput, szinputcoorddir,szinputcoordlist,noffsetleft,noffsetright,nbinsize,
- bcenter, bunique, busesignal,szcolfields,bbaseres, szoutfile,bcolscaleheat,theColor,sztitle, szlabelmapping, bprintimage,bstringlabels,bbrowser);
+ bcenter, bunique, busesignal,szcolfields,bbaseres, szoutfile,bcolscaleheat,theColor,sztitle, szlabelmapping, bprintimage,bstringlabels,bbrowser,blogpvals);
}
else
{
StateAnalysis.enrichmentMax(szinput, szinputcoorddir,szinputcoordlist,noffsetleft,noffsetright,nbinsize,
- bcenter, bunique, busesignal,szcolfields,bbaseres, szoutfile,bcolscaleheat,theColor,sztitle, szlabelmapping,bprintimage,bstringlabels,bbrowser);
+ bcenter, bunique, busesignal,szcolfields,bbaseres, szoutfile,bcolscaleheat,theColor,sztitle, szlabelmapping,bprintimage,bstringlabels,bbrowser,blogpvals);
}
}
else
{
StateAnalysis.enrichmentPosterior(szinput, szcell,szinputcoorddir,szinputcoordlist,noffsetleft,noffsetright,nbinsize,
- bcenter, bunique, busesignal,szcolfields,bbaseres,szoutfile,bcolscaleheat,theColor,sztitle, szlabelmapping,bprintimage);
+ bcenter, bunique, busesignal,szcolfields,bbaseres,szoutfile,bcolscaleheat,theColor,sztitle, szlabelmapping,bprintimage,blogpvals);
}
}
else
@@ -14684,8 +14718,8 @@ public class ChromHMM
{
System.out.println("usage OverlapEnrichment [-a cell][-b binsize][-binres][-browser][-color r,g,b][-center][-colfields chromosome,start,end[,signal]]"+
"[-e offsetend][-f coordlistfile][-labels][-lowmem][-m labelmappingfile]"+
- "[-multicount][-noimage][-posterior][-s offsetstart][-signal][-t title][-uniformscale]"+
- " inputsegment inputcoorddir outfileprefix");
+ "[-multicount][-noimage][-nopvals][-posterior][-s offsetstart][-signal][-t title][-uniformscale]"+
+ " inputsegment inputcoorddir outfileprefix");
}
}
else if ((szcommand.equalsIgnoreCase("NeighborhoodEnrichment"))||(szcommand.equalsIgnoreCase("NeighborhoodSignal")))
@@ -15391,7 +15425,7 @@ public class ChromHMM
ChromHMM.DEFAULT_OVERLAPENRICHMENT_BCENTER, !ChromHMM.DEFAULT_OVERLAPENRICHMENT_BCOUNTMULTI,
ChromHMM.DEFAULT_OVERLAPENRICHMENT_BUSESIGNAL,null,//szcolfields,
ChromHMM.DEFAULT_OVERLAPENRICHMENT_BBASERES, szoutputdir+"/"+szprefix+ChromHMM.SZOVERLAPEXTENSION,
- !ChromHMM.DEFAULT_OVERLAPENRICHMENT_BUNIFORMHEAT,theColor,"Fold Enrichment "+szprefix,null,bprintimage, false,false);
+ !ChromHMM.DEFAULT_OVERLAPENRICHMENT_BUNIFORMHEAT,theColor,"Fold Enrichment "+szprefix,null,bprintimage, false,false,false);
}
else
{
@@ -15403,7 +15437,7 @@ public class ChromHMM
ChromHMM.DEFAULT_OVERLAPENRICHMENT_BCENTER, !ChromHMM.DEFAULT_OVERLAPENRICHMENT_BCOUNTMULTI,
ChromHMM.DEFAULT_OVERLAPENRICHMENT_BUSESIGNAL,null,//szcolfields,
ChromHMM.DEFAULT_OVERLAPENRICHMENT_BBASERES, szoutputdir+"/"+szprefix+ChromHMM.SZOVERLAPEXTENSION,
- !ChromHMM.DEFAULT_OVERLAPENRICHMENT_BUNIFORMHEAT,theColor,"Fold Enrichment "+szprefix,null,bprintimage, false,false);
+ !ChromHMM.DEFAULT_OVERLAPENRICHMENT_BUNIFORMHEAT,theColor,"Fold Enrichment "+szprefix,null,bprintimage, false,false,false);
}
String szoverlapoutfile = szprefix+ChromHMM.SZOVERLAPEXTENSION+".txt";
if (bprintimage)
=====================================
edu/mit/compbio/ChromHMM/StateAnalysis.java
=====================================
@@ -38,6 +38,11 @@ public class StateAnalysis
*/
static double EPSILONOVERLAP = 0.00000001;
+ /**
+ * Limit on how significant p-value should be reported in OverlapEnrichment
+ */
+ static double PVALLOG10CUTOFF = 300;
+
/**
* A record for storing a segmentation
@@ -200,7 +205,8 @@ public class StateAnalysis
public static void enrichmentPosterior(String szposteriordir,String szcell,String szinputcoorddir, String szinputcoordlist,
int noffsetleft, int noffsetright, int nbinsize,
boolean bcenter,boolean bunique, boolean busesignal,String szcolfields,boolean bbaseres,
- String szoutfile,boolean bcolscaleheat, Color theColor,String sztitle,String szlabelmapping, boolean bprintimage) throws IOException
+ String szoutfile,boolean bcolscaleheat, Color theColor,String sztitle,
+ String szlabelmapping, boolean bprintimage, boolean blogpvals) throws IOException
{
String szLine;
@@ -542,7 +548,8 @@ public class StateAnalysis
}
else
{
- damount = 1;
+ //update in v1.26
+ damount = 1.0/(double) (nbinsize);
}
if (bcenter)
@@ -640,7 +647,7 @@ public class StateAnalysis
outputenrichment(szoutfile, files,tallyoverlaplabel, tallylabel, dsumoverlaplabel,theColor,bcolscaleheat,ChromHMM.convertCharOrderToStringOrder(chorder),
- sztitle,1,szlabelmapping,chorder, bprintimage,false, null);
+ sztitle,1,szlabelmapping,chorder, bprintimage,false, null,bcenter&&blogpvals,!bunique,nbinsize);
}
@@ -667,7 +674,8 @@ public class StateAnalysis
int noffsetleft, int noffsetright,
int nbinsize, boolean bcenter,boolean bunique, boolean busesignal,String szcolfields,
boolean bbaseres, String szoutfile,boolean bcolscaleheat,Color theColor,String sztitle,
- String szlabelmapping, boolean bprintimage, boolean bstringlabels, boolean bbrowser) throws IOException
+ String szlabelmapping, boolean bprintimage,
+ boolean bstringlabels, boolean bbrowser, boolean blogpvals) throws IOException
{
//usual high memory
ArrayList alsegments = new ArrayList(); //stores all the segments
@@ -1131,7 +1139,8 @@ public class StateAnalysis
}
else
{
- damount = 1;
+ //fix in v1.26
+ damount = 1.0/(double) (nbinsize);
}
Integer objChrom = (Integer) hmchromToIndex.get(szchrom);
@@ -1216,7 +1225,7 @@ public class StateAnalysis
outputenrichment(szoutfile, files,tallyoverlaplabel, tallylabel, dsumoverlaplabel,theColor,
bcolscaleheat,ChromHMM.convertCharOrderToStringOrder(szlabel.charAt(0)),sztitle,0,szlabelmapping,szlabel.charAt(0), bprintimage,
- bstringlabels, hmIndexToLabel);
+ bstringlabels, hmIndexToLabel, bcenter&&blogpvals, !bunique, nbinsize);
}
@@ -1245,8 +1254,9 @@ public class StateAnalysis
public static void enrichmentMaxLowMem(String szinputsegment,String szinputcoorddir,String szinputcoordlist,
int noffsetleft, int noffsetright,
int nbinsize, boolean bcenter,boolean bunique, boolean busesignal,String szcolfields,
- boolean bbaseres, String szoutfile,boolean bcolscaleheat,Color theColor,String sztitle,
- String szlabelmapping, boolean bprintimage, boolean bstringlabels, boolean bbrowser) throws IOException
+ boolean bbaseres, String szoutfile,boolean bcolscaleheat,Color theColor,String sztitle,
+ String szlabelmapping, boolean bprintimage,
+ boolean bstringlabels, boolean bbrowser, boolean blogpvals) throws IOException
{
@@ -1803,7 +1813,8 @@ public class StateAnalysis
}
else
{
- damount = 1;
+ //fix in v1.26
+ damount = 1.0/(double)nbinsize;
}
//Integer objChrom = (Integer) hmchromToIndex.get(szchrom);
@@ -1890,7 +1901,7 @@ public class StateAnalysis
}
outputenrichment(szoutfile, files,tallyoverlaplabel, tallylabel, dsumoverlaplabel,theColor,
- bcolscaleheat,ChromHMM.convertCharOrderToStringOrder(szlabel.charAt(0)),sztitle,0,szlabelmapping,szlabel.charAt(0), bprintimage, bstringlabels, hmIndexToLabel);
+ bcolscaleheat,ChromHMM.convertCharOrderToStringOrder(szlabel.charAt(0)),sztitle,0,szlabelmapping,szlabel.charAt(0), bprintimage, bstringlabels, hmIndexToLabel, bcenter&&blogpvals, !bunique,nbinsize);
}
@@ -1932,7 +1943,8 @@ public class StateAnalysis
double[] tallylabel, double[] dsumoverlaplabel,Color theColor,
boolean bcolscaleheat,String szstateorder,String sztitle, int noffset,
String szlabelmapping,char chorder, boolean bprintimage,
- boolean bstringlabels, HashMap hmIndexToLabel) throws IOException
+ boolean bstringlabels, HashMap hmIndexToLabel,
+ boolean blogpvals, boolean bbinomial,int nbinsize) throws IOException
{
HashMap hmlabelExtend = makeLabelMapping(szlabelmapping);
@@ -1956,13 +1968,50 @@ public class StateAnalysis
System.out.println("Writing to file "+szoutfile+".txt");
PrintWriter pw = new PrintWriter(new FileWriter(szoutfile+".txt"));
- pw.print("State ("+szstateorder+" order)\tGenome %");
+
+ //added v1.26
+ PrintWriter pwlogpval = null;
+ if (blogpvals)
+ {
+ System.out.println("Writing to file "+szoutfile+"_log10pvals.txt");
+ pwlogpval = new PrintWriter(new FileWriter(szoutfile+"_log10pvals.txt"));
+ }
+
+ //added v1.26
+ if (bcolscaleheat)
+ {
+ pw.print("State ("+szstateorder+" order)\tGenome %");
+
+ if (blogpvals)
+ {
+ pwlogpval.print("State ("+szstateorder+" order)\tGenome %");
+ }
+ }
+ else
+ {
+ pw.print("State ("+szstateorder+" order)");
+
+ if (blogpvals)
+ {
+ pwlogpval.print("State ("+szstateorder+" order)");
+ }
+ }
+
for (int nfile = 0; nfile < files.length; nfile++)
{
pw.print("\t"+files[nfile]);
}
pw.println();
+ if (blogpvals)
+ {
+ for (int nfile = 0; nfile < files.length; nfile++)
+ {
+ pwlogpval.print("\t"+files[nfile]);
+ }
+ pwlogpval.println();
+ }
+
double[][] heatmapfold;
@@ -1976,6 +2025,19 @@ public class StateAnalysis
heatmapfold = new double[tallyoverlaplabel[0].length][tallyoverlaplabel.length];
}
+ double[][] heatmaplogpval = null;
+ if (blogpvals)
+ {
+ if (bcolscaleheat)
+ {
+ heatmaplogpval = new double[tallyoverlaplabel[0].length][tallyoverlaplabel.length+1];
+ }
+ else
+ {
+ heatmaplogpval = new double[tallyoverlaplabel[0].length][tallyoverlaplabel.length];
+ }
+ }
+
int numelim = 0;
for (int nstate = 0; nstate < tallyoverlaplabel[0].length; nstate++)
@@ -1985,15 +2047,29 @@ public class StateAnalysis
if (bstringlabels)
{
pw.print(hmIndexToLabel.get(""+nstate));
+
+ if (blogpvals)
+ {
+ pwlogpval.print(hmIndexToLabel.get(""+nstate));
+ }
}
else
{
pw.print(nstate+noffset);
+ if (blogpvals)
+ {
+ pwlogpval.print(nstate+noffset);
+ }
String szsuffix;
if ((szsuffix = (String) hmlabelExtend.get(""+chorder+(nstate+noffset)))!=null)
{
pw.print("_"+szsuffix);
+
+ if (blogpvals)
+ {
+ pwlogpval.print("_"+szsuffix);
+ }
}
}
@@ -2002,6 +2078,12 @@ public class StateAnalysis
//only include genome % if scaling by column
heatmapfold[nstate][0] =100*(tallylabel[nstate]/dsumlabel); //first column is heatmap
pw.print("\t"+nf5.format(heatmapfold[nstate][0]));
+
+ if (blogpvals)
+ {
+ heatmaplogpval[nstate][0] = 100*(tallylabel[nstate]/dsumlabel);
+ pwlogpval.print("\t"+nf5.format(heatmaplogpval[nstate][0]));
+ }
}
for (int nfile = 0; nfile < tallyoverlaplabel.length; nfile++)
{
@@ -2016,27 +2098,114 @@ public class StateAnalysis
{
heatmapfold[nstate][nfile] = dfold;
}
+
pw.print("\t"+nf5.format(dfold));
+
+ if (blogpvals)
+ {
+ double dlogpval;
+ if (bbinomial)
+ {
+ dlogpval = -Math.log(binomialtail(Math.round(tallyoverlaplabel[nfile][nstate]*nbinsize-1),
+ Math.round(dsumoverlaplabel[nfile]*nbinsize),
+ tallylabel[nstate]/dsumlabel))/Math.log(10);
+
+ }
+ else
+ {
+
+ dlogpval = -Math.log(hypergeometrictail(Math.round(tallyoverlaplabel[nfile][nstate]*nbinsize-1),
+ Math.round(tallylabel[nstate]*nbinsize),
+ Math.round((dsumlabel- tallylabel[nstate])*nbinsize),
+ Math.round(dsumoverlaplabel[nfile]*nbinsize)))/Math.log(10);
+ }
+
+ if (dlogpval > PVALLOG10CUTOFF)
+ {
+ dlogpval = PVALLOG10CUTOFF;
+ }
+ else if (dlogpval == -0)
+ {
+ dlogpval = 0;
+ }
+
+ if (bcolscaleheat)
+ {
+ heatmaplogpval[nstate][nfile+1] = dlogpval;
+ }
+ else
+ {
+ heatmaplogpval[nstate][nfile] = dlogpval;
+ }
+
+ pwlogpval.print("\t"+nf5.format(dlogpval));
+ }
+
}
pw.println();
+
+ if (blogpvals)
+ {
+ pwlogpval.println();
+ }
}
else
{
numelim++;
}
}
- pw.print("Base\t100");
- for (int nfile = 0; nfile < tallyoverlaplabel.length; nfile++)
+
+ //added v1.26
+ if (bcolscaleheat)
{
- pw.print("\t"+nf10.format(100*(dsumoverlaplabel[nfile]/dsumlabel)));
+ pw.print("Base\t100");
}
+ else
+ {
+ pw.print("Base");
+ }
+
+ for (int nfile = 0; nfile < tallyoverlaplabel.length; nfile++)
+ {
+ pw.print("\t"+nf10.format(100*(dsumoverlaplabel[nfile]/dsumlabel)));
+ }
+
pw.println();
pw.close();
+
+
+ if (blogpvals)
+ {
+ //added v1.26
+ if (bcolscaleheat)
+ {
+ pwlogpval.print("Base\t100");
+ }
+ else
+ {
+ pwlogpval.print("Base");
+ }
+
+ for (int nfile = 0; nfile < tallyoverlaplabel.length; nfile++)
+ {
+ pwlogpval.print("\t"+nf10.format(100*(dsumoverlaplabel[nfile]/dsumlabel)));
+ }
+
+ pwlogpval.println();
+ pwlogpval.close();
+ }
+
String[] rowlabels;// = new String[tallyoverlaplabel[0].length];
if (numelim > 0)
{
double[][] heatmapreduce = new double[heatmapfold.length-numelim][heatmapfold[0].length];
+
+ double[][] heatmapreducelogpval = null;
+ if (blogpvals)
+ {
+ heatmapreducelogpval = new double[heatmaplogpval.length-numelim][heatmaplogpval[0].length];
+ }
rowlabels = new String[heatmapreduce.length];
int nkeepindex = 0;
for (int nstate = 0; nstate < tallyoverlaplabel[0].length; nstate++)
@@ -2046,6 +2215,11 @@ public class StateAnalysis
for (int ncol = 0; ncol < heatmapfold[nstate].length; ncol++)
{
heatmapreduce[nkeepindex][ncol] = heatmapfold[nstate][ncol];
+
+ if (blogpvals)
+ {
+ heatmapreducelogpval[nkeepindex][ncol] = heatmaplogpval[nstate][ncol];
+ }
}
if (bstringlabels)
@@ -2118,6 +2292,33 @@ public class StateAnalysis
heatmapfold[nstate][nfile] =(heatmapfold[nstate][nfile]-dminval)/dmaxval;
}
}
+
+ if (blogpvals)
+ {
+ for (int nfile = 0; nfile < heatmaplogpval[0].length; nfile++)
+ {
+ double dmaxval = Double.NEGATIVE_INFINITY;
+ double dminval = Double.POSITIVE_INFINITY;
+
+ for (int nstate = 0; nstate < heatmaplogpval.length; nstate++)
+ {
+ if (heatmaplogpval[nstate][nfile] > dmaxval)
+ {
+ dmaxval = heatmaplogpval[nstate][nfile];
+ }
+
+ if (heatmaplogpval[nstate][nfile] < dminval)
+ {
+ dminval = heatmaplogpval[nstate][nfile];
+ }
+ }
+
+ for (int nstate = 0; nstate < heatmaplogpval.length; nstate++)
+ {
+ heatmaplogpval[nstate][nfile] =(heatmaplogpval[nstate][nfile]-dminval)/dmaxval;
+ }
+ }
+ }
}
String[] collabels = new String[heatmapfold[0].length];
@@ -2160,6 +2361,200 @@ public class StateAnalysis
{
makeEnrichmentHeatMap(heatmapfold, collabels, rowlabels,szoutfile,theColor,sztitle,
"Category","State ("+szstateorder+" order)");
+
+ if (blogpvals)
+ {
+ makeEnrichmentHeatMap(heatmaplogpval, collabels, rowlabels,szoutfile+"_log10pvals",theColor,sztitle,
+ "Category","State ("+szstateorder+" order)");
+ }
+ }
+ }
+
+ //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ /**
+ *this hashtable caches previously computed binomial coefficient values so they do not need to be recomputed
+ */
+ public static Hashtable htbinom =new Hashtable();
+
+ /**
+ * Code based on STEM/DREM code I (Jason Ernst) previously wrote
+ *Returns the log of the binomial coefficient N choose ni
+ */
+ public static double logbinomcoeff(long ni, long N)
+ {
+ String sz = ni+";"+N;
+ Double dobj = (Double) htbinom.get(sz);
+ double dsum;
+
+ if (dobj != null)
+ {
+ dsum = ((Double) dobj).doubleValue();
+ }
+ else
+ {
+ dsum = 0;
+ long dmax = Math.max(ni,N-ni);
+ long dmin = Math.min(ni,N-ni);
+
+ //the log of the part of the numerator not cancelled by
+ //the larger factorial in the denominator
+ for (long nj = dmax+1; nj <=N; nj++)
+ {
+ dsum += Math.log(nj);
+ }
+
+ //subtract off the log of the denominator of the smaller term
+ for (long nj = 2; nj <=dmin; nj++)
+ {
+ dsum -= Math.log(nj);
+ }
+ //store it
+ htbinom.put(sz,new Double(dsum));
+ }
+
+ return dsum;
+ }
+
+
+ //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+
+ /**
+ * Code based on STEM/DREM code I (Jason Ernst) previously wrote
+ * Computes the probability of seeing more than nx successes in nN trials
+ * where the probability of a success is dp.
+ */
+ public static double binomialtail(long nx,long nN, double dp)
+ {
+ if (nx > nN)
+ {
+ return 0;
+ }
+ else if ((nx < 0)||(dp<=0)||(dp>=1))
+ {
+ return 1;
+ }
+
+ nx++;
+ double dterm = logbinomcoeff(nx, nN);
+ double dpv1 = Math.log(dp);
+ double dpv2 = Math.log(1-dp);
+
+ dterm += nx*dpv1+(nN-nx)*dpv2;
+
+ double dlogprob = dterm;
+ double dpdiff = dpv1-dpv2;
+ double dprob;
+ for (long ni = nx+1; ni <= nN; ni++)
+ {
+ //N!/(ni!(N-ni)!)
+ //N!/((ni-1)!(N-ni+1)!)
+ dterm += Math.log(nN-ni+1) - Math.log(ni) + dpdiff;
+
+ if (dterm >= dlogprob)
+ {
+ dlogprob = dterm + Math.log(1+Math.pow(Math.E,dlogprob-dterm));
+ }
+ else
+ {
+ dlogprob = dlogprob + Math.log(1+Math.pow(Math.E,dterm-dlogprob));
+ }
+ }
+ dprob = Math.pow(Math.E,dlogprob);
+
+ if (dprob <= 0)
+ {
+ return 0;
+ }
+ else if (dprob >= 1)
+ {
+ return 1;
+ }
+ else
+ {
+ return dprob;
+ }
+ }
+
+
+
+ //////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+ /**
+ * Code based on STEM/DREM code I (Jason Ernst) previously wrote
+ * Returns the probability of seeing more than nx objects of type A, when there are nA objects of type A
+ * nB objects of type B, and nm objects total drawn
+ * This can be used to compute a more accurate p-values than a 1-cumulative probability calculation
+ */
+ public static double hypergeometrictail(long nx, long nA, long nB, long nm)
+ {
+ if (nx < 0)
+ {
+ return 1;
+ }
+
+ double dprob = 0;
+
+
+ long nminx = Math.max(nx+1,0); //the first element to the right of x or 0
+ long nmaxx = Math.min(nA,nm); //the max of type A there can be
+
+ if (nminx > nmaxx)
+ {
+ //if nx approaches infinity tail should be 0
+ return 0;
+ }
+
+ double dsum = -logbinomcoeff(nm, nA + nB)+ logbinomcoeff(nminx, nA)
+ + logbinomcoeff(nm-nminx, nB);
+
+ double dlogprob=dsum;
+ for (long ni = nminx+1; ni <= nmaxx; ni++)
+ {
+ //computing the increase in probability mass
+ //numerator has nA!/(ni!(nA-ni)!) * nB!/((nm-ni)!(nB-nm+ni)!)
+ //denominator has (nA+nB)!/(nm!(nA+nB-nm)!)
+
+ //numerator has nA!/((ni-1)!(nA-ni+1)!) * nB!/((nm-ni+1)!(nB-nm+ni-1)!)
+ //denominator has (nA+nB)!/(nm!(nA+nB-nm)!)
+
+ //cancelling gives
+ //1/(ni!(nA-ni)!) * 1/((nm-ni)!(nB-nm+ni)!) over
+ //1/((ni-1)!(nA-ni+1)!) * 1/((nm-ni+1)!(nB-nm+ni-1)!)
+ dsum += Math.log(nA-ni+1)-Math.log(nB-nm+ni)
+ + Math.log(nm-ni+1)-Math.log(ni);
+
+
+ //log(a+b+c+d+e)
+ //log(e) + log(a+b+c+d+e) - log(e)
+ //log(e) + log((a+b+c+d+e)/e)
+ //log(e) + log(1+(a+b+c+d)/e)
+ //log(e) + log(1+Math.exp(log(a+b+c+d)-log(e)))
+
+ if (dsum >= dlogprob)
+ {
+ dlogprob = dsum + Math.log(1+Math.pow(Math.E,dlogprob-dsum));
+ }
+ else
+ {
+ dlogprob = dlogprob + Math.log(1+Math.pow(Math.E,dsum-dlogprob));
+ }
+ }
+
+ dprob = Math.pow(Math.E,dlogprob);
+
+
+ if (dprob <= 0)
+ {
+ return 0;
+ }
+ else if (dprob >= 1)
+ {
+ return 1;
+ }
+ else
+ {
+ return dprob;
}
}
@@ -2276,6 +2671,16 @@ public class StateAnalysis
boolean bstringlabels, boolean bbrowser) throws IOException
{
+ //v1.26
+ int nminnumcols =3;
+ if (busestrand && busesignal)
+ {
+ nminnumcols = 4;
+ }
+ else if (!busestrand && !busesignal)
+ {
+ nminnumcols = 2;
+ }
boolean bchrommatch = false;//added in 1.23 to check for chromosome matches
//an array of chromosome names
@@ -2592,6 +2997,12 @@ public class StateAnalysis
if (szLine.trim().equals("")) continue;
String[] szLineA = szLine.split("\\s+");
+ if (szLineA.length < nminnumcols)
+ {
+ //v1.26
+ throw new IllegalArgumentException("Line: "+szLine +" in "+szanchorpositions+" has "+szLineA.length+" columns while expecting "+nminnumcols);
+ }
+
String szchrom = szLineA[theAnchorIndex.nchromindex];
if (!szchrom.equals(szchromwant))
continue;
@@ -2707,6 +3118,17 @@ public class StateAnalysis
String sztitle,String szlabelmapping, boolean bprintimage,
boolean bstringlabels, boolean bbrowser) throws IOException
{
+ //v1.26
+ int nminnumcols =3;
+ if (busestrand && busesignal)
+ {
+ nminnumcols = 4;
+ }
+ else if (!busestrand && !busesignal)
+ {
+ nminnumcols = 2;
+ }
+
//highmem
boolean bchrommatch = false;//added in 1.23 to check for chromosome matches
//stores all the segments in the data
@@ -2935,9 +3357,15 @@ public class StateAnalysis
BufferedReader brcoords = Util.getBufferedReader(szanchorpositions);
while ((szLine = brcoords.readLine())!=null)
{
- if (szLine.trim().equals("")) continue;
+ if (szLine.trim().equals("")) continue;
String[] szLineA = szLine.split("\\s+");
+ if (szLineA.length < nminnumcols)
+ {
+ //v1.26
+ throw new IllegalArgumentException("Line: "+szLine +" in "+szanchorpositions+" has "+szLineA.length+" columns while expecting "+nminnumcols);
+ }
+
String szchrom = szLineA[theAnchorIndex.nchromindex];
int nanchor = (Integer.parseInt(szLineA[theAnchorIndex.npositionindex])-noffsetanchor);
boolean bposstrand = true;
@@ -3049,6 +3477,16 @@ public class StateAnalysis
boolean busestrand, boolean busesignal,String szcolfields, int noffsetanchor,
String szoutfile,Color theColor,String sztitle,String szlabelmapping, boolean bprintimage) throws IOException
{
+ //v1.26
+ int nminnumcols =3;
+ if (busestrand && busesignal)
+ {
+ nminnumcols = 4;
+ }
+ else if (!busestrand && !busesignal)
+ {
+ nminnumcols = 2;
+ }
boolean bchrommatch = false;//added in 1.23 to check for chromosome matches
//posterior here is really signal just using equivalent variable names
@@ -3163,6 +3601,13 @@ public class StateAnalysis
if (szLine.trim().equals("")) continue;
//going through all the coordinates keeping only those for the current chromosome
String[] szLineA = szLine.split("\\s+");
+
+ if (szLineA.length < nminnumcols)
+ {
+ //v1.26
+ throw new IllegalArgumentException("Line: "+szLine +" in "+szanchorpositions+" has "+szLineA.length+" columns while expecting "+nminnumcols);
+ }
+
String szreadchrom = szLineA[theAnchorIndex.nchromindex];
if (szreadchrom.equals(szchrom))
@@ -3291,6 +3736,16 @@ public class StateAnalysis
boolean busestrand, boolean busesignal,String szcolfields, int noffsetanchor,
String szoutfile,Color theColor,String sztitle,String szlabelmapping, boolean bprintimage) throws IOException
{
+ //v1.26
+ int nminnumcols =3;
+ if (busestrand && busesignal)
+ {
+ nminnumcols = 4;
+ }
+ else if (!busestrand && !busesignal)
+ {
+ nminnumcols = 2;
+ }
boolean bchrommatch = false;//added in 1.23 to check for chromosome matches
//list of possible posterior files
@@ -3403,6 +3858,14 @@ public class StateAnalysis
if (szLine.trim().equals("")) continue;
//going through all the coordinates keeping only those for the current chromosome
String[] szLineA = szLine.split("\\s+");
+
+ if (szLineA.length < nminnumcols)
+ {
+ //v1.26
+ throw new IllegalArgumentException("Line: "+szLine +" in "+szanchorpositions+" has "+szLineA.length+" columns while expecting "+nminnumcols);
+ }
+
+
String szreadchrom = szLineA[theAnchorIndex.nchromindex];
if (szreadchrom.equals(szchrom))
=====================================
versionlog.txt
=====================================
@@ -1,3 +1,14 @@
+1/2/2025 ChromHMM 1.26
+* Added to ChromHMM's output -log10 p-values of enrichments when using OverlapEnrichment with the '-center' flag. This can be supressed with the use of the '-nopvals' flag
+* Fixed a bug when running OverlapEnrichment with the '-uniformscale' flag that caused ChromHMM to display an extraneous 'Genome %'
+in the header row and 100% in the bottom row in the text file output. This did not effect the image files or running in a default mode without the flag.
+* Fixed a bug when running OverlapEnrichment with the '-center' and '-multicount' flags that caused an incorrect base % for the annotation category
+to be reported.
+* Provides a more informative error message when running NeighborhoodEnrichment and an input line has less than the expected number of entries
+* Now throws an error if the beginning of an output segment would be past the length of a chromosome specified in a file given with the "-l" option, which could be because a different assembly
+was used for the binarization.
+
+
12/28/2023 ChromHMM 1.25
* Added the flag '-nobrowserheader' to LearnModel and MakeBrowserFiles to surpress the printing of header lines in browser bed files
* Added the flag '-nopseudoinit' to LearnModel which prevents pseudocounts from being added in computing the emission parameter of the last mark and
View it on GitLab: https://salsa.debian.org/med-team/chromhmm/-/commit/d70bc9dae0d6d3b51a0ba2f5cb615d191c84875c
--
View it on GitLab: https://salsa.debian.org/med-team/chromhmm/-/commit/d70bc9dae0d6d3b51a0ba2f5cb615d191c84875c
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20250203/2c8f9dac/attachment-0001.htm>
More information about the debian-med-commit
mailing list